/
githubmirror
/
express
Обзор
Документация
Войти
/
githubmirror
/
express
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/mvc/controllers/pet/index.js
31 строка
599 B
Douglas Christopher Wilson
examples: use strict mode
02 фев 2022, 09:30
02 фев 2022, 09:30
20047bb
Код
Авторство
О чём код?
'use strict' /** * Module dependencies. */ var db = require('../../db'); exports.engine = 'ejs'; exports.before = function(req, res, next){ var pet = db.pets[req.params.pet_id]; if (!pet) return next('route'); req.pet = pet; next(); }; exports.show = function(req, res, next){ res.render('show', { pet: req.pet }); }; exports.edit = function(req, res, next){ res.render('edit', { pet: req.pet }); }; exports.update = function(req, res, next){ var body = req.body; req.pet.name = body.pet.name; res.message('Information updated!'); res.redirect('/pet/' + req.pet.id); };