azurajs 2.3.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-DN5yAhkX.d.cts → ProxyPlugin-C8N2AtaT.d.cts} +2 -2
- package/dist/{ProxyPlugin-DzKHKl5x.d.ts → ProxyPlugin-CzDTnllH.d.ts} +2 -2
- package/dist/{Server-CBibslLs.d.cts → Server-2cG_Fz3U.d.cts} +2 -2
- package/dist/{Server-JgWGBIJb.d.ts → Server-47kmx_eB.d.ts} +2 -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.ts → common.type-DEa1osVV.d.ts} +9 -1
- package/dist/{request.type-CJ-EGGcM.d.cts → common.type-oXALN7XJ.d.cts} +9 -1
- 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.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 -5
- package/dist/decorators.d.ts +4 -5
- package/dist/index.cjs +246 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +80 -7
- package/dist/index.d.ts +80 -7
- package/dist/index.js +245 -26
- package/dist/index.js.map +1 -1
- package/dist/infra.cjs +224 -25
- package/dist/infra.cjs.map +1 -1
- package/dist/infra.d.cts +3 -4
- package/dist/infra.d.ts +3 -4
- package/dist/infra.js +224 -25
- 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 +114 -16
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.cts +3 -4
- package/dist/plugins.d.ts +3 -4
- package/dist/plugins.js +114 -16
- package/dist/plugins.js.map +1 -1
- package/dist/{proxy.type-CtbSNjKM.d.cts → proxy.type-DSnJz20D.d.cts} +1 -1
- package/dist/{proxy.type-CSaviouz.d.ts → proxy.type-W2HTcyty.d.ts} +1 -1
- 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 +4 -1
- package/dist/router.d.ts +4 -1
- 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 -4
- package/dist/types.d.ts +23 -4
- 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 +19 -0
- package/src/infra/Server.ts +24 -9
- package/src/infra/utils/IpResolver.ts +208 -0
- package/src/shared/config/ConfigModule.ts +14 -0
- package/src/types/cookies.type.ts +158 -0
- package/src/types/extensions.d.ts +59 -0
- package/src/types/index.ts +9 -0
- package/src/types/logger.types.ts +35 -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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as RequestServer } from './common.type-oXALN7XJ.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-DSnJz20D.cjs';
|
|
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 {
|
|
1
|
+
import { a as RequestServer } from './common.type-DEa1osVV.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-W2HTcyty.js';
|
|
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-oXALN7XJ.cjs';
|
|
5
|
+
import { P as ProxyOptions } from './proxy.type-DSnJz20D.cjs';
|
|
6
6
|
|
|
7
7
|
declare class AzuraClient {
|
|
8
8
|
private opts;
|
|
@@ -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-DEa1osVV.js';
|
|
5
|
+
import { P as ProxyOptions } from './proxy.type-W2HTcyty.js';
|
|
6
6
|
|
|
7
7
|
declare class AzuraClient {
|
|
8
8
|
private opts;
|
|
@@ -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.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.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"]}
|