elseware-nodejs 1.8.5 → 1.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +19 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +19 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -56,26 +56,37 @@ var APIResponse = class _APIResponse {
|
|
|
56
56
|
if (statusCode === 204) {
|
|
57
57
|
return res.status(204).send();
|
|
58
58
|
}
|
|
59
|
-
const body = {
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
const body = {
|
|
60
|
+
success,
|
|
61
|
+
message,
|
|
62
|
+
...data !== void 0 && { data },
|
|
63
|
+
...meta !== void 0 && { meta }
|
|
64
|
+
};
|
|
62
65
|
return res.status(statusCode).json(body);
|
|
63
66
|
}
|
|
64
|
-
static ok(res, data, message, meta) {
|
|
67
|
+
static ok(res, data, message = "Success", meta) {
|
|
65
68
|
return _APIResponse.send(res, { statusCode: 200, data, message, meta });
|
|
66
69
|
}
|
|
67
|
-
static created(res, data, message) {
|
|
70
|
+
static created(res, data, message = "Resource created successfully") {
|
|
68
71
|
return _APIResponse.send(res, { statusCode: 201, data, message });
|
|
69
72
|
}
|
|
70
73
|
static noContent(res) {
|
|
71
74
|
return _APIResponse.send(res, { statusCode: 204 });
|
|
72
75
|
}
|
|
73
|
-
|
|
74
|
-
static error(res, message, statusCode = 500) {
|
|
76
|
+
static error(res, message = "Internal Server Error", statusCode = 500, meta) {
|
|
75
77
|
return _APIResponse.send(res, {
|
|
76
78
|
success: false,
|
|
77
79
|
statusCode,
|
|
78
|
-
message
|
|
80
|
+
message,
|
|
81
|
+
meta
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
static paginated(res, data, options, message = "Data fetched successfully") {
|
|
85
|
+
return _APIResponse.ok(res, data, message, {
|
|
86
|
+
total: options.total,
|
|
87
|
+
page: options.page,
|
|
88
|
+
limit: options.limit,
|
|
89
|
+
totalPages: Math.ceil(options.total / options.limit)
|
|
79
90
|
});
|
|
80
91
|
}
|
|
81
92
|
};
|