Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Gists for 'taking the express route out' blog
tmp$ express todo-server
tmp$ cd todo-server
todo-server$ npm install
var express = require('express');
var router = express.Router();
var items = require('./items.json');
router.get('/', function(req, res) {
res.send(items);
});
module.exports = router;
{
"task A": true,
"task B": false
}
todo-server$ mkdir ../todo-items
todo-server$ cd ../todo-items
todo-items$ npm init
todo-items$ npm install --save express
var items = require('todo-items');
app.use('/items', items);
todo-server$ vim app.js
todo-items$ vim index.js
todo-items$ vim items.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.