azurajs 2.2.0 → 2.4.0
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-CYNvypha.d.cts → LoggingMiddleware-DTrY3W4i.d.cts} +1 -1
- package/dist/{LoggingMiddleware-BQKJUBqT.d.ts → LoggingMiddleware-rWrLslKl.d.ts} +1 -1
- package/dist/ProxyPlugin-C8N2AtaT.d.cts +11 -0
- package/dist/ProxyPlugin-CzDTnllH.d.ts +11 -0
- package/dist/{Server-CY3k1FIL.d.cts → Server-2cG_Fz3U.d.cts} +22 -2
- package/dist/{Server-Ba-EFdi2.d.ts → Server-47kmx_eB.d.ts} +22 -2
- package/dist/colors.type-CgmoA5kW.d.cts +86 -0
- package/dist/colors.type-CgmoA5kW.d.ts +86 -0
- package/dist/{request.type-CJ-EGGcM.d.cts → common.type-DEa1osVV.d.ts} +9 -1
- package/dist/{request.type-CJ-EGGcM.d.ts → common.type-oXALN7XJ.d.cts} +9 -1
- package/dist/config.cjs +1 -0
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts +14 -0
- package/dist/config.d.ts +14 -0
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/cookies.cjs +344 -0
- package/dist/cookies.cjs.map +1 -1
- package/dist/cookies.d.cts +119 -3
- package/dist/cookies.d.ts +119 -3
- package/dist/cookies.js +340 -1
- package/dist/cookies.js.map +1 -1
- package/dist/cookies.type-BZZ0wd-o.d.cts +127 -0
- package/dist/cookies.type-BZZ0wd-o.d.ts +127 -0
- package/dist/cors.d.cts +1 -2
- package/dist/cors.d.ts +1 -2
- package/dist/decorators.d.cts +4 -4
- package/dist/decorators.d.ts +4 -4
- package/dist/index.cjs +439 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +80 -5
- package/dist/index.d.ts +80 -5
- package/dist/index.js +435 -30
- package/dist/index.js.map +1 -1
- package/dist/infra.cjs +414 -29
- 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 +413 -29
- package/dist/infra.js.map +1 -1
- package/dist/logger.cjs +149 -16
- package/dist/logger.cjs.map +1 -1
- package/dist/logger.d.cts +105 -6
- package/dist/logger.d.ts +105 -6
- package/dist/logger.js +147 -17
- package/dist/logger.js.map +1 -1
- package/dist/middleware.d.cts +2 -3
- package/dist/middleware.d.ts +2 -3
- package/dist/plugins.cjs +253 -0
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.cts +3 -2
- package/dist/plugins.d.ts +3 -2
- package/dist/plugins.js +247 -1
- package/dist/plugins.js.map +1 -1
- package/dist/proxy.type-DSnJz20D.d.cts +23 -0
- package/dist/proxy.type-W2HTcyty.d.ts +23 -0
- package/dist/rate-limit.d.cts +1 -2
- package/dist/rate-limit.d.ts +1 -2
- package/dist/router.cjs +15 -1
- package/dist/router.cjs.map +1 -1
- package/dist/router.d.cts +5 -2
- package/dist/router.d.ts +5 -2
- package/dist/router.js +15 -1
- package/dist/router.js.map +1 -1
- package/dist/types.cjs +63 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +23 -3
- package/dist/types.d.ts +23 -3
- package/dist/types.js +56 -0
- package/dist/types.js.map +1 -1
- package/dist/utils.cjs +1342 -43
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +6 -4
- package/dist/utils.d.ts +6 -4
- package/dist/utils.js +1323 -44
- package/dist/utils.js.map +1 -1
- package/dist/validators.cjs +822 -0
- package/dist/validators.cjs.map +1 -1
- package/dist/validators.d.cts +223 -4
- package/dist/validators.d.ts +223 -4
- package/dist/validators.js +811 -1
- package/dist/validators.js.map +1 -1
- package/dist/validators.type-DJZoGXZt.d.cts +250 -0
- package/dist/validators.type-DJZoGXZt.d.ts +250 -0
- package/package.json +1 -1
- package/src/decorators/index.ts +1 -3
- package/src/index.ts +8 -1
- package/src/infra/Router.ts +20 -1
- package/src/infra/Server.ts +104 -14
- package/src/infra/utils/IpResolver.ts +208 -0
- package/src/shared/config/ConfigModule.ts +16 -1
- package/src/shared/plugins/ProxyPlugin.ts +167 -0
- package/src/shared/plugins/index.ts +1 -0
- package/src/types/cookies.type.ts +158 -0
- package/src/types/extensions.d.ts +59 -0
- package/src/types/index.ts +10 -0
- package/src/types/logger.types.ts +35 -0
- package/src/types/plugins/proxy.type.ts +24 -0
- package/src/types/utils/colors.type.ts +60 -0
- package/src/types/utils/icons.type.ts +15 -0
- package/src/types/validators.type.ts +263 -0
- package/src/utils/Logger.ts +212 -17
- package/src/utils/cookies/CookieManager.ts +463 -0
- package/src/utils/cookies/index.ts +2 -0
- package/src/utils/index.ts +11 -3
- package/src/utils/validators/Validator.ts +1015 -0
- package/src/utils/validators/index.ts +2 -0
- package/dist/common.type-BoV71o_C.d.ts +0 -11
- package/dist/common.type-Ct06XeYQ.d.cts +0 -11
- package/dist/validations.type-D4ZhF5g6.d.cts +0 -6
- package/dist/validations.type-D4ZhF5g6.d.ts +0 -6
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { a as RequestServer } from './common.type-oXALN7XJ.cjs';
|
|
2
|
+
import { R as ResponseServer } from './response.type-d6e6eU9D.cjs';
|
|
3
|
+
import { P as ProxyOptions } from './proxy.type-DSnJz20D.cjs';
|
|
4
|
+
|
|
5
|
+
declare function createProxyMiddleware(options: ProxyOptions): (req: RequestServer, res: ResponseServer, next?: Function) => Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Middleware de proxy simples - apenas passa o target
|
|
8
|
+
*/
|
|
9
|
+
declare function proxyPlugin(target: string, options?: Partial<ProxyOptions>): (req: RequestServer, res: ResponseServer, next?: Function) => Promise<void>;
|
|
10
|
+
|
|
11
|
+
export { createProxyMiddleware as c, proxyPlugin as p };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { a as RequestServer } from './common.type-DEa1osVV.js';
|
|
2
|
+
import { R as ResponseServer } from './response.type-d6e6eU9D.js';
|
|
3
|
+
import { P as ProxyOptions } from './proxy.type-W2HTcyty.js';
|
|
4
|
+
|
|
5
|
+
declare function createProxyMiddleware(options: ProxyOptions): (req: RequestServer, res: ResponseServer, next?: Function) => Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Middleware de proxy simples - apenas passa o target
|
|
8
|
+
*/
|
|
9
|
+
declare function proxyPlugin(target: string, options?: Partial<ProxyOptions>): (req: RequestServer, res: ResponseServer, next?: Function) => Promise<void>;
|
|
10
|
+
|
|
11
|
+
export { createProxyMiddleware as c, proxyPlugin as p };
|
|
@@ -1,15 +1,17 @@
|
|
|
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-
|
|
4
|
+
import { R as RequestHandler } from './common.type-oXALN7XJ.cjs';
|
|
5
|
+
import { P as ProxyOptions } from './proxy.type-DSnJz20D.cjs';
|
|
5
6
|
|
|
6
7
|
declare class AzuraClient {
|
|
7
8
|
private opts;
|
|
8
9
|
private server?;
|
|
9
10
|
private port;
|
|
10
11
|
private initPromise;
|
|
11
|
-
router
|
|
12
|
+
private router;
|
|
12
13
|
private middlewares;
|
|
14
|
+
private proxies;
|
|
13
15
|
constructor();
|
|
14
16
|
/**
|
|
15
17
|
* Configura rotas padrão para evitar erros 404 comuns
|
|
@@ -18,12 +20,30 @@ declare class AzuraClient {
|
|
|
18
20
|
getConfig(): ConfigTypes;
|
|
19
21
|
private init;
|
|
20
22
|
use(mw: RequestHandler): void;
|
|
23
|
+
use(prefix: string, router: Router): void;
|
|
21
24
|
addRoute(method: string, path: string, ...handlers: RequestHandler[]): void;
|
|
22
25
|
get: (p: string, ...h: RequestHandler[]) => void;
|
|
23
26
|
post: (p: string, ...h: RequestHandler[]) => void;
|
|
24
27
|
put: (p: string, ...h: RequestHandler[]) => void;
|
|
25
28
|
delete: (p: string, ...h: RequestHandler[]) => void;
|
|
26
29
|
patch: (p: string, ...h: RequestHandler[]) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Configures a proxy for a specific route
|
|
32
|
+
* @param path - Path of the route to be proxied
|
|
33
|
+
* @param target - Destination server URL
|
|
34
|
+
* @param options - Additional proxy options
|
|
35
|
+
* * @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* // Simple proxy
|
|
38
|
+
* app.proxy('/api', 'http://localhost:4000');
|
|
39
|
+
* * // With advanced options
|
|
40
|
+
* app.proxy('/api', 'http://localhost:4000', {
|
|
41
|
+
* pathRewrite: { '^/api': '' },
|
|
42
|
+
* headers: { 'X-Custom-Header': 'value' }
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
proxy(path: string, target: string, options?: Partial<ProxyOptions>): void;
|
|
27
47
|
getRoutes(): {
|
|
28
48
|
method: string;
|
|
29
49
|
path: string;
|
|
@@ -1,15 +1,17 @@
|
|
|
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-
|
|
4
|
+
import { R as RequestHandler } from './common.type-DEa1osVV.js';
|
|
5
|
+
import { P as ProxyOptions } from './proxy.type-W2HTcyty.js';
|
|
5
6
|
|
|
6
7
|
declare class AzuraClient {
|
|
7
8
|
private opts;
|
|
8
9
|
private server?;
|
|
9
10
|
private port;
|
|
10
11
|
private initPromise;
|
|
11
|
-
router
|
|
12
|
+
private router;
|
|
12
13
|
private middlewares;
|
|
14
|
+
private proxies;
|
|
13
15
|
constructor();
|
|
14
16
|
/**
|
|
15
17
|
* Configura rotas padrão para evitar erros 404 comuns
|
|
@@ -18,12 +20,30 @@ declare class AzuraClient {
|
|
|
18
20
|
getConfig(): ConfigTypes;
|
|
19
21
|
private init;
|
|
20
22
|
use(mw: RequestHandler): void;
|
|
23
|
+
use(prefix: string, router: Router): void;
|
|
21
24
|
addRoute(method: string, path: string, ...handlers: RequestHandler[]): void;
|
|
22
25
|
get: (p: string, ...h: RequestHandler[]) => void;
|
|
23
26
|
post: (p: string, ...h: RequestHandler[]) => void;
|
|
24
27
|
put: (p: string, ...h: RequestHandler[]) => void;
|
|
25
28
|
delete: (p: string, ...h: RequestHandler[]) => void;
|
|
26
29
|
patch: (p: string, ...h: RequestHandler[]) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Configures a proxy for a specific route
|
|
32
|
+
* @param path - Path of the route to be proxied
|
|
33
|
+
* @param target - Destination server URL
|
|
34
|
+
* @param options - Additional proxy options
|
|
35
|
+
* * @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* // Simple proxy
|
|
38
|
+
* app.proxy('/api', 'http://localhost:4000');
|
|
39
|
+
* * // With advanced options
|
|
40
|
+
* app.proxy('/api', 'http://localhost:4000', {
|
|
41
|
+
* pathRewrite: { '^/api': '' },
|
|
42
|
+
* headers: { 'X-Custom-Header': 'value' }
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
proxy(path: string, target: string, options?: Partial<ProxyOptions>): void;
|
|
27
47
|
getRoutes(): {
|
|
28
48
|
method: string;
|
|
29
49
|
path: string;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger configuration interface
|
|
3
|
+
* Allows customization of logger appearance and behavior
|
|
4
|
+
*/
|
|
5
|
+
interface LoggerConfig {
|
|
6
|
+
/** Custom color mapping for log levels (supports hex, rgb, or predefined color names) */
|
|
7
|
+
colors?: Record<string, string>;
|
|
8
|
+
/** Custom icon mapping for log levels */
|
|
9
|
+
icons?: Record<string, string>;
|
|
10
|
+
/** Whether to display timestamps in log messages */
|
|
11
|
+
showTimestamp?: boolean;
|
|
12
|
+
/** Whether to display icons in log messages */
|
|
13
|
+
showIcon?: boolean;
|
|
14
|
+
/** Format for timestamp display: 'time' (HH:MM:SS), 'datetime' (full date and time), or 'iso' (ISO 8601) */
|
|
15
|
+
timestampFormat?: "time" | "datetime" | "iso";
|
|
16
|
+
/** Custom prefix for log messages (default: 'Azura') */
|
|
17
|
+
prefix?: string;
|
|
18
|
+
/** Whether to display log level in uppercase */
|
|
19
|
+
uppercase?: boolean;
|
|
20
|
+
/** Apply bold styling to log level label */
|
|
21
|
+
bold?: boolean;
|
|
22
|
+
/** Apply dim/faded styling to log level label */
|
|
23
|
+
dim?: boolean;
|
|
24
|
+
/** Background color for log level label (supports hex, rgb, or predefined bg color names) */
|
|
25
|
+
backgroundColor?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* ANSI escape codes for text styling
|
|
30
|
+
* These codes control text formatting in terminal output
|
|
31
|
+
*/
|
|
32
|
+
declare const RESET = "\u001B[0m";
|
|
33
|
+
declare const BOLD = "\u001B[1m";
|
|
34
|
+
declare const DIM = "\u001B[2m";
|
|
35
|
+
/**
|
|
36
|
+
* Predefined ANSI foreground colors
|
|
37
|
+
* Includes standard and bright color variants
|
|
38
|
+
*/
|
|
39
|
+
declare const ANSI_COLORS: {
|
|
40
|
+
black: string;
|
|
41
|
+
red: string;
|
|
42
|
+
green: string;
|
|
43
|
+
yellow: string;
|
|
44
|
+
blue: string;
|
|
45
|
+
magenta: string;
|
|
46
|
+
cyan: string;
|
|
47
|
+
white: string;
|
|
48
|
+
gray: string;
|
|
49
|
+
brightRed: string;
|
|
50
|
+
brightGreen: string;
|
|
51
|
+
brightYellow: string;
|
|
52
|
+
brightBlue: string;
|
|
53
|
+
brightMagenta: string;
|
|
54
|
+
brightCyan: string;
|
|
55
|
+
brightWhite: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* ANSI background color codes
|
|
59
|
+
* Used for highlighting text with colored backgrounds
|
|
60
|
+
*/
|
|
61
|
+
declare const BG_COLORS: {
|
|
62
|
+
bgBlack: string;
|
|
63
|
+
bgRed: string;
|
|
64
|
+
bgGreen: string;
|
|
65
|
+
bgYellow: string;
|
|
66
|
+
bgBlue: string;
|
|
67
|
+
bgMagenta: string;
|
|
68
|
+
bgCyan: string;
|
|
69
|
+
bgWhite: string;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Default color mapping for each log level
|
|
73
|
+
* Provides semantic color coding for different message types
|
|
74
|
+
*/
|
|
75
|
+
declare const DEFAULT_COLORS: {
|
|
76
|
+
debug: string;
|
|
77
|
+
info: string;
|
|
78
|
+
success: string;
|
|
79
|
+
warn: string;
|
|
80
|
+
error: string;
|
|
81
|
+
fatal: string;
|
|
82
|
+
trace: string;
|
|
83
|
+
log: string;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export { ANSI_COLORS as A, BOLD as B, DIM as D, type LoggerConfig as L, RESET as R, BG_COLORS as a, DEFAULT_COLORS as b };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger configuration interface
|
|
3
|
+
* Allows customization of logger appearance and behavior
|
|
4
|
+
*/
|
|
5
|
+
interface LoggerConfig {
|
|
6
|
+
/** Custom color mapping for log levels (supports hex, rgb, or predefined color names) */
|
|
7
|
+
colors?: Record<string, string>;
|
|
8
|
+
/** Custom icon mapping for log levels */
|
|
9
|
+
icons?: Record<string, string>;
|
|
10
|
+
/** Whether to display timestamps in log messages */
|
|
11
|
+
showTimestamp?: boolean;
|
|
12
|
+
/** Whether to display icons in log messages */
|
|
13
|
+
showIcon?: boolean;
|
|
14
|
+
/** Format for timestamp display: 'time' (HH:MM:SS), 'datetime' (full date and time), or 'iso' (ISO 8601) */
|
|
15
|
+
timestampFormat?: "time" | "datetime" | "iso";
|
|
16
|
+
/** Custom prefix for log messages (default: 'Azura') */
|
|
17
|
+
prefix?: string;
|
|
18
|
+
/** Whether to display log level in uppercase */
|
|
19
|
+
uppercase?: boolean;
|
|
20
|
+
/** Apply bold styling to log level label */
|
|
21
|
+
bold?: boolean;
|
|
22
|
+
/** Apply dim/faded styling to log level label */
|
|
23
|
+
dim?: boolean;
|
|
24
|
+
/** Background color for log level label (supports hex, rgb, or predefined bg color names) */
|
|
25
|
+
backgroundColor?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* ANSI escape codes for text styling
|
|
30
|
+
* These codes control text formatting in terminal output
|
|
31
|
+
*/
|
|
32
|
+
declare const RESET = "\u001B[0m";
|
|
33
|
+
declare const BOLD = "\u001B[1m";
|
|
34
|
+
declare const DIM = "\u001B[2m";
|
|
35
|
+
/**
|
|
36
|
+
* Predefined ANSI foreground colors
|
|
37
|
+
* Includes standard and bright color variants
|
|
38
|
+
*/
|
|
39
|
+
declare const ANSI_COLORS: {
|
|
40
|
+
black: string;
|
|
41
|
+
red: string;
|
|
42
|
+
green: string;
|
|
43
|
+
yellow: string;
|
|
44
|
+
blue: string;
|
|
45
|
+
magenta: string;
|
|
46
|
+
cyan: string;
|
|
47
|
+
white: string;
|
|
48
|
+
gray: string;
|
|
49
|
+
brightRed: string;
|
|
50
|
+
brightGreen: string;
|
|
51
|
+
brightYellow: string;
|
|
52
|
+
brightBlue: string;
|
|
53
|
+
brightMagenta: string;
|
|
54
|
+
brightCyan: string;
|
|
55
|
+
brightWhite: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* ANSI background color codes
|
|
59
|
+
* Used for highlighting text with colored backgrounds
|
|
60
|
+
*/
|
|
61
|
+
declare const BG_COLORS: {
|
|
62
|
+
bgBlack: string;
|
|
63
|
+
bgRed: string;
|
|
64
|
+
bgGreen: string;
|
|
65
|
+
bgYellow: string;
|
|
66
|
+
bgBlue: string;
|
|
67
|
+
bgMagenta: string;
|
|
68
|
+
bgCyan: string;
|
|
69
|
+
bgWhite: string;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Default color mapping for each log level
|
|
73
|
+
* Provides semantic color coding for different message types
|
|
74
|
+
*/
|
|
75
|
+
declare const DEFAULT_COLORS: {
|
|
76
|
+
debug: string;
|
|
77
|
+
info: string;
|
|
78
|
+
success: string;
|
|
79
|
+
warn: string;
|
|
80
|
+
error: string;
|
|
81
|
+
fatal: string;
|
|
82
|
+
trace: string;
|
|
83
|
+
log: string;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export { ANSI_COLORS as A, BOLD as B, DIM as D, type LoggerConfig as L, RESET as R, BG_COLORS as a, DEFAULT_COLORS as b };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IncomingMessage, IncomingHttpHeaders } from 'node:http';
|
|
2
|
+
import { R as ResponseServer } from './response.type-d6e6eU9D.js';
|
|
2
3
|
|
|
3
4
|
interface RequestServer extends IncomingMessage {
|
|
4
5
|
path: string;
|
|
@@ -19,4 +20,11 @@ interface RequestServer extends IncomingMessage {
|
|
|
19
20
|
header(name: string): string | undefined;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
type RequestHandler = (req: RequestServer, res: ResponseServer, next: (err?: Error | any) => void) => void;
|
|
24
|
+
interface HttpContext {
|
|
25
|
+
request: RequestServer;
|
|
26
|
+
response: ResponseServer;
|
|
27
|
+
body?: Buffer | string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type { HttpContext as H, RequestHandler as R, RequestServer as a };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IncomingMessage, IncomingHttpHeaders } from 'node:http';
|
|
2
|
+
import { R as ResponseServer } from './response.type-d6e6eU9D.cjs';
|
|
2
3
|
|
|
3
4
|
interface RequestServer extends IncomingMessage {
|
|
4
5
|
path: string;
|
|
@@ -19,4 +20,11 @@ interface RequestServer extends IncomingMessage {
|
|
|
19
20
|
header(name: string): string | undefined;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
type RequestHandler = (req: RequestServer, res: ResponseServer, next: (err?: Error | any) => void) => void;
|
|
24
|
+
interface HttpContext {
|
|
25
|
+
request: RequestServer;
|
|
26
|
+
response: ResponseServer;
|
|
27
|
+
body?: Buffer | string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type { HttpContext as H, RequestHandler as R, RequestServer as a };
|
package/dist/config.cjs
CHANGED
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","readFileSync"],"mappings":";;;;;;;;;;;;;;;AAoDO,IAAM,eAAN,MAAmB;AAAA,EAAnB,WAAA,GAAA;AACL,IAAA,IAAA,CAAQ,SAAsB,EAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ/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;AACb,IAAA,KAAA,MAAW,YAAY,WAAA,EAAa;AAClC,MAAA,MAAM,QAAA,GAAWA,qBAAA,CAAK,IAAA,CAAK,GAAA,EAAK,QAAQ,CAAA;AACxC,MAAA,IAAI,CAACC,aAAA,CAAW,QAAQ,CAAA,EAAG;AAE3B,MAAA,MAAM,SAAA,GAAYD,qBAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA;AACvC,MAAA,MAAM,GAAA,GAAME,eAAA,CAAa,QAAA,EAAU,MAAM,CAAA;AAEzC,MAAA,IAAI;AACF,QAAA,IAAI,MAAA;AACJ,QAAA,QAAQ,SAAA;AAAW,UACjB,KAAK,KAAA;AAAA,UACL,KAAK,KAAA;AACH,YAAA,MAAM,GAAA,GAAM,UAAQ,QAAQ,CAAA;AAC5B,YAAA,MAAA,GAAS,IAAI,OAAA,IAAW,GAAA;AACxB,YAAA;AAAA,UACF,KAAK,OAAA;AACH,YAAA,MAAA,GAAS,IAAA,CAAK,MAAM,GAAG,CAAA;AACvB,YAAA;AAAA,UACF,KAAK,OAAA;AAAA,UACL,KAAK,MAAA;AACH,YAAA,MAAA,GAAS,SAAA,CAAQ,SAAS,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AACpC,YAAA;AAAA,UACF;AACE,YAAA,MAAM,IAAI,KAAA,CAAM,CAAA,+BAAA,EAAkC,SAAS,CAAA,CAAE,CAAA;AAAA;AAGjE,QAAA,IAAA,CAAK,SAAS,EAAE,GAAG,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,EAOA,MAAA,GAAsB;AACpB,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,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 path from \"node:path\";\n\n/**\n * Config Files Extensions Supported\n * ex: azura.config.*extension\n */\n\ntype SupportedConfigFile = \".js\" | \".ts\" | \".json\" | \".yaml\" | \".yml\";\n\nexport type ConfigTypes = {\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 * Recivied error if config file not found or invalid format\n * @param configFiles\n */\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 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 const raw = readFileSync(filePath, \"utf8\");\n\n try {\n let parsed: ConfigTypes;\n switch (extension) {\n case \".ts\":\n case \".js\":\n const mod = require(filePath);\n parsed = mod.default || mod;\n break;\n case \".json\":\n parsed = JSON.parse(raw);\n break;\n case \".yaml\":\n case \".yml\":\n parsed = require(\"js-yaml\").load(raw);\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\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\n get<T extends keyof ConfigTypes>(key: T): ConfigTypes[T] {\n return this.config[key];\n }\n}\n"]}
|
package/dist/config.d.cts
CHANGED
|
@@ -6,6 +6,20 @@ type ConfigTypes = {
|
|
|
6
6
|
cluster?: boolean;
|
|
7
7
|
ipHost?: boolean;
|
|
8
8
|
https?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Configure trust proxy behavior for IP resolution
|
|
11
|
+
* - true: trust all proxies
|
|
12
|
+
* - false: don't trust any proxies (default)
|
|
13
|
+
* - number: trust the nth hop from the front-facing proxy
|
|
14
|
+
* - string: trust specific IP address or CIDR range
|
|
15
|
+
* - string[]: trust multiple IPs or CIDR ranges
|
|
16
|
+
*/
|
|
17
|
+
trustProxy?: boolean | number | string | string[];
|
|
18
|
+
/**
|
|
19
|
+
* Custom header name to read IP from
|
|
20
|
+
* @default 'x-forwarded-for'
|
|
21
|
+
*/
|
|
22
|
+
ipHeader?: string;
|
|
9
23
|
};
|
|
10
24
|
plugins?: {
|
|
11
25
|
rateLimit?: {
|
package/dist/config.d.ts
CHANGED
|
@@ -6,6 +6,20 @@ type ConfigTypes = {
|
|
|
6
6
|
cluster?: boolean;
|
|
7
7
|
ipHost?: boolean;
|
|
8
8
|
https?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Configure trust proxy behavior for IP resolution
|
|
11
|
+
* - true: trust all proxies
|
|
12
|
+
* - false: don't trust any proxies (default)
|
|
13
|
+
* - number: trust the nth hop from the front-facing proxy
|
|
14
|
+
* - string: trust specific IP address or CIDR range
|
|
15
|
+
* - string[]: trust multiple IPs or CIDR ranges
|
|
16
|
+
*/
|
|
17
|
+
trustProxy?: boolean | number | string | string[];
|
|
18
|
+
/**
|
|
19
|
+
* Custom header name to read IP from
|
|
20
|
+
* @default 'x-forwarded-for'
|
|
21
|
+
*/
|
|
22
|
+
ipHeader?: string;
|
|
9
23
|
};
|
|
10
24
|
plugins?: {
|
|
11
25
|
rateLimit?: {
|
package/dist/config.js
CHANGED
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":[],"mappings":";;;;;;;;;AAoDO,IAAM,eAAN,MAAmB;AAAA,EAAnB,WAAA,GAAA;AACL,IAAA,IAAA,CAAQ,SAAsB,EAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ/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;AACb,IAAA,KAAA,MAAW,YAAY,WAAA,EAAa;AAClC,MAAA,MAAM,QAAA,GAAW,IAAA,CAAK,IAAA,CAAK,GAAA,EAAK,QAAQ,CAAA;AACxC,MAAA,IAAI,CAAC,UAAA,CAAW,QAAQ,CAAA,EAAG;AAE3B,MAAA,MAAM,SAAA,GAAY,IAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA;AACvC,MAAA,MAAM,GAAA,GAAM,YAAA,CAAa,QAAA,EAAU,MAAM,CAAA;AAEzC,MAAA,IAAI;AACF,QAAA,IAAI,MAAA;AACJ,QAAA,QAAQ,SAAA;AAAW,UACjB,KAAK,KAAA;AAAA,UACL,KAAK,KAAA;AACH,YAAA,MAAM,GAAA,GAAM,UAAQ,QAAQ,CAAA;AAC5B,YAAA,MAAA,GAAS,IAAI,OAAA,IAAW,GAAA;AACxB,YAAA;AAAA,UACF,KAAK,OAAA;AACH,YAAA,MAAA,GAAS,IAAA,CAAK,MAAM,GAAG,CAAA;AACvB,YAAA;AAAA,UACF,KAAK,OAAA;AAAA,UACL,KAAK,MAAA;AACH,YAAA,MAAA,GAAS,SAAA,CAAQ,SAAS,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AACpC,YAAA;AAAA,UACF;AACE,YAAA,MAAM,IAAI,KAAA,CAAM,CAAA,+BAAA,EAAkC,SAAS,CAAA,CAAE,CAAA;AAAA;AAGjE,QAAA,IAAA,CAAK,SAAS,EAAE,GAAG,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,EAOA,MAAA,GAAsB;AACpB,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,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 path from \"node:path\";\n\n/**\n * Config Files Extensions Supported\n * ex: azura.config.*extension\n */\n\ntype SupportedConfigFile = \".js\" | \".ts\" | \".json\" | \".yaml\" | \".yml\";\n\nexport type ConfigTypes = {\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 * Recivied error if config file not found or invalid format\n * @param configFiles\n */\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 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 const raw = readFileSync(filePath, \"utf8\");\n\n try {\n let parsed: ConfigTypes;\n switch (extension) {\n case \".ts\":\n case \".js\":\n const mod = require(filePath);\n parsed = mod.default || mod;\n break;\n case \".json\":\n parsed = JSON.parse(raw);\n break;\n case \".yaml\":\n case \".yml\":\n parsed = require(\"js-yaml\").load(raw);\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\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\n get<T extends keyof ConfigTypes>(key: T): ConfigTypes[T] {\n return this.config[key];\n }\n}\n"]}
|