@aeriajs/http 0.0.186 → 0.0.188

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/cors.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import type { GenericRequest, GenericResponse } from '@aeriajs/types';
2
- export declare const cors: (req: GenericRequest, res: GenericResponse) => null | undefined;
1
+ import type { GenericRequest, GenericResponse, CorsConfig } from '@aeriajs/types';
2
+ export declare const cors: (req: GenericRequest, res: GenericResponse, config: CorsConfig) => null | undefined;
package/dist/cors.js CHANGED
@@ -1,23 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.cors = void 0;
4
- const cors = (req, res) => {
5
- const allowedHeaders = [
6
- 'Accept',
7
- 'Accept-Version',
8
- 'Authorization',
9
- 'Content-Length',
10
- 'Content-MD5',
11
- 'Content-Type',
12
- 'Date',
13
- 'X-Api-Version',
14
- 'X-Stream-Request',
15
- ];
4
+ const cors = (req, res, config) => {
5
+ const { allowOrigin = [], allowMethods = [], allowHeaders = [], maxAge, } = config;
16
6
  const headers = {
17
- 'Access-Control-Allow-Origin': '*',
18
- 'Access-Control-Allow-Methods': '*',
19
- 'Access-Control-Allow-Headers': allowedHeaders.join(','),
20
- 'Access-Control-Max-Age': '2592000',
7
+ 'Access-Control-Allow-Origin': allowOrigin.join(','),
8
+ 'Access-Control-Allow-Methods': allowMethods.join(','),
9
+ 'Access-Control-Allow-Headers': allowHeaders.join(','),
10
+ 'Access-Control-Max-Age': maxAge,
21
11
  };
22
12
  if (req.method === 'OPTIONS') {
23
13
  res.writeHead(204, headers);
package/dist/cors.mjs CHANGED
@@ -1,21 +1,16 @@
1
1
  "use strict";
2
- export const cors = (req, res) => {
3
- const allowedHeaders = [
4
- "Accept",
5
- "Accept-Version",
6
- "Authorization",
7
- "Content-Length",
8
- "Content-MD5",
9
- "Content-Type",
10
- "Date",
11
- "X-Api-Version",
12
- "X-Stream-Request"
13
- ];
2
+ export const cors = (req, res, config) => {
3
+ const {
4
+ allowOrigin = [],
5
+ allowMethods = [],
6
+ allowHeaders = [],
7
+ maxAge
8
+ } = config;
14
9
  const headers = {
15
- "Access-Control-Allow-Origin": "*",
16
- "Access-Control-Allow-Methods": "*",
17
- "Access-Control-Allow-Headers": allowedHeaders.join(","),
18
- "Access-Control-Max-Age": "2592000"
10
+ "Access-Control-Allow-Origin": allowOrigin.join(","),
11
+ "Access-Control-Allow-Methods": allowMethods.join(","),
12
+ "Access-Control-Allow-Headers": allowHeaders.join(","),
13
+ "Access-Control-Max-Age": maxAge
19
14
  };
20
15
  if (req.method === "OPTIONS") {
21
16
  res.writeHead(204, headers);
package/dist/log.js CHANGED
@@ -15,7 +15,7 @@ const logResponse = (response) => {
15
15
  ? types_1.METHOD_COLORS[method]
16
16
  : 'white';
17
17
  const now = new Date();
18
- let line = `[${(0, node_util_1.styleText)([statusColor], statusCode.toString())}] `;
18
+ let line = `[${(0, node_util_1.styleText)(statusColor, statusCode.toString())}] `;
19
19
  line += `[${now.toLocaleString()}] `;
20
20
  line += (0, node_util_1.styleText)([
21
21
  'bold',
package/dist/log.mjs CHANGED
@@ -9,7 +9,7 @@ export const logResponse = (response) => {
9
9
  const statusColor = statusCode >= 400 && statusCode <= 599 ? "red" : "white";
10
10
  const methodColor = method in METHOD_COLORS ? METHOD_COLORS[method] : "white";
11
11
  const now = /* @__PURE__ */ new Date();
12
- let line = `[${styleText([statusColor], statusCode.toString())}] `;
12
+ let line = `[${styleText(statusColor, statusCode.toString())}] `;
13
13
  line += `[${now.toLocaleString()}] `;
14
14
  line += styleText([
15
15
  "bold",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/http",
3
- "version": "0.0.186",
3
+ "version": "0.0.188",
4
4
  "description": "## Installation",
5
5
  "main": "dist/index.js",
6
6
  "aeriaMain": "tests/fixtures/aeriaMain.js",
@@ -30,10 +30,10 @@
30
30
  "mongodb": "^6.17.0"
31
31
  },
32
32
  "peerDependencies": {
33
- "@aeriajs/common": "^0.0.152",
34
- "@aeriajs/entrypoint": "^0.0.158",
35
- "@aeriajs/types": "^0.0.130",
36
- "@aeriajs/validation": "^0.0.171",
33
+ "@aeriajs/common": "^0.0.154",
34
+ "@aeriajs/entrypoint": "^0.0.160",
35
+ "@aeriajs/types": "^0.0.132",
36
+ "@aeriajs/validation": "^0.0.173",
37
37
  "mongodb": "^6.17.0"
38
38
  },
39
39
  "scripts": {