azurajs 2.5.2 → 2.5.4-1
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/{LoggingMiddleware-BBmUUuyX.d.ts → LoggingMiddleware-BZfecAhg.d.ts} +1 -1
- package/dist/{LoggingMiddleware-D8FkeXT4.d.cts → LoggingMiddleware-BZvXPu-Q.d.cts} +1 -1
- package/dist/{ProxyPlugin--9F0WYSD.d.ts → ProxyPlugin-Cs7B9xzo.d.ts} +2 -2
- package/dist/{ProxyPlugin-C9FSADp9.d.cts → ProxyPlugin-rOa2o83O.d.cts} +2 -2
- package/dist/{Server-CVyJAYne.d.cts → Server-Cfz6d-2n.d.cts} +3 -2
- package/dist/{Server-CbcNkm0I.d.ts → Server-um_Vy8kC.d.ts} +3 -2
- package/dist/{Swagger-BuMxfyha.d.ts → Swagger-CIAFqmEw.d.ts} +6 -64
- package/dist/{Swagger-BWCRS_VR.d.cts → Swagger-CoAiKR11.d.cts} +6 -64
- package/dist/{common.type-BPo50rEF.d.ts → common.type-BAw801cA.d.ts} +1 -1
- package/dist/{common.type-f0llB3mM.d.cts → common.type-D02Uw2lN.d.cts} +1 -1
- package/dist/config.cjs +12 -11
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts +1 -2
- package/dist/config.d.ts +1 -2
- package/dist/config.js +11 -11
- package/dist/config.js.map +1 -1
- package/dist/cors.d.cts +1 -1
- package/dist/cors.d.ts +1 -1
- package/dist/decorators.cjs +92 -89
- package/dist/decorators.cjs.map +1 -1
- package/dist/decorators.d.cts +10 -15
- package/dist/decorators.d.ts +10 -15
- package/dist/decorators.js +92 -89
- package/dist/decorators.js.map +1 -1
- package/dist/index.cjs +12 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/infra.cjs +12 -11
- package/dist/infra.cjs.map +1 -1
- package/dist/infra.d.cts +3 -3
- package/dist/infra.d.ts +3 -3
- package/dist/infra.js +11 -11
- package/dist/infra.js.map +1 -1
- package/dist/middleware.d.cts +2 -2
- package/dist/middleware.d.ts +2 -2
- package/dist/plugins.d.cts +3 -3
- package/dist/plugins.d.ts +3 -3
- package/dist/{proxy.type-B2VypPGc.d.ts → proxy.type-B9XYNOyP.d.ts} +1 -1
- package/dist/{proxy.type-ByYzE_1y.d.cts → proxy.type-h1wgeME0.d.cts} +1 -1
- package/dist/rate-limit.d.cts +1 -1
- package/dist/rate-limit.d.ts +1 -1
- package/dist/router.d.cts +1 -1
- package/dist/router.d.ts +1 -1
- package/dist/shared/swagger/swagger-ui-modern.html +595 -901
- package/dist/swagger.cjs +291 -435
- package/dist/swagger.cjs.map +1 -1
- package/dist/swagger.d.cts +6 -130
- package/dist/swagger.d.ts +6 -130
- package/dist/swagger.js +291 -435
- package/dist/swagger.js.map +1 -1
- package/dist/types.d.cts +2 -2
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
- package/src/decorators/Route.ts +70 -64
- package/src/decorators/Swagger.ts +74 -178
- package/src/infra/Server.ts +4 -3
- package/src/shared/config/ConfigModule.ts +13 -9
- package/src/shared/swagger/SwaggerGenerator.ts +107 -252
- package/src/shared/swagger/SwaggerHelper.ts +8 -12
- package/src/shared/swagger/index.ts +48 -50
- package/src/shared/swagger/swagger-ui-modern.html +595 -901
- package/src/types/index.ts +3 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as RequestServer } from './common.type-
|
|
1
|
+
import { a as RequestServer } from './common.type-BAw801cA.js';
|
|
2
2
|
import { R as ResponseServer } from './response.type-d6e6eU9D.js';
|
|
3
|
-
import { P as ProxyOptions } from './proxy.type-
|
|
3
|
+
import { P as ProxyOptions } from './proxy.type-B9XYNOyP.js';
|
|
4
4
|
|
|
5
5
|
declare function createProxyMiddleware(options: ProxyOptions): (req: RequestServer, res: ResponseServer, next?: Function) => Promise<void>;
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as RequestServer } from './common.type-
|
|
1
|
+
import { a as RequestServer } from './common.type-D02Uw2lN.cjs';
|
|
2
2
|
import { R as ResponseServer } from './response.type-d6e6eU9D.cjs';
|
|
3
|
-
import { P as ProxyOptions } from './proxy.type-
|
|
3
|
+
import { P as ProxyOptions } from './proxy.type-h1wgeME0.cjs';
|
|
4
4
|
|
|
5
5
|
declare function createProxyMiddleware(options: ProxyOptions): (req: RequestServer, res: ResponseServer, next?: Function) => Promise<void>;
|
|
6
6
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ConfigTypes } from './config.cjs';
|
|
2
2
|
import http from 'node:http';
|
|
3
3
|
import { Router } from './router.cjs';
|
|
4
|
-
import { R as RequestHandler } from './common.type-
|
|
5
|
-
import { P as ProxyOptions } from './proxy.type-
|
|
4
|
+
import { R as RequestHandler } from './common.type-D02Uw2lN.cjs';
|
|
5
|
+
import { P as ProxyOptions } from './proxy.type-h1wgeME0.cjs';
|
|
6
6
|
|
|
7
7
|
declare class AzuraClient {
|
|
8
8
|
private opts;
|
|
@@ -19,6 +19,7 @@ declare class AzuraClient {
|
|
|
19
19
|
private setupDefaultRoutes;
|
|
20
20
|
getConfig(): ConfigTypes;
|
|
21
21
|
private init;
|
|
22
|
+
use(prefix: string, mw: RequestHandler): void;
|
|
22
23
|
use(mw: RequestHandler): void;
|
|
23
24
|
use(prefix: string, router: Router): void;
|
|
24
25
|
addRoute(method: string, path: string, ...handlers: RequestHandler[]): void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ConfigTypes } from './config.js';
|
|
2
2
|
import http from 'node:http';
|
|
3
3
|
import { Router } from './router.js';
|
|
4
|
-
import { R as RequestHandler } from './common.type-
|
|
5
|
-
import { P as ProxyOptions } from './proxy.type-
|
|
4
|
+
import { R as RequestHandler } from './common.type-BAw801cA.js';
|
|
5
|
+
import { P as ProxyOptions } from './proxy.type-B9XYNOyP.js';
|
|
6
6
|
|
|
7
7
|
declare class AzuraClient {
|
|
8
8
|
private opts;
|
|
@@ -19,6 +19,7 @@ declare class AzuraClient {
|
|
|
19
19
|
private setupDefaultRoutes;
|
|
20
20
|
getConfig(): ConfigTypes;
|
|
21
21
|
private init;
|
|
22
|
+
use(prefix: string, mw: RequestHandler): void;
|
|
22
23
|
use(mw: RequestHandler): void;
|
|
23
24
|
use(prefix: string, router: Router): void;
|
|
24
25
|
addRoute(method: string, path: string, ...handlers: RequestHandler[]): void;
|
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import { A as ApiDocMetadata, H as Header, q as Schema, v as SecurityRequirement
|
|
1
|
+
import { A as ApiDocMetadata, H as Header, q as Schema, v as SecurityRequirement } from './swagger.type-BWq5nhCX.js';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Decorator to document an endpoint
|
|
5
|
-
*/
|
|
6
3
|
declare function ApiDoc(metadata: Omit<ApiDocMetadata, "method" | "path">): MethodDecorator;
|
|
7
|
-
/**
|
|
8
|
-
* Decorator to document a response
|
|
9
|
-
*/
|
|
10
4
|
declare function ApiResponse(statusCode: number, description: string, options?: {
|
|
11
5
|
type?: any;
|
|
12
6
|
examples?: Record<string, any>;
|
|
13
7
|
headers?: Record<string, Header>;
|
|
14
8
|
}): MethodDecorator;
|
|
15
|
-
/**
|
|
16
|
-
* Decorator to document a parameter
|
|
17
|
-
*/
|
|
18
9
|
declare function ApiParameter(name: string, paramIn: "query" | "header" | "path" | "cookie", options?: {
|
|
19
10
|
description?: string;
|
|
20
11
|
required?: boolean;
|
|
@@ -22,70 +13,21 @@ declare function ApiParameter(name: string, paramIn: "query" | "header" | "path"
|
|
|
22
13
|
example?: any;
|
|
23
14
|
schema?: Schema;
|
|
24
15
|
}): MethodDecorator;
|
|
25
|
-
/**
|
|
26
|
-
* Decorator to document a request body
|
|
27
|
-
*/
|
|
28
16
|
declare function ApiBody(description: string, options?: {
|
|
29
17
|
type?: any;
|
|
30
18
|
required?: boolean;
|
|
31
19
|
examples?: Record<string, any>;
|
|
32
20
|
}): MethodDecorator;
|
|
33
|
-
/**
|
|
34
|
-
* Decorator to add tags to a controller
|
|
35
|
-
*/
|
|
36
21
|
declare function ApiTags(...tags: string[]): ClassDecorator;
|
|
37
|
-
/**
|
|
38
|
-
* Decorator to mark an endpoint as deprecated
|
|
39
|
-
*/
|
|
40
22
|
declare function ApiDeprecated(): MethodDecorator;
|
|
41
|
-
/**
|
|
42
|
-
* Decorator to add security requirements
|
|
43
|
-
*/
|
|
44
23
|
declare function ApiSecurity(...requirements: SecurityRequirement[]): MethodDecorator;
|
|
45
|
-
/**
|
|
46
|
-
* Helper to get all swagger metadata
|
|
47
|
-
*/
|
|
48
24
|
declare function getSwaggerMetadata(target: Function): {
|
|
49
|
-
metadata:
|
|
50
|
-
responses:
|
|
51
|
-
parameters:
|
|
52
|
-
body:
|
|
53
|
-
tags:
|
|
25
|
+
metadata: any;
|
|
26
|
+
responses: any;
|
|
27
|
+
parameters: any;
|
|
28
|
+
body: any;
|
|
29
|
+
tags: any;
|
|
54
30
|
};
|
|
55
|
-
/**
|
|
56
|
-
* Unified Swagger decorator - Simple and easy to use!
|
|
57
|
-
* Document everything in one place with a clean object structure.
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```typescript
|
|
61
|
-
* @Swagger({
|
|
62
|
-
* summary: "Get user by ID",
|
|
63
|
-
* description: "Retrieve a single user",
|
|
64
|
-
* tags: ["Users"],
|
|
65
|
-
* parameters: [
|
|
66
|
-
* {
|
|
67
|
-
* name: "id",
|
|
68
|
-
* in: "path",
|
|
69
|
-
* description: "User ID",
|
|
70
|
-
* required: true,
|
|
71
|
-
* schema: { type: "string" },
|
|
72
|
-
* example: "123"
|
|
73
|
-
* }
|
|
74
|
-
* ],
|
|
75
|
-
* responses: {
|
|
76
|
-
* 200: {
|
|
77
|
-
* description: "User found",
|
|
78
|
-
* example: { id: "123", name: "John" }
|
|
79
|
-
* },
|
|
80
|
-
* 404: {
|
|
81
|
-
* description: "User not found",
|
|
82
|
-
* example: { error: "Not found" }
|
|
83
|
-
* }
|
|
84
|
-
* }
|
|
85
|
-
* })
|
|
86
|
-
* getUser(req, res) { }
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
31
|
declare function Swagger(config: {
|
|
90
32
|
summary?: string;
|
|
91
33
|
description?: string;
|
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import { A as ApiDocMetadata, H as Header, q as Schema, v as SecurityRequirement
|
|
1
|
+
import { A as ApiDocMetadata, H as Header, q as Schema, v as SecurityRequirement } from './swagger.type-BWq5nhCX.cjs';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Decorator to document an endpoint
|
|
5
|
-
*/
|
|
6
3
|
declare function ApiDoc(metadata: Omit<ApiDocMetadata, "method" | "path">): MethodDecorator;
|
|
7
|
-
/**
|
|
8
|
-
* Decorator to document a response
|
|
9
|
-
*/
|
|
10
4
|
declare function ApiResponse(statusCode: number, description: string, options?: {
|
|
11
5
|
type?: any;
|
|
12
6
|
examples?: Record<string, any>;
|
|
13
7
|
headers?: Record<string, Header>;
|
|
14
8
|
}): MethodDecorator;
|
|
15
|
-
/**
|
|
16
|
-
* Decorator to document a parameter
|
|
17
|
-
*/
|
|
18
9
|
declare function ApiParameter(name: string, paramIn: "query" | "header" | "path" | "cookie", options?: {
|
|
19
10
|
description?: string;
|
|
20
11
|
required?: boolean;
|
|
@@ -22,70 +13,21 @@ declare function ApiParameter(name: string, paramIn: "query" | "header" | "path"
|
|
|
22
13
|
example?: any;
|
|
23
14
|
schema?: Schema;
|
|
24
15
|
}): MethodDecorator;
|
|
25
|
-
/**
|
|
26
|
-
* Decorator to document a request body
|
|
27
|
-
*/
|
|
28
16
|
declare function ApiBody(description: string, options?: {
|
|
29
17
|
type?: any;
|
|
30
18
|
required?: boolean;
|
|
31
19
|
examples?: Record<string, any>;
|
|
32
20
|
}): MethodDecorator;
|
|
33
|
-
/**
|
|
34
|
-
* Decorator to add tags to a controller
|
|
35
|
-
*/
|
|
36
21
|
declare function ApiTags(...tags: string[]): ClassDecorator;
|
|
37
|
-
/**
|
|
38
|
-
* Decorator to mark an endpoint as deprecated
|
|
39
|
-
*/
|
|
40
22
|
declare function ApiDeprecated(): MethodDecorator;
|
|
41
|
-
/**
|
|
42
|
-
* Decorator to add security requirements
|
|
43
|
-
*/
|
|
44
23
|
declare function ApiSecurity(...requirements: SecurityRequirement[]): MethodDecorator;
|
|
45
|
-
/**
|
|
46
|
-
* Helper to get all swagger metadata
|
|
47
|
-
*/
|
|
48
24
|
declare function getSwaggerMetadata(target: Function): {
|
|
49
|
-
metadata:
|
|
50
|
-
responses:
|
|
51
|
-
parameters:
|
|
52
|
-
body:
|
|
53
|
-
tags:
|
|
25
|
+
metadata: any;
|
|
26
|
+
responses: any;
|
|
27
|
+
parameters: any;
|
|
28
|
+
body: any;
|
|
29
|
+
tags: any;
|
|
54
30
|
};
|
|
55
|
-
/**
|
|
56
|
-
* Unified Swagger decorator - Simple and easy to use!
|
|
57
|
-
* Document everything in one place with a clean object structure.
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```typescript
|
|
61
|
-
* @Swagger({
|
|
62
|
-
* summary: "Get user by ID",
|
|
63
|
-
* description: "Retrieve a single user",
|
|
64
|
-
* tags: ["Users"],
|
|
65
|
-
* parameters: [
|
|
66
|
-
* {
|
|
67
|
-
* name: "id",
|
|
68
|
-
* in: "path",
|
|
69
|
-
* description: "User ID",
|
|
70
|
-
* required: true,
|
|
71
|
-
* schema: { type: "string" },
|
|
72
|
-
* example: "123"
|
|
73
|
-
* }
|
|
74
|
-
* ],
|
|
75
|
-
* responses: {
|
|
76
|
-
* 200: {
|
|
77
|
-
* description: "User found",
|
|
78
|
-
* example: { id: "123", name: "John" }
|
|
79
|
-
* },
|
|
80
|
-
* 404: {
|
|
81
|
-
* description: "User not found",
|
|
82
|
-
* example: { error: "Not found" }
|
|
83
|
-
* }
|
|
84
|
-
* }
|
|
85
|
-
* })
|
|
86
|
-
* getUser(req, res) { }
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
31
|
declare function Swagger(config: {
|
|
90
32
|
summary?: string;
|
|
91
33
|
description?: string;
|
package/dist/config.cjs
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var fs = require('fs');
|
|
4
|
+
require('url');
|
|
4
5
|
var path = require('path');
|
|
6
|
+
var module$1 = require('module');
|
|
5
7
|
|
|
8
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
6
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
10
|
|
|
8
11
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
12
|
-
}) : x)(function(x) {
|
|
13
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
14
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
15
|
-
});
|
|
13
|
+
// src/shared/config/ConfigModule.ts
|
|
16
14
|
var ConfigModule = class {
|
|
17
15
|
constructor() {
|
|
18
16
|
this.config = {};
|
|
19
17
|
}
|
|
20
18
|
/**
|
|
21
19
|
* Load config files first (azura.config.*)
|
|
22
|
-
*
|
|
23
|
-
* @param configFiles
|
|
20
|
+
* Received error if config file not found or invalid format
|
|
24
21
|
*/
|
|
25
22
|
initSync() {
|
|
26
23
|
const cdw = process.cwd();
|
|
@@ -35,21 +32,25 @@ var ConfigModule = class {
|
|
|
35
32
|
const filePath = path__default.default.join(cdw, fileName);
|
|
36
33
|
if (!fs.existsSync(filePath)) continue;
|
|
37
34
|
const extension = path__default.default.extname(fileName);
|
|
38
|
-
const raw = fs.readFileSync(filePath, "utf8");
|
|
39
35
|
try {
|
|
40
36
|
let parsed;
|
|
41
37
|
switch (extension) {
|
|
42
38
|
case ".ts":
|
|
43
39
|
case ".js":
|
|
44
|
-
const
|
|
40
|
+
const require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('config.cjs', document.baseURI).href)));
|
|
41
|
+
const mod = require2(filePath);
|
|
45
42
|
parsed = mod.default || mod;
|
|
46
43
|
break;
|
|
47
44
|
case ".json":
|
|
45
|
+
const raw = fs.readFileSync(filePath, "utf8");
|
|
48
46
|
parsed = JSON.parse(raw);
|
|
49
47
|
break;
|
|
50
48
|
case ".yaml":
|
|
51
49
|
case ".yml":
|
|
52
|
-
|
|
50
|
+
const yamlRaw = fs.readFileSync(filePath, "utf8");
|
|
51
|
+
const requireYaml = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('config.cjs', document.baseURI).href)));
|
|
52
|
+
const jsYaml = requireYaml("js-yaml");
|
|
53
|
+
parsed = jsYaml.load(yamlRaw);
|
|
53
54
|
break;
|
|
54
55
|
default:
|
|
55
56
|
throw new Error(`Invalid config file extension: ${extension}`);
|
package/dist/config.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/shared/config/ConfigModule.ts"],"names":["path","existsSync","readFileSync"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/shared/config/ConfigModule.ts"],"names":["path","existsSync","require","createRequire","readFileSync"],"mappings":";;;;;;;;;;;;;AAsDO,IAAM,eAAN,MAAmB;AAAA,EAAnB,WAAA,GAAA;AACL,IAAA,IAAA,CAAQ,SAAsB,EAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM/B,QAAA,GAAiB;AACf,IAAA,MAAM,GAAA,GAAM,QAAQ,GAAA,EAAI;AACxB,IAAA,MAAM,WAAA,GAA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AG,IAAA,CAAK,MAAA,EAAQ,GAAG,MAAA,EAAO;AAC1C,QAAA,MAAA,GAAS,IAAA;AACT,QAAA;AAAA,MACF,SAAS,KAAA,EAAoB;AAC3B,QAAA,MAAM,IAAI,KAAA,CAAM,CAAA,2BAAA,EAA8B,QAAQ;AAAA,EAAK,KAAA,CAAM,OAAO,CAAA,CAAE,CAAA;AAAA,MAC5E;AAAA,IACF;AAEA,IAAA,IAAI,CAAC,MAAA,EAAQ;AACX,MAAA,MAAM,IAAI,MAAM,qDAAqD,CAAA;AAAA,IACvE;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAA,GAAsB;AACpB,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,IAAiC,GAAA,EAAwB;AACvD,IAAA,OAAO,IAAA,CAAK,OAAO,GAAG,CAAA;AAAA,EACxB;AACF","file":"config.cjs","sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { pathToFileURL } from \"node:url\";\nimport path from \"node:path\";\nimport { createRequire } from \"node:module\";\n\n/**\n * Config Files Extensions Supported\n * ex: azura.config.*extension\n */\ntype SupportedConfigFile = \".js\" | \".ts\" | \".json\" | \".yaml\" | \".yml\";\n\nexport type ConfigTypes = {\n name?: string;\n environment?: \"development\" | \"production\";\n debug?: boolean;\n server?: {\n port?: number;\n cluster?: boolean;\n ipHost?: boolean;\n https?: boolean;\n /**\n * Configure trust proxy behavior for IP resolution\n * - true: trust all proxies\n * - false: don't trust any proxies (default)\n * - number: trust the nth hop from the front-facing proxy\n * - string: trust specific IP address or CIDR range\n * - string[]: trust multiple IPs or CIDR ranges\n */\n trustProxy?: boolean | number | string | string[];\n /**\n * Custom header name to read IP from\n * @default 'x-forwarded-for'\n */\n ipHeader?: string;\n };\n plugins?: {\n rateLimit?: {\n enabled: boolean;\n limit: number;\n timeframe: number;\n };\n cors?: {\n enabled: boolean;\n origins: string | string[];\n methods: string | string[];\n allowedHeaders: string | string[];\n };\n };\n logging?: {\n enabled?: boolean;\n showDetails?: boolean;\n };\n};\n\nexport class ConfigModule {\n private config: ConfigTypes = {};\n\n /**\n * Load config files first (azura.config.*)\n * Received error if config file not found or invalid format\n */\n initSync(): void {\n const cdw = process.cwd();\n const configFiles = [\n \"azura.config.ts\",\n \"azura.config.json\",\n \"azura.config.yaml\",\n \"azura.config.yml\",\n ];\n\n let loaded = false;\n\n for (const fileName of configFiles) {\n const filePath = path.join(cdw, fileName);\n if (!existsSync(filePath)) continue;\n\n const extension = path.extname(fileName) as SupportedConfigFile;\n\n try {\n let parsed: ConfigTypes;\n\n switch (extension) {\n case \".ts\":\n case \".js\":\n // Usa createRequire para manter compatibilidade com ESM\n const require = createRequire(import.meta.url);\n const mod = require(filePath);\n parsed = mod.default || mod;\n break;\n case \".json\":\n const raw = readFileSync(filePath, \"utf8\");\n parsed = JSON.parse(raw);\n break;\n case \".yaml\":\n case \".yml\":\n const yamlRaw = readFileSync(filePath, \"utf8\");\n const requireYaml = createRequire(import.meta.url);\n const jsYaml = requireYaml(\"js-yaml\");\n parsed = jsYaml.load(yamlRaw) as ConfigTypes;\n break;\n default:\n throw new Error(`Invalid config file extension: ${extension}`);\n }\n\n this.config = { ...this.config, ...parsed };\n loaded = true;\n break;\n } catch (error: Error | any) {\n throw new Error(`Error loading config file: ${filePath}\\n${error.message}`);\n }\n }\n\n if (!loaded) {\n throw new Error(\"Nothing config file found in the current directory.\");\n }\n }\n\n /**\n * Get all configs from loaded config file\n * @returns ConfigTypes\n */\n getAll(): ConfigTypes {\n return this.config;\n }\n\n /**\n * Return a specific config from loaded config file\n *\n * @template T\n * @param {T} key - key of the config to retrieve\n * @returns {ConfigTypes[T]}\n */\n get<T extends keyof ConfigTypes>(key: T): ConfigTypes[T] {\n return this.config[key];\n }\n}"]}
|
package/dist/config.d.cts
CHANGED
|
@@ -44,8 +44,7 @@ declare class ConfigModule {
|
|
|
44
44
|
private config;
|
|
45
45
|
/**
|
|
46
46
|
* Load config files first (azura.config.*)
|
|
47
|
-
*
|
|
48
|
-
* @param configFiles
|
|
47
|
+
* Received error if config file not found or invalid format
|
|
49
48
|
*/
|
|
50
49
|
initSync(): void;
|
|
51
50
|
/**
|
package/dist/config.d.ts
CHANGED
|
@@ -44,8 +44,7 @@ declare class ConfigModule {
|
|
|
44
44
|
private config;
|
|
45
45
|
/**
|
|
46
46
|
* Load config files first (azura.config.*)
|
|
47
|
-
*
|
|
48
|
-
* @param configFiles
|
|
47
|
+
* Received error if config file not found or invalid format
|
|
49
48
|
*/
|
|
50
49
|
initSync(): void;
|
|
51
50
|
/**
|
package/dist/config.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'fs';
|
|
2
|
+
import 'url';
|
|
2
3
|
import path from 'path';
|
|
4
|
+
import { createRequire } from 'module';
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
6
|
-
}) : x)(function(x) {
|
|
7
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
8
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
9
|
-
});
|
|
6
|
+
// src/shared/config/ConfigModule.ts
|
|
10
7
|
var ConfigModule = class {
|
|
11
8
|
constructor() {
|
|
12
9
|
this.config = {};
|
|
13
10
|
}
|
|
14
11
|
/**
|
|
15
12
|
* Load config files first (azura.config.*)
|
|
16
|
-
*
|
|
17
|
-
* @param configFiles
|
|
13
|
+
* Received error if config file not found or invalid format
|
|
18
14
|
*/
|
|
19
15
|
initSync() {
|
|
20
16
|
const cdw = process.cwd();
|
|
@@ -29,21 +25,25 @@ var ConfigModule = class {
|
|
|
29
25
|
const filePath = path.join(cdw, fileName);
|
|
30
26
|
if (!existsSync(filePath)) continue;
|
|
31
27
|
const extension = path.extname(fileName);
|
|
32
|
-
const raw = readFileSync(filePath, "utf8");
|
|
33
28
|
try {
|
|
34
29
|
let parsed;
|
|
35
30
|
switch (extension) {
|
|
36
31
|
case ".ts":
|
|
37
32
|
case ".js":
|
|
38
|
-
const
|
|
33
|
+
const require2 = createRequire(import.meta.url);
|
|
34
|
+
const mod = require2(filePath);
|
|
39
35
|
parsed = mod.default || mod;
|
|
40
36
|
break;
|
|
41
37
|
case ".json":
|
|
38
|
+
const raw = readFileSync(filePath, "utf8");
|
|
42
39
|
parsed = JSON.parse(raw);
|
|
43
40
|
break;
|
|
44
41
|
case ".yaml":
|
|
45
42
|
case ".yml":
|
|
46
|
-
|
|
43
|
+
const yamlRaw = readFileSync(filePath, "utf8");
|
|
44
|
+
const requireYaml = createRequire(import.meta.url);
|
|
45
|
+
const jsYaml = requireYaml("js-yaml");
|
|
46
|
+
parsed = jsYaml.load(yamlRaw);
|
|
47
47
|
break;
|
|
48
48
|
default:
|
|
49
49
|
throw new Error(`Invalid config file extension: ${extension}`);
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/shared/config/ConfigModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/shared/config/ConfigModule.ts"],"names":["require"],"mappings":";;;;;;AAsDO,IAAM,eAAN,MAAmB;AAAA,EAAnB,WAAA,GAAA;AACL,IAAA,IAAA,CAAQ,SAAsB,EAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM/B,QAAA,GAAiB;AACf,IAAA,MAAM,GAAA,GAAM,QAAQ,GAAA,EAAI;AACxB,IAAA,MAAM,WAAA,GAAc;AAAA,MAClB,iBAAA;AAAA,MACA,mBAAA;AAAA,MACA,mBAAA;AAAA,MACA;AAAA,KACF;AAEA,IAAA,IAAI,MAAA,GAAS,KAAA;AAEb,IAAA,KAAA,MAAW,YAAY,WAAA,EAAa;AAClC,MAAA,MAAM,QAAA,GAAW,IAAA,CAAK,IAAA,CAAK,GAAA,EAAK,QAAQ,CAAA;AACxC,MAAA,IAAI,C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CAAE,CAAA;AAAA,MAC5E;AAAA,IACF;AAEA,IAAA,IAAI,CAAC,MAAA,EAAQ;AACX,MAAA,MAAM,IAAI,MAAM,qDAAqD,CAAA;AAAA,IACvE;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAA,GAAsB;AACpB,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,IAAiC,GAAA,EAAwB;AACvD,IAAA,OAAO,IAAA,CAAK,OAAO,GAAG,CAAA;AAAA,EACxB;AACF","file":"config.js","sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { pathToFileURL } from \"node:url\";\nimport path from \"node:path\";\nimport { createRequire } from \"node:module\";\n\n/**\n * Config Files Extensions Supported\n * ex: azura.config.*extension\n */\ntype SupportedConfigFile = \".js\" | \".ts\" | \".json\" | \".yaml\" | \".yml\";\n\nexport type ConfigTypes = {\n name?: string;\n environment?: \"development\" | \"production\";\n debug?: boolean;\n server?: {\n port?: number;\n cluster?: boolean;\n ipHost?: boolean;\n https?: boolean;\n /**\n * Configure trust proxy behavior for IP resolution\n * - true: trust all proxies\n * - false: don't trust any proxies (default)\n * - number: trust the nth hop from the front-facing proxy\n * - string: trust specific IP address or CIDR range\n * - string[]: trust multiple IPs or CIDR ranges\n */\n trustProxy?: boolean | number | string | string[];\n /**\n * Custom header name to read IP from\n * @default 'x-forwarded-for'\n */\n ipHeader?: string;\n };\n plugins?: {\n rateLimit?: {\n enabled: boolean;\n limit: number;\n timeframe: number;\n };\n cors?: {\n enabled: boolean;\n origins: string | string[];\n methods: string | string[];\n allowedHeaders: string | string[];\n };\n };\n logging?: {\n enabled?: boolean;\n showDetails?: boolean;\n };\n};\n\nexport class ConfigModule {\n private config: ConfigTypes = {};\n\n /**\n * Load config files first (azura.config.*)\n * Received error if config file not found or invalid format\n */\n initSync(): void {\n const cdw = process.cwd();\n const configFiles = [\n \"azura.config.ts\",\n \"azura.config.json\",\n \"azura.config.yaml\",\n \"azura.config.yml\",\n ];\n\n let loaded = false;\n\n for (const fileName of configFiles) {\n const filePath = path.join(cdw, fileName);\n if (!existsSync(filePath)) continue;\n\n const extension = path.extname(fileName) as SupportedConfigFile;\n\n try {\n let parsed: ConfigTypes;\n\n switch (extension) {\n case \".ts\":\n case \".js\":\n // Usa createRequire para manter compatibilidade com ESM\n const require = createRequire(import.meta.url);\n const mod = require(filePath);\n parsed = mod.default || mod;\n break;\n case \".json\":\n const raw = readFileSync(filePath, \"utf8\");\n parsed = JSON.parse(raw);\n break;\n case \".yaml\":\n case \".yml\":\n const yamlRaw = readFileSync(filePath, \"utf8\");\n const requireYaml = createRequire(import.meta.url);\n const jsYaml = requireYaml(\"js-yaml\");\n parsed = jsYaml.load(yamlRaw) as ConfigTypes;\n break;\n default:\n throw new Error(`Invalid config file extension: ${extension}`);\n }\n\n this.config = { ...this.config, ...parsed };\n loaded = true;\n break;\n } catch (error: Error | any) {\n throw new Error(`Error loading config file: ${filePath}\\n${error.message}`);\n }\n }\n\n if (!loaded) {\n throw new Error(\"Nothing config file found in the current directory.\");\n }\n }\n\n /**\n * Get all configs from loaded config file\n * @returns ConfigTypes\n */\n getAll(): ConfigTypes {\n return this.config;\n }\n\n /**\n * Return a specific config from loaded config file\n *\n * @template T\n * @param {T} key - key of the config to retrieve\n * @returns {ConfigTypes[T]}\n */\n get<T extends keyof ConfigTypes>(key: T): ConfigTypes[T] {\n return this.config[key];\n }\n}"]}
|
package/dist/cors.d.cts
CHANGED
package/dist/cors.d.ts
CHANGED