-
Notifications
You must be signed in to change notification settings - Fork 1
/
routes.js
126 lines (81 loc) · 2.7 KB
/
routes.js
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
var authentication = require('./routes/users/authentication'),
user = {
login : require('./routes/users/login'),
register : require('./routes/users/register'),
logout : require('./routes/users/logout'),
edit : require('./routes/users/edit')
},
article = {
list : require('./routes/articles/list'),
add : require('./routes/articles/add'),
edit : require('./routes/articles/edit'),
info : require('./routes/articles/info'),
del : require('./routes/articles/del'),
upload : require('./routes/articles/upload')
};
//comment = {
// list : require('./routes/comments/list'),
// add : require('./routes/comments/add'),
// del : require('./routes/comments/del'),
// edit : require('./routes/comments/edit')
//};
module.exports = function(app){
// authentication
// 路径中包含 /edit , /add , /del 的请求,先验证
app.all(/edit|add|del|upload/,function(req,res,next){
if(req.path == '/comment/add'){
next();
return;
}
authentication(req,res,next);
})
//app.get('/bbs',bbs);
// home
app.get('/',article.list);
app.get('/index',article.list);
// 文章
// /article?start=0
// /article?start=100&type=时尚
// /article?start=100&user=tiger
// /article/add
// /article/edit/gid
app.get('/article',article.list);
app.get('/article/',article.list);
app.get('/article/add',article.add.get);
app.post('/article/add',article.add.add);
app.get('/article/edit/:gid',article.edit.get);
app.post('/article/edit/',article.edit.update);
app.get('/article/del/:gid',article.del);
app.post('/article/upload',article.upload);
app.get('/article/list/:tid/',article.list); // tid type的id
app.get('/article/list/:tid/:gid',article.info); // cid 文章的id
// 评论 仅提供 ajax接口
//app.get('/comment/add',comment.add);
//app.get('/comment/del',comment.del);
//app.get('/comment/edit',comment.edit);
//app.get('/comment/list',comment.list);
// 修改用户信息
//app.param( 'type' , /\w+/ );
//app.get('/users/edit',user.edit.get);
//app.get('/users/edit/:type',user.edit.get);
//app.post('/users/edit/name',user.edit.name);
//app.post('/users/edit/password',user.edit.pwd);
//app.post('/users/edit/icon',user.edit.icon);
// 登录
app.get('/login',user.login.get);
app.post('/login',user.login.post);
// 注册 验证
app.get('/register',user.register.get);
app.post('/register',user.register.post);
app.get('/vorify',user.register.vorify);
// 登出
app.get('/logout',user.logout);
// 获取上传的文件地址。post,get,put,delete地址。
// 用于上传图片,头像
//app.get('/geturl',upload)
// search
// 404
app.get('*',function(req,res){
res.send(404)
})
}