carbone-connect
v0.1.1
Published
A lib to connect to remote carbone server
Downloads
45
Maintainers
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);
});