Coder Social home page Coder Social logo

ces1508 / carbone-connect Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fleebzz/carbone-connect

0.0 0.0 0.0 72 KB

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

License: MIT License

JavaScript 100.00%

carbone-connect's Introduction

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

carbone-connect's People

Contributors

fleebzz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.