@aeriajs/http 0.0.187 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/http",
3
- "version": "0.0.187",
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.153",
34
- "@aeriajs/entrypoint": "^0.0.159",
35
- "@aeriajs/types": "^0.0.131",
36
- "@aeriajs/validation": "^0.0.172",
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": {