Skip to content

Instantly share code, notes, and snippets.

@ricston-git
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricston-git/386497c51fcf88fc1759 to your computer and use it in GitHub Desktop.
Save ricston-git/386497c51fcf88fc1759 to your computer and use it in GitHub Desktop.
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