index.js
This file
Path
examples/mvc/controllers/user/index.js
41 lines · 873 bytes · JavaScript
Last changed by
docs: add missing apostrophe in example (#7483)Chris Zbefore adoption9169cbe
History of this fileTake it
The walk stopped after 200 commits: lines older than 2027b87 point at it.
fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1–16why, one step back1'use strict'23/**4 * Module dependencies.5 */67var db = require('../../db');89exports.engine = 'hbs';1011exports.before = function(req, res, next){12 var id = req.params.user_id;13 if (!id) return next();14 // pretend to query a database...15 process.nextTick(function(){16 req.user = db.users[id];docs: add missing apostrophe in example (#7483)Chris Zbefore adoption9169cbe
line 17why, one step back17 // can't find that userfix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 18–41why, one step back18 if (!req.user) return next('route');19 // found it, move on to the routes20 next();21 });22};2324exports.list = function(req, res, next){25 res.render('list', { users: db.users });26};2728exports.edit = function(req, res, next){29 res.render('edit', { user: req.user });30};3132exports.show = function(req, res, next){33 res.render('show', { user: req.user });34};3536exports.update = function(req, res, next){37 var body = req.body;38 req.user.name = body.user.name;39 res.message('Information updated!');40 res.redirect('/user/' + req.user.id);41};