@aeriajs/http 0.0.161 → 0.0.162

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
@@ -1,4 +1,4 @@
1
1
  export * from './cors.js';
2
- export * from './options.js';
2
+ export * from './log.js';
3
3
  export * from './routing.js';
4
4
  export * from './payload.js';
package/dist/index.js CHANGED
@@ -15,6 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./cors.js"), exports);
18
- __exportStar(require("./options.js"), exports);
18
+ __exportStar(require("./log.js"), exports);
19
19
  __exportStar(require("./routing.js"), exports);
20
20
  __exportStar(require("./payload.js"), exports);
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  export * from "./cors.mjs";
3
- export * from "./options.mjs";
3
+ export * from "./log.mjs";
4
4
  export * from "./routing.mjs";
5
5
  export * from "./payload.mjs";
package/dist/log.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import type { GenericResponse } from '@aeriajs/types';
2
+ export declare const logResponse: (response: GenericResponse) => void;
package/dist/log.js ADDED
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logResponse = void 0;
4
+ const common_1 = require("@aeriajs/common");
5
+ const logResponse = (response) => {
6
+ const { statusCode, req: { method, url } } = response;
7
+ if (!method) {
8
+ return;
9
+ }
10
+ 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;
16
+ const now = new Date();
17
+ let line = `[${(0, common_1.escape)(statusColor, statusCode.toString())}] `;
18
+ line += `[${now.toLocaleString()}] `;
19
+ line += (0, common_1.escape)([
20
+ '[1m',
21
+ methodColor,
22
+ ], method) + ' ';
23
+ line += url;
24
+ console.log(line);
25
+ };
26
+ exports.logResponse = logResponse;
package/dist/log.mjs ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ import { escape, AnsiColor, METHOD_COLORS } from "@aeriajs/common";
3
+ export const logResponse = (response) => {
4
+ const { statusCode, req: { method, url } } = response;
5
+ if (!method) {
6
+ return;
7
+ }
8
+ const statusColor = statusCode >= 400 && statusCode <= 599 ? AnsiColor.Red : AnsiColor.White;
9
+ const methodColor = method in METHOD_COLORS ? METHOD_COLORS[method] : AnsiColor.White;
10
+ const now = /* @__PURE__ */ new Date();
11
+ let line = `[${escape(statusColor, statusCode.toString())}] `;
12
+ line += `[${now.toLocaleString()}] `;
13
+ line += escape([
14
+ "[1m",
15
+ methodColor
16
+ ], method) + " ";
17
+ line += url;
18
+ console.log(line);
19
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/http",
3
- "version": "0.0.161",
3
+ "version": "0.0.162",
4
4
  "description": "## Installation",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -28,10 +28,10 @@
28
28
  "@aeriajs/validation": "link:../validation"
29
29
  },
30
30
  "peerDependencies": {
31
- "@aeriajs/common": "^0.0.133",
32
- "@aeriajs/entrypoint": "^0.0.137",
33
- "@aeriajs/types": "^0.0.115",
34
- "@aeriajs/validation": "^0.0.149"
31
+ "@aeriajs/common": "^0.0.134",
32
+ "@aeriajs/entrypoint": "^0.0.138",
33
+ "@aeriajs/types": "^0.0.116",
34
+ "@aeriajs/validation": "^0.0.150"
35
35
  },
36
36
  "scripts": {
37
37
  "test": "vitest run",
package/dist/options.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export type ServerOptions = {
2
- host?: string;
3
- port?: number;
4
- };
5
- export declare const defineServerOptions: <TServerOptions extends ServerOptions>(options: TServerOptions) => TServerOptions;
package/dist/options.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defineServerOptions = void 0;
4
- const defineServerOptions = (options) => {
5
- return options;
6
- };
7
- exports.defineServerOptions = defineServerOptions;
package/dist/options.mjs DELETED
@@ -1,4 +0,0 @@
1
- "use strict";
2
- export const defineServerOptions = (options) => {
3
- return options;
4
- };