@aeriajs/http 0.0.181 → 0.0.183

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/log.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import type { GenericResponse } from '@aeriajs/types';
1
+ import { type GenericResponse } from '@aeriajs/types';
2
2
  export declare const logResponse: (response: GenericResponse) => void;
package/dist/log.js CHANGED
@@ -1,23 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.logResponse = void 0;
4
- const common_1 = require("@aeriajs/common");
4
+ const types_1 = require("@aeriajs/types");
5
+ const node_util_1 = require("node:util");
5
6
  const logResponse = (response) => {
6
7
  const { statusCode, req: { method, url } } = response;
7
8
  if (!method) {
8
9
  return;
9
10
  }
10
11
  const statusColor = statusCode >= 400 && statusCode <= 599
11
- ? common_1.AnsiColor.Red
12
- : common_1.AnsiColor.White;
13
- const methodColor = method in common_1.METHOD_COLORS
14
- ? common_1.METHOD_COLORS[method]
15
- : common_1.AnsiColor.White;
12
+ ? 'red'
13
+ : 'white';
14
+ const methodColor = method in types_1.METHOD_COLORS
15
+ ? types_1.METHOD_COLORS[method]
16
+ : 'white';
16
17
  const now = new Date();
17
- let line = `[${(0, common_1.escape)(statusColor, statusCode.toString())}] `;
18
+ let line = `[${(0, node_util_1.styleText)([statusColor], statusCode.toString())}] `;
18
19
  line += `[${now.toLocaleString()}] `;
19
- line += (0, common_1.escape)([
20
- '[1m',
20
+ line += (0, node_util_1.styleText)([
21
+ 'bold',
21
22
  methodColor,
22
23
  ], method) + ' ';
23
24
  line += url;
package/dist/log.mjs CHANGED
@@ -1,17 +1,18 @@
1
1
  "use strict";
2
- import { escape, AnsiColor, METHOD_COLORS } from "@aeriajs/common";
2
+ import { METHOD_COLORS } from "@aeriajs/types";
3
+ import { styleText } from "node:util";
3
4
  export const logResponse = (response) => {
4
5
  const { statusCode, req: { method, url } } = response;
5
6
  if (!method) {
6
7
  return;
7
8
  }
8
- const statusColor = statusCode >= 400 && statusCode <= 599 ? AnsiColor.Red : AnsiColor.White;
9
- const methodColor = method in METHOD_COLORS ? METHOD_COLORS[method] : AnsiColor.White;
9
+ const statusColor = statusCode >= 400 && statusCode <= 599 ? "red" : "white";
10
+ const methodColor = method in METHOD_COLORS ? METHOD_COLORS[method] : "white";
10
11
  const now = /* @__PURE__ */ new Date();
11
- let line = `[${escape(statusColor, statusCode.toString())}] `;
12
+ let line = `[${styleText([statusColor], statusCode.toString())}] `;
12
13
  line += `[${now.toLocaleString()}] `;
13
- line += escape([
14
- "[1m",
14
+ line += styleText([
15
+ "bold",
15
16
  methodColor
16
17
  ], method) + " ";
17
18
  line += url;
package/dist/routing.d.ts CHANGED
@@ -8,7 +8,7 @@ export type RoutesMeta = Record<RouteUri, Partial<Record<RequestMethod, Contract
8
8
  export type RouteGroupOptions = {
9
9
  base?: RouteUri;
10
10
  };
11
- type TypedContext<TContractWithRoles extends ContractWithRoles> = Omit<RouteContext<TContractWithRoles['roles']>, 'request'> & {
11
+ type NarrowedContext<TContractWithRoles extends ContractWithRoles> = Omit<RouteContext<TContractWithRoles['roles']>, 'request'> & {
12
12
  request: Omit<RouteContext['request'], 'payload' | 'query'> & {
13
13
  payload: TContractWithRoles extends {
14
14
  payload: infer Payload;
@@ -20,7 +20,7 @@ type TypedContext<TContractWithRoles extends ContractWithRoles> = Omit<RouteCont
20
20
  };
21
21
  export type ProxiedRouter<TRouter> = TRouter & Record<typeof REQUEST_METHODS[number], <const TContractWithRoles extends ContractWithRoles, TCallback extends (TContractWithRoles extends {
22
22
  response: infer Response;
23
- } ? InferProperties<Response> extends infer InferredResponse ? InferredResponse | Promise<InferredResponse> : never : unknown) extends infer Response ? (context: TypedContext<TContractWithRoles>) => Response : never>(exp: RouteUri, cb: TCallback, contract?: TContractWithRoles) => ReturnType<typeof registerRoute>>;
23
+ } ? InferProperties<Response> extends infer InferredResponse ? InferredResponse | Promise<InferredResponse> : never : unknown) extends infer Response ? (context: NarrowedContext<TContractWithRoles>) => Response : never>(exp: RouteUri, cb: TCallback, contract?: TContractWithRoles) => ReturnType<typeof registerRoute>>;
24
24
  export declare const matches: <TRequest extends GenericRequest>(req: TRequest, method: RequestMethod | RequestMethod[] | null, exp: string | RegExp, options?: RouterOptions, config?: ApiConfig) => {
25
25
  fragments: string[];
26
26
  } | undefined;
@@ -29,7 +29,7 @@ export declare const wrapRouteExecution: (response: GenericResponse, cb: () => u
29
29
  export declare const createRouter: (options?: Partial<RouterOptions>) => ProxiedRouter<{
30
30
  route: <const TContractWithRoles extends ContractWithRoles, TCallback extends (TContractWithRoles extends {
31
31
  response: infer Response;
32
- } ? InferProperties<Response> : unknown) extends infer Response ? (context: TypedContext<TContractWithRoles>) => Response : never>(method: RequestMethod | RequestMethod[], exp: RouteUri, cb: TCallback, contract?: TContractWithRoles) => void;
32
+ } ? InferProperties<Response> : unknown) extends infer Response ? (context: NarrowedContext<TContractWithRoles>) => Response : never>(method: RequestMethod | RequestMethod[], exp: RouteUri, cb: TCallback, contract?: TContractWithRoles) => void;
33
33
  routes: ((_: unknown, context: RouteContext, groupOptions?: RouteGroupOptions) => unknown)[];
34
34
  routesMeta: RoutesMeta;
35
35
  group: <TRouter extends {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/http",
3
- "version": "0.0.181",
3
+ "version": "0.0.183",
4
4
  "description": "## Installation",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -26,14 +26,14 @@
26
26
  "@aeriajs/entrypoint": "link:../entrypoint",
27
27
  "@aeriajs/types": "link:../types",
28
28
  "@aeriajs/validation": "link:../validation",
29
- "mongodb": "^6.16.0"
29
+ "mongodb": "^6.17.0"
30
30
  },
31
31
  "peerDependencies": {
32
- "@aeriajs/common": "^0.0.150",
33
- "@aeriajs/entrypoint": "^0.0.155",
34
- "@aeriajs/types": "^0.0.128",
35
- "@aeriajs/validation": "^0.0.168",
36
- "mongodb": "^6.16.0"
32
+ "@aeriajs/common": "^0.0.151",
33
+ "@aeriajs/entrypoint": "^0.0.156",
34
+ "@aeriajs/types": "^0.0.129",
35
+ "@aeriajs/validation": "^0.0.169",
36
+ "mongodb": "^6.17.0"
37
37
  },
38
38
  "scripts": {
39
39
  "test": "vitest run",