@divine-lab/request 1.0.3 → 1.0.4
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.
|
@@ -27,7 +27,7 @@ logger_1.default.raw(`${(0, colors_1.colorize)("blue", "[API]")} - API logging i
|
|
|
27
27
|
function errorResponse(res, error, { title, detail, type, data, status } = {}) {
|
|
28
28
|
const errorDef = BackendErrors_1.SERVER_ERRORS[error];
|
|
29
29
|
if (API_LOG)
|
|
30
|
-
logger_1.default.raw(`${new Date().toISOString()} ${(0, colors_1.colorize)("red", "[API]")} - ${(0, colors_1.colorize)("red", (status || errorDef.status))} - ${res.request.url} : ${(0, colors_1.colorize)("gray", `${title || errorDef.title} - ${detail || errorDef.detail}`)}`);
|
|
30
|
+
logger_1.default.raw(`${new Date().toISOString()} ${(0, colors_1.colorize)("red", "[API]")} - ${(0, colors_1.colorize)("gray", res.request.ip)} - ${(0, colors_1.colorize)("red", (status || errorDef.status))} - ${res.request.url} : ${(0, colors_1.colorize)("gray", `${title || errorDef.title} - ${detail || errorDef.detail}`)}`);
|
|
31
31
|
res.code(status || errorDef.status).send({
|
|
32
32
|
status: status || errorDef.status,
|
|
33
33
|
instance: res.request.url,
|
|
@@ -51,7 +51,7 @@ function errorResponse(res, error, { title, detail, type, data, status } = {}) {
|
|
|
51
51
|
*/
|
|
52
52
|
function successResponse(res, status = 200, { title = "Success", detail = "Success", data = null } = { title: "Success", detail: "Success", data: null }) {
|
|
53
53
|
if (API_LOG)
|
|
54
|
-
logger_1.default.raw(`${new Date().toISOString()} ${(0, colors_1.colorize)("green", "[API]")} - ${(0, colors_1.colorize)("green", status)} - ${res.request.url} : ${(0, colors_1.colorize)("gray", title)}`);
|
|
54
|
+
logger_1.default.raw(`${new Date().toISOString()} ${(0, colors_1.colorize)("green", "[API]")} - ${(0, colors_1.colorize)("gray", res.request.ip)} - ${(0, colors_1.colorize)("green", status)} - ${res.request.url} : ${(0, colors_1.colorize)("gray", title)}`);
|
|
55
55
|
res.code(status).send({
|
|
56
56
|
success: true,
|
|
57
57
|
title,
|