Skip to content

Instantly share code, notes, and snippets.

@young-steveo
Created March 31, 2016 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save young-steveo/c5f97dea15b8d0a3cdb21a03de498ad9 to your computer and use it in GitHub Desktop.
Save young-steveo/c5f97dea15b8d0a3cdb21a03de498ad9 to your computer and use it in GitHub Desktop.
// Factory
function createPdfsController(container) {
// the dependencies required by the service. This is still lazily evaluated,
// and mockable as long as you register the mock before accessing the service
// in your tests.
const PdfService = container.service.PdfGenerator;
return {
create: (req, res, next) => {
const content_id = req.params.content_id;
const pdf_id = PdfService.generate(content_id);
res.json({ pdf_id: pdf_id });
}
};
}
// Export a function that registers the service provider with the given container.
modules.export = bottle => {
bottle.factory(
'controller.Pdfs', // the name of the service we're providing
createPdfsController // the factory to create the service instance
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment