-
-
Save Southern/ad1bc1eb2742305e9dd7 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
// Initialize nconf | |
var nconf = require('nconf'); | |
// Get the route | |
var route = require('./route.js'); | |
// Setup the route | |
express.get('/', route(nconf)); |
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 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