Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nisaacson/controller-config-example
Example of passing a configuration object to an Express controller
https://github.com/nisaacson/controller-config-example
Last synced: about 1 month ago
JSON representation
Example of passing a configuration object to an Express controller
- Host: GitHub
- URL: https://github.com/nisaacson/controller-config-example
- Owner: nisaacson
- Created: 2013-01-30T02:26:06.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-01-30T02:38:05.000Z (almost 12 years ago)
- Last Synced: 2024-04-15T11:14:55.670Z (7 months ago)
- Language: JavaScript
- Size: 496 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Example of passing a configuration object to an Express controller
## Controller
```javascript
// controller.js file
module.exports = function(req, res, config) {
console.log('config parameter passed to controller', config);
res.end('config passed')
}
```
## App```javascript
// index.js file with the express app
var controller = require('./controller');
var config = {
key1: 'foo'
};
var express = require('express');
var app = express();
var port = 3000;
app.get('/', function(req, res){
controller(req, res, config);
});
app.listen(port);
console.log('app listening on port', 3000);
```## Usage
`node index.js`
`curl localhost:3000`