Created
March 31, 2016 20:00
-
-
Save young-steveo/c5f97dea15b8d0a3cdb21a03de498ad9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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