用 Node.js 快速打造 RESTful API
 http://blog.techbridge.cc/2016/04/23/fast-restful-nodejs-api-backend/

API 觀念
 http://leeboy19890101-blog.logdown.com/posts/578758

用 node.js 實作 API
 http://hzchirs-blog.logdown.com/posts/212065-build-restful-web-api-by-using-nodejs-and-express4

node.js 的方式:
 http://scottksmith.com/blog/2014/05/05/beer-locker-building-a-restful-api-with-node-crud/
 監聽 router 的 動作,然後根據動作來決定function 內容
 所以 每個 model 可以指定一個 router
 ex.

var router = express.Router();
var Route = router.route('/posts')
var Post = require('./models/post');
Route
.get(function(request, response) {
res.json({
id: req.params.id,
title: 'Article' + req.params.id
})
})

.post(function(req, res) {
var post = new Post()

Post.title = req.body.name
Post.type = req.body.type
Post.author = req.body.author

Post.save(function(err) {
if (err) {
res.send(err)

res.json({ message: 'Post have been created!', data: Post})
}
})
})
Show your support

Clapping shows how much you appreciated Zuray’s story.