Last active
August 29, 2015 13:56
-
-
Save imalberto/8832217 to your computer and use it in GitHub Desktop.
sample app.js
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
'use strict'; | |
var debug = require('debug')('app'), | |
express = require('express'), | |
libmojito = require('../../../'), | |
app, | |
mojito; | |
app = express(); | |
app.set('port', process.env.PORT || 8666); | |
libmojito.extend(app); | |
app.use(libmojito.middleware()); | |
app.mojito.attachRoutes(); | |
app.post('/tunnel', libmojito.tunnelMiddleware()); | |
app.get('/:type/:action', function (req, res, next) { | |
libmojito.dispatch(req.params.type + '.' + req.params.action)(req, res, next); | |
}); | |
app.get('/status', function (req, res) { | |
res.send('200 OK'); | |
}); | |
app.listen(app.get('port'), function () { | |
debug('Server listening on port ' + app.get('port') + ' ' + | |
'in ' + app.get('env') + ' mode'); | |
}); |
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
function dispatch (call) { | |
return function (req, res, next) { | |
// do it here | |
// replace req.params with keys that matches {key} from call | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment