Skip to content
Myr

index.js

This file

Path

examples/mvc/controllers/user/index.js

37 lines · 833 bytes · JavaScript

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than 6bc7574 point at it.

docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574

lines 1–37why, one step back
1/**
2 * Module dependencies.3 */45var db = require('../../db');67exports.before = function(req, res, next){8 var id = req.params.user_id;9 if (!id) return next();10 // pretend to query a database...11 process.nextTick(function(){12 req.user = db.users[id];13 // cant find that user14 if (!req.user) return next('route');15 // found it, move on to the routes16 next();17 });18};1920exports.list = function(req, res, next){21 res.render('list', { users: db.users });22};2324exports.edit = function(req, res, next){25 res.render('edit', { user: req.user });26};2728exports.show = function(req, res, next){29 res.render('show', { user: req.user });30};3132exports.update = function(req, res, next){33 var body = req.body;34 req.user.name = body.user.name;35 res.message('Information updated!');36 res.redirect('/user/' + req.user.id);37};