Home / File/ index.js — express Source File

index.js — express Source File

Architecture documentation for index.js, a javascript file in the express codebase.

Entity Profile

Relationship Graph

Source Code

'use strict'

/**
 * Module dependencies.
 */

var db = require('../../db');

exports.engine = 'hbs';

exports.before = function(req, res, next){
  var id = req.params.user_id;
  if (!id) return next();
  // pretend to query a database...
  process.nextTick(function(){
    req.user = db.users[id];
    // cant find that user
    if (!req.user) return next('route');
    // found it, move on to the routes
    next();
  });
};

exports.list = function(req, res, next){
  res.render('list', { users: db.users });
};

exports.edit = function(req, res, next){
  res.render('edit', { user: req.user });
};

exports.show = function(req, res, next){
  res.render('show', { user: req.user });
};

exports.update = function(req, res, next){
  var body = req.body;
  req.user.name = body.user.name;
  res.message('Information updated!');
  res.redirect('/user/' + req.user.id);
};

Domain

Subdomains

Functions

Frequently Asked Questions

What does index.js do?
index.js is a source file in the express codebase, written in javascript. It belongs to the ExpressCore domain, PrototypalExtension subdomain.
What functions are defined in index.js?
index.js defines 1 function(s): exports.
Where is index.js in the architecture?
index.js is located at examples/mvc/controllers/user/index.js (domain: ExpressCore, subdomain: PrototypalExtension, directory: examples/mvc/controllers/user).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free