Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

carbone-connect

fleebzz33MIT0.1.1

A lib to connect to remote carbone server

report, document, pdf, xslx, docx, odt, ods, json, connector, carbone

readme

carbone-connect

This package allows you to use a remote carbone server like the one provided by carbone-docker.

Installation

yarn add carbone-connect

Or

npm install --save carbone-connect

Then in your code :

const carbone = require(`carbone-connect`)(`http://carbone-docker-container`);

// Use carbone as usual...

Usage

This package exposes the same API than the original Carbone.io package with some additions.

Additions

Promise addition

If no callback is provided to carbone.render() then a Promise is returned

Legacy usage

carbone.render(templatePath, data, options, (err, report) => {
  // Do some stuff
}));

Promise usage

carbone.render(templatePath, data, options)
.then(report => {
  // Do some stuff with the report
})
.catch(err => {
  // ...
});

async/await usage

const report = await carbone.render(templatePath, data, options);

Stream addition

When you use Express and want to return the generated report you can speedup the process by using carbone.renderStream() method.

Example

app.get(`/report`, (req, res) => {
  carbone.renderStream(templatePath, data, options).pipe(res);
});