Last active
August 29, 2015 14:11
-
-
Save ricston-git/386497c51fcf88fc1759 to your computer and use it in GitHub Desktop.
Gists for 'taking the express route out' blog
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
tmp$ express todo-server | |
tmp$ cd todo-server | |
todo-server$ npm install |
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
var express = require('express'); | |
var router = express.Router(); | |
var items = require('./items.json'); | |
router.get('/', function(req, res) { | |
res.send(items); | |
}); | |
module.exports = router; |
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
{ | |
"task A": true, | |
"task B": false | |
} |
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
todo-server$ mkdir ../todo-items | |
todo-server$ cd ../todo-items | |
todo-items$ npm init | |
todo-items$ npm install --save express |
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
todo-items$ npm link | |
/Users/justin/.nvm/v0.10.33/lib/node_modules/todo-items -> /Users/justin/tmp/todo-items | |
todo-items$ cd ../todo-server | |
todo-server$ npm link todo-items | |
/Users/justin/tmp/todo-server/node_modules/todo-items -> /Users/justin/.nvm/v0.10.33/lib/node_modules/todo-items -> /Users/justin/tmp/todo-items |
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
var items = require('todo-items'); | |
app.use('/items', items); |
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
todo-server$ vim app.js |
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
todo-items$ vim index.js |
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
todo-items$ vim items.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment