users.js
1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var express = require('express');
var router = express.Router();
/* GET users listing. */
router.get('/', function(req, res, next) {
res.render('users/index', {users: [
{_id: 1, name: '지드래곤', email: 'gd@test.com'},
{_id: 2, name: '탑', email: 'top@test.com'},
{_id: 3, name: '승리', email: 'victory@test.com'},
{_id: 4, name: '태양', email: 'sun@test.com'},
{_id: 5, name: '대성', email: 'ds@test.com'}
]});
});
router.get('/new', function(req, res, next) {
res.render('users/new');
});
router.get('/:id/edit', function(req, res, next) {
res.render('users/edit', {user: {_id: 1, name: '지드래곤', email: 'gd@test.com'}});
});
router.put('/:id', function(req, res, next) {
req.flash('success', '사용자 정보가 변경되었습니다.');
res.redirect('/users');
});
router.delete('/:id', function(req, res, next) {
req.flash('success', '사용자 계정이 삭제되었습니다.');
res.redirect('/users');
});
router.get('/:id', function(req, res, next) {
res.render('users/show', {user: {_id: 1, name: '지드래곤', email: 'gd@test.com'}});
});
router.post('/', function(req, res, next) {
req.flash('success', '가입이 완료되었습니다. 로그인 해주세요.');
res.redirect('/');
});
module.exports = router;