Skip to content

Instantly share code, notes, and snippets.

@emilong
Last active March 28, 2016 21:17
Show Gist options
  • Save emilong/8a4c164e8dfe139c7951 to your computer and use it in GitHub Desktop.
Save emilong/8a4c164e8dfe139c7951 to your computer and use it in GitHub Desktop.
const path = require('path');
const glob = require('glob');
const express = require('express');
const Bottle = require('bottlejs');
const bottle = new Bottle();
// traverse the file system, passing this bottle to every javascript file we find
glob.sync(path.join(path.resolve(__dirname), 'app/**/*.js')).forEach((match) => {
require(match)(bottle);
});
// App provider factory
const createApp = function(PdfController) {
const app = express();
app.post('/pdfs/:content_id', PdfController.create);
return app;
}
bottle.service('app', createApp, 'controller.Pdfs');
// grab the application out of the container and start a server
const server = bottle.container.app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Listening at http://%s:%s', host, port);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment