-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmessage.js
More file actions
46 lines (43 loc) · 1021 Bytes
/
message.js
File metadata and controls
46 lines (43 loc) · 1021 Bytes
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
const message = [
'Success', // 0 - 200
'Created', // 1 - 201
'No content', // 2 - 204
'Deleted', // 3 - 204
'Bad request. invalid parameter', // 4 - 400
'Bad request. please check \'page\' query', // 5 - 400
'Bad request. \'sub\' must write \'main\' together', // 6 - 400
'Unauthorized. Please login', // 7 - 401
'No user. Please check your account.', // 8 - 403
'not found', // 9 - 404
'Conflict. Already exists', // 10 - 409
'Internal server error', // 11 - 500
'Service unavailable', // 12 - 503
'Bad request. invalid body', // 13 - 400
'Not connet to redis' // 14 - 500
];
const code = [
200, // 0
201, // 1
204, // 2
204, // 3
400, // 4
400, // 5
400, // 6
401, // 7
403, // 8
404, // 9
409, // 10
500, // 11
503, // 12
400, // 13
500 //14
];
exports.code = function (num) {
return code[num];
};
exports.json = function (num, err) {
const json = { code: code[num], message: message[num] };
if (num == 1)
json.err = err;
return json;
};