@rdyl/node-koa-controller 0.1.2 → 0.1.3

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/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ## 0.1.2 (2025-04-07)
1
+ ## 0.1.3 (2025-04-07)
2
2
 
3
3
 
4
4
 
@@ -190,7 +190,7 @@ function useController(app, opts) {
190
190
  }
191
191
  if (logs) {
192
192
  app.use(function (ctx, next) { return __awaiter(_this, void 0, void 0, function () {
193
- var start, duration, status_1, method, statusColor, dateTime;
193
+ var start, duration, status_1, method, statusColor, dateTime, dText;
194
194
  return __generator(this, function (_a) {
195
195
  switch (_a.label) {
196
196
  case 0:
@@ -205,7 +205,7 @@ function useController(app, opts) {
205
205
  case 3:
206
206
  duration = Date.now() - start;
207
207
  status_1 = ctx.status;
208
- method = ctx.method.padEnd(7);
208
+ method = ctx.method;
209
209
  statusColor = void 0;
210
210
  if (status_1 >= 500)
211
211
  statusColor = chalk_1.default.red;
@@ -218,7 +218,14 @@ function useController(app, opts) {
218
218
  else
219
219
  statusColor = chalk_1.default.gray;
220
220
  dateTime = (0, utils_1.formatDateTime)();
221
- console.log("- [".concat(dateTime, " | ").concat(chalk_1.default.gray("".concat(duration, "ms")), "] ").concat(chalk_1.default.magenta(method)).concat(ctx.url, " ").concat(statusColor(status_1)));
221
+ dText = chalk_1.default.gray("".concat(duration, "ms"));
222
+ if (duration > 5000) {
223
+ dText = chalk_1.default.red("".concat(duration, "ms"));
224
+ }
225
+ else if (duration > 1000) {
226
+ dText = chalk_1.default.yellow("".concat(duration, "ms"));
227
+ }
228
+ console.log("- [".concat(dateTime, " | ").concat(dText, "] ").concat(chalk_1.default.magenta(method), " ").concat(ctx.url, " ").concat(statusColor(status_1)));
222
229
  return [7 /*endfinally*/];
223
230
  case 4: return [2 /*return*/];
224
231
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rdyl/node-koa-controller",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",