-
Notifications
You must be signed in to change notification settings - Fork 417
/
Copy pathapiResponse.js
49 lines (44 loc) · 877 Bytes
/
apiResponse.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
exports.successResponse = function (res, msg) {
var data = {
status: 1,
message: msg
};
return res.status(200).json(data);
};
exports.successResponseWithData = function (res, msg, data) {
var resData = {
status: 1,
message: msg,
data: data
};
return res.status(200).json(resData);
};
exports.ErrorResponse = function (res, msg) {
var data = {
status: 0,
message: msg,
};
return res.status(500).json(data);
};
exports.notFoundResponse = function (res, msg) {
var data = {
status: 0,
message: msg,
};
return res.status(404).json(data);
};
exports.validationErrorWithData = function (res, msg, data) {
var resData = {
status: 0,
message: msg,
data: data
};
return res.status(400).json(resData);
};
exports.unauthorizedResponse = function (res, msg) {
var data = {
status: 0,
message: msg,
};
return res.status(401).json(data);
};