-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter.mjs
45 lines (33 loc) · 1.23 KB
/
router.mjs
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
import Router from 'express';
const router = Router();
import createResponse from './helper/createResponse.mjs';
router.use( createResponse )
import authorizeRequest from './helper/authorizeRequest.mjs';
import user_login from './routes/users/login.mjs';
router.post('/user/login', user_login);
import ticket_list from './routes/tickets/list.mjs';
router.get( '/tickets/list', authorizeRequest, ticket_list );
import ticket_messages from './routes/tickets/messages.mjs';
router.get( '/tickets/message/:id', authorizeRequest, ticket_messages );
import ticket_create from './routes/tickets/create.mjs';
router.post( '/tickets', authorizeRequest, ticket_create );
import ticket_message from './routes/tickets/message.mjs';
router.post( '/tickets/message/:id', authorizeRequest, ticket_message );
import ticket_status from './routes/tickets/status.mjs';
router.patch( '/tickets/admin/status/:id', authorizeRequest, ticket_status );
router.use(function(req,res){
res.status(404).json({
code: 404,
message: 'Not found',
data: {}
})
})
router.use(function(err,req,res,text){
console.log(err);
res.status(err.status || 500).json({
code: 500,
message: 'Internal server error',
data: {}
});
})
export default router;