@arkstack/driver-express 0.17.15 → 0.17.17

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.d.ts CHANGED
@@ -5,7 +5,6 @@ import { ArkstackKitDriver, ArkstackRouteListOptions, PromiseOrValue } from "@ar
5
5
  import { Router as Router$2 } from "clear-router/express";
6
6
  import { Route } from "clear-router";
7
7
  import { Handler as Handler$1, HttpContext, Middleware } from "clear-router/types/express";
8
-
9
8
  //#region src/error-handler.d.ts
10
9
  declare const defaultErrorHandler: ErrorRequestHandler;
11
10
  //#endregion
@@ -1,7 +1,6 @@
1
1
  import { Handler, NextFunction, Request, Response } from "express";
2
2
  import multer from "multer";
3
3
  import { ValueDeterminingMiddleware } from "express-rate-limit";
4
-
5
4
  //#region src/middlewares/auth.d.ts
6
5
  declare const auth: Handler;
7
6
  declare class AuthMiddleware {
@@ -59,9 +58,7 @@ declare const limiter: (requests?: number | ValueDeterminingMiddleware<number>,
59
58
  * @param config.allowInProduction If true, the logger will also log requests in production environment. Default is false.
60
59
  * @returns
61
60
  */
62
- declare const requestLogger: ({
63
- allowInProduction
64
- }?: {
61
+ declare const requestLogger: ({ allowInProduction }?: {
65
62
  allowInProduction?: boolean;
66
63
  }) => (req: Request, res: Response, next: NextFunction) => Promise<void>;
67
64
  declare class RequestLoggerMiddleware {
@@ -170,16 +170,19 @@ const colors = {
170
170
  */
171
171
  const requestLogger = ({ allowInProduction = false } = {}) => async (req, res, next) => {
172
172
  const VERBOSE = process.env.VERBOSITY != "0";
173
- if (nodeEnv() === "prod" && !allowInProduction || !VERBOSE) return next();
174
- const start = Date.now();
175
- const status = res.statusCode || 200;
176
- const duration = Date.now() - start;
177
- Logger.log([
178
- [`[${req.method}]`, colors[req.method] || "white"],
179
- [req.url, "cyan"],
180
- [status.toString(), status >= 500 ? "red" : status >= 400 ? "yellow" : "green"],
181
- [`- ${duration}ms`, "dim"]
182
- ], " ");
173
+ const startedAt = performance.now();
174
+ res.once("finish", () => {
175
+ if (nodeEnv() === "prod" && !allowInProduction || !VERBOSE) return;
176
+ if (process.env.NODE_ENV === "test" || process.env.VITEST) return;
177
+ const status = res.statusCode || 200;
178
+ const duration = Math.round((performance.now() - startedAt) * 100) / 100;
179
+ Logger.log([
180
+ [`[${req.method}]`, colors[req.method] || "white"],
181
+ [req.url, "cyan"],
182
+ [status.toString(), status >= 500 ? "red" : status >= 400 ? "yellow" : "green"],
183
+ [`- ${duration}ms`, "dim"]
184
+ ], " ");
185
+ });
183
186
  next();
184
187
  };
185
188
  var RequestLoggerMiddleware = class {
package/dist/types.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { Handler } from "express";
2
2
  import { ArkstackMiddlewareConfig } from "@arkstack/contract";
3
3
  import { ClassMiddleware } from "clear-router/types/basic";
4
-
5
4
  //#region src/types.d.ts
6
5
  type Middleware = Handler | ClassMiddleware<Handler>;
7
6
  type MiddlewareConfig = ArkstackMiddlewareConfig<Middleware>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkstack/driver-express",
3
- "version": "0.17.15",
3
+ "version": "0.17.17",
4
4
  "type": "module",
5
5
  "description": "Express driver for Arkstack, providing Express-based runtime integration for the framework.",
6
6
  "homepage": "https://arkstack.toneflix.net",
@@ -38,20 +38,20 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@ngrok/ngrok": "^1.7.0",
41
- "@resora/plugin-clear-router": "^1.0.70",
42
- "clear-router": "^2.9.2",
41
+ "@resora/plugin-clear-router": "^1.0.72",
42
+ "clear-router": "^2.9.3",
43
43
  "express-rate-limit": "^8.4.1",
44
44
  "multer": "^2.1.1",
45
- "resora": "^1.3.32",
46
- "@arkstack/contract": "^0.17.15",
47
- "@arkstack/http": "^0.17.15"
45
+ "resora": "^1.3.34",
46
+ "@arkstack/contract": "^0.17.17",
47
+ "@arkstack/http": "^0.17.17"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "express": "^5.2.1",
51
- "@arkstack/auth": "^0.17.15",
52
- "@arkstack/common": "^0.17.15",
53
- "@arkstack/inertia": "^0.17.15",
54
- "@arkstack/foundry": "^0.17.15"
51
+ "@arkstack/common": "^0.17.17",
52
+ "@arkstack/auth": "^0.17.17",
53
+ "@arkstack/foundry": "^0.17.17",
54
+ "@arkstack/inertia": "^0.17.17"
55
55
  },
56
56
  "peerDependenciesMeta": {
57
57
  "@arkstack/auth": {