4
4
const router = require ( 'express' ) . Router ;
5
5
const each = require ( 'async-each-map' ) ;
6
6
7
- const app = router ( ) ;
7
+ const route = router ( ) ;
8
8
const ApiUser = require ( '../app/model' ) . ApiUser ;
9
9
10
10
const filters = require ( './filters' ) ;
@@ -16,24 +16,24 @@ if (module.parent.exports.nunjucks) {
16
16
} ) ;
17
17
}
18
18
19
- app . use ( '/' , ( req , res , next ) => {
19
+ route . use ( '/' , ( req , res , next ) => {
20
20
if ( ! req . session . auth . isAdmin ) {
21
21
return res . redirect ( '/' ) ;
22
22
}
23
23
24
24
return next ( ) ;
25
25
} ) ;
26
26
27
- app . get ( '/' , ( req , res ) => res . redirect ( '/admin/users' ) ) ;
27
+ route . get ( '/' , ( req , res ) => res . redirect ( '/admin/users' ) ) ;
28
28
29
- app . get ( '/users' , ( req , res , next ) => {
29
+ route . get ( '/users' , ( req , res , next ) => {
30
30
ApiUser . find ( ) . limit ( 100 ) . sort ( { updated : - 1 } ) . exec ( ( err , apps ) => {
31
31
if ( err ) { return next ( err ) ; }
32
32
return res . render ( 'admin/users.html' , { req, apps } ) ;
33
33
} ) ;
34
34
} ) ;
35
35
36
- app . get ( '/limits' , ( req , res , next ) => {
36
+ route . get ( '/limits' , ( req , res , next ) => {
37
37
const error = req . session . message ;
38
38
delete req . session . message ;
39
39
@@ -54,7 +54,7 @@ app.get('/limits', (req, res, next) => {
54
54
} ) ;
55
55
} ) ;
56
56
57
- app . post ( '/limits/:userId/:appId' , ( req , res , next ) => {
57
+ route . post ( '/limits/:userId/:appId' , ( req , res , next ) => {
58
58
ApiUser . findOne ( { _id : req . params . userId } , ( err , user ) => {
59
59
if ( err ) { return next ( err ) ; }
60
60
@@ -114,7 +114,7 @@ app.post('/limits/:userId/:appId', (req, res, next) => {
114
114
} ) ;
115
115
} ) ;
116
116
117
- app . get ( '/requests' , ( req , res , next ) => {
117
+ route . get ( '/requests' , ( req , res , next ) => {
118
118
const error = req . session . message ;
119
119
delete req . session . message ;
120
120
@@ -133,7 +133,7 @@ app.get('/requests', (req, res, next) => {
133
133
} ) ;
134
134
} ) ;
135
135
136
- app . post ( '/requests/:userId/:appId' , ( req , res , next ) => {
136
+ route . post ( '/requests/:userId/:appId' , ( req , res , next ) => {
137
137
ApiUser . findOne ( { _id : req . params . userId } , ( err , user ) => {
138
138
if ( err ) { return next ( err ) ; }
139
139
@@ -186,14 +186,14 @@ app.post('/requests/:userId/:appId', (req, res, next) => {
186
186
} ) ;
187
187
} ) ;
188
188
189
- app . get ( '/email' , ( req , res ) => {
189
+ route . get ( '/email' , ( req , res ) => {
190
190
const error = req . session . message ;
191
191
192
192
delete req . session . message ;
193
193
res . render ( 'admin/email.html' , { req } ) ;
194
194
} ) ;
195
195
196
- app . post ( '/email' , ( req , res , next ) => {
196
+ route . post ( '/email' , ( req , res , next ) => {
197
197
const from = req . body . from ;
198
198
const subject = req . body . subject ;
199
199
const template = req . body . content ;
@@ -303,6 +303,6 @@ app.post('/email', (req, res, next) => {
303
303
}
304
304
} ) ;
305
305
306
- app . get ( '*' , ( req , res ) => res . redirect ( '/admin' ) ) ;
306
+ route . get ( '*' , ( req , res ) => res . redirect ( '/admin' ) ) ;
307
307
308
- module . exports = app ;
308
+ module . exports = route ;
0 commit comments