Skip to content

Instantly share code, notes, and snippets.

@Southern
Last active December 15, 2015 07:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Southern/ad1bc1eb2742305e9dd7 to your computer and use it in GitHub Desktop.
Save Southern/ad1bc1eb2742305e9dd7 to your computer and use it in GitHub Desktop.
// Initialize nconf
var nconf = require('nconf');
// Get the route
var route = require('./route.js');
// Setup the route
express.get('/', route(nconf));
function route(req, res) {
// this = nconf
// req = Express' this.request
// res = Express' this.response
res.send('Hello world!');
}
module.exports = function(conf) {
return function(req, res) {
// Store Express' bind
var self = this;
// Bind to nconf and call the route with Express' this.request and this.response.
return route.bind(conf)(self.request, self.response);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment