Last active
March 28, 2016 21:17
-
-
Save emilong/8a4c164e8dfe139c7951 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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