carbone-connect

0.1.1 • Public • Published

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);
});

Dependencies (2)

Dev Dependencies (1)

Package Sidebar

Install

npm i carbone-connect

Weekly Downloads

73

Version

0.1.1

License

MIT

Unpacked Size

58.8 kB

Total Files

6

Last publish

Collaborators

  • fleebz