plutin 1.7.2 → 1.7.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.
- package/dist/index.cjs +9 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -9
- package/dist/index.d.ts +3 -9
- package/dist/index.mjs +9 -38
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -995,23 +995,6 @@ __name(getTakeAndSkip, "getTakeAndSkip");
|
|
|
995
995
|
import cors from "cors";
|
|
996
996
|
import express from "express";
|
|
997
997
|
|
|
998
|
-
// src/infra/logger/index.ts
|
|
999
|
-
import { bold } from "kleur";
|
|
1000
|
-
var logger = {
|
|
1001
|
-
info: (...args) => {
|
|
1002
|
-
console.info(bold().blue(`[INFO] `), ...args);
|
|
1003
|
-
},
|
|
1004
|
-
log: (...args) => {
|
|
1005
|
-
console.log(bold().grey(`[LOG] `), ...args);
|
|
1006
|
-
},
|
|
1007
|
-
warn: (...args) => {
|
|
1008
|
-
console.warn(bold().yellow(`[WARN] `), ...args);
|
|
1009
|
-
},
|
|
1010
|
-
error: (...args) => {
|
|
1011
|
-
console.error(bold().red(`[ERROR] `), ...args);
|
|
1012
|
-
}
|
|
1013
|
-
};
|
|
1014
|
-
|
|
1015
998
|
// src/infra/adapters/http/response-error-code.ts
|
|
1016
999
|
var ErrorResponseCode = /* @__PURE__ */ function(ErrorResponseCode2) {
|
|
1017
1000
|
ErrorResponseCode2["NO_CONTENT_BODY"] = "B001";
|
|
@@ -1038,10 +1021,12 @@ var ExpressAdapter = class {
|
|
|
1038
1021
|
__name(this, "ExpressAdapter");
|
|
1039
1022
|
}
|
|
1040
1023
|
env;
|
|
1024
|
+
logger;
|
|
1041
1025
|
instance;
|
|
1042
1026
|
server;
|
|
1043
|
-
constructor(env) {
|
|
1027
|
+
constructor(env, logger) {
|
|
1044
1028
|
this.env = env;
|
|
1029
|
+
this.logger = logger;
|
|
1045
1030
|
this.instance = express();
|
|
1046
1031
|
this.instance.use(cors());
|
|
1047
1032
|
this.instance.use(express.json({
|
|
@@ -1088,7 +1073,7 @@ var ExpressAdapter = class {
|
|
|
1088
1073
|
async startServer(port) {
|
|
1089
1074
|
return new Promise((resolve) => {
|
|
1090
1075
|
this.server = this.instance.listen(port, () => {
|
|
1091
|
-
logger.
|
|
1076
|
+
this.logger.info(`Server is running on PORT ${port}`);
|
|
1092
1077
|
resolve();
|
|
1093
1078
|
});
|
|
1094
1079
|
});
|
|
@@ -1119,28 +1104,15 @@ var FastifyAdapter = class {
|
|
|
1119
1104
|
env;
|
|
1120
1105
|
logger;
|
|
1121
1106
|
instance;
|
|
1122
|
-
constructor(env,
|
|
1107
|
+
constructor(env, logger) {
|
|
1123
1108
|
this.env = env;
|
|
1124
|
-
this.logger =
|
|
1109
|
+
this.logger = logger;
|
|
1125
1110
|
this.instance = fastify({
|
|
1126
1111
|
bodyLimit: 10 * 1024 * 1024,
|
|
1127
1112
|
querystringParser: (str) => qs.parse(str),
|
|
1128
|
-
logger: false
|
|
1129
|
-
disableRequestLogging: true
|
|
1113
|
+
loggerInstance: env.ENVIRONMENT !== "test" ? logger : false
|
|
1130
1114
|
});
|
|
1131
1115
|
this.instance.register(cors2);
|
|
1132
|
-
if (env.NODE_ENV !== "test") {
|
|
1133
|
-
this.instance.addHook("onRequest", async (request) => {
|
|
1134
|
-
logger2.info({
|
|
1135
|
-
req: request
|
|
1136
|
-
});
|
|
1137
|
-
});
|
|
1138
|
-
this.instance.addHook("onResponse", async (_, reply) => {
|
|
1139
|
-
logger2.info({
|
|
1140
|
-
res: reply
|
|
1141
|
-
});
|
|
1142
|
-
});
|
|
1143
|
-
}
|
|
1144
1116
|
}
|
|
1145
1117
|
registerRoute(controllerClass) {
|
|
1146
1118
|
const { metadata } = validateControllerMetadata(controllerClass);
|
|
@@ -1179,7 +1151,7 @@ var FastifyAdapter = class {
|
|
|
1179
1151
|
port
|
|
1180
1152
|
});
|
|
1181
1153
|
if (this.env.NODE_ENV !== "test") {
|
|
1182
|
-
logger.
|
|
1154
|
+
this.logger.info(`Server is running on PORT ${port}`);
|
|
1183
1155
|
}
|
|
1184
1156
|
}
|
|
1185
1157
|
async closeServer() {
|
|
@@ -1241,7 +1213,7 @@ var NotificationErrorInMemory = class {
|
|
|
1241
1213
|
}
|
|
1242
1214
|
errors = [];
|
|
1243
1215
|
async notify(error, context) {
|
|
1244
|
-
|
|
1216
|
+
console.error(error);
|
|
1245
1217
|
this.errors.push({
|
|
1246
1218
|
error: error.message,
|
|
1247
1219
|
context
|
|
@@ -1771,7 +1743,6 @@ export {
|
|
|
1771
1743
|
WinstonOtelFastify,
|
|
1772
1744
|
baseEnvSchema,
|
|
1773
1745
|
getTakeAndSkip,
|
|
1774
|
-
logger,
|
|
1775
1746
|
zodValidator
|
|
1776
1747
|
};
|
|
1777
1748
|
//# sourceMappingURL=index.mjs.map
|