サンプル
https://github.com/visionmedia/express/tree/master/examples/ にてオトせるらしいとのことにてとりあえず clone してみました。
$ git clone https://github.com/visionmedia/express.git Initialized empty Git repository in /home/rms/Documents/nodejs/express/.git/ remote: Counting objects: 17712, done. remote: Compressing objects: 100% (6041/6041), done. remote: Total 17712 (delta 11194), reused 17275 (delta 10836) Receiving objects: 100% (17712/17712), 4.26 MiB | 828 KiB/s, done. Resolving deltas: 100% (11194/11194), done. $
ぼちぼち読みはじめてみます。
ふふ
mvc なサンプルに以下なナニを発見。
function bootController(app, file) { var name = file.replace('.js', '') , actions = require('./controllers/' + name) , plural = name + 's' // realistically we would use an inflection lib , prefix = '/' + plural; // Special case for "app" if (name == 'app') prefix = '/'; Object.keys(actions).map(function(action){ var fn = controllerAction(name, plural, action, actions[action]); switch(action) { case 'index': app.get(prefix, fn); break; case 'show': app.get(prefix + '/:id.:format?', fn); break; case 'add': app.get(prefix + '/:id/add', fn); break; case 'create': app.post(prefix + '/:id', fn); break; case 'edit': app.get(prefix + '/:id/edit', fn); break; case 'update': app.put(prefix + '/:id', fn); break; case 'destroy': app.del(prefix + '/:id', fn); break; } }); }
REST ですな。ここから確認入れた方が良さげ。