azurajs 2.3.0 → 2.4.1-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/README.md +6 -3
- package/dist/{LoggingMiddleware-BQKJUBqT.d.ts → LoggingMiddleware-BchkPkH1.d.ts} +1 -1
- package/dist/{LoggingMiddleware-CYNvypha.d.cts → LoggingMiddleware-CKV1J-pk.d.cts} +1 -1
- package/dist/{ProxyPlugin-DN5yAhkX.d.cts → ProxyPlugin-BOqrVi_Z.d.cts} +2 -2
- package/dist/{ProxyPlugin-DzKHKl5x.d.ts → ProxyPlugin-CBdhfKEk.d.ts} +2 -2
- package/dist/{Server-JgWGBIJb.d.ts → Server-Cxt5ItIO.d.ts} +2 -2
- package/dist/{Server-CBibslLs.d.cts → Server-ZBdAKUkW.d.cts} +2 -2
- package/dist/colors.type-CgmoA5kW.d.cts +86 -0
- package/dist/colors.type-CgmoA5kW.d.ts +86 -0
- package/dist/common.type-DzWRjunB.d.cts +37 -0
- package/dist/common.type-ydMVG8sw.d.ts +37 -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.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.cjs +1 -1
- package/dist/decorators.cjs.map +1 -1
- package/dist/decorators.d.cts +4 -5
- package/dist/decorators.d.ts +4 -5
- package/dist/decorators.js +1 -1
- package/dist/decorators.js.map +1 -1
- package/dist/index.cjs +277 -34
- 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 +276 -35
- package/dist/index.js.map +1 -1
- package/dist/infra.cjs +255 -34
- 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 +255 -34
- 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-CSaviouz.d.ts → proxy.type-Ccn3auo8.d.ts} +1 -1
- package/dist/{proxy.type-CtbSNjKM.d.cts → proxy.type-qt4XEHnf.d.cts} +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/Route.ts +2 -2
- 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 +31 -11
- package/src/infra/utils/GetIp.ts +28 -8
- package/src/infra/utils/IpResolver.ts +208 -0
- package/src/infra/utils/RequestHandler.ts +6 -0
- package/src/shared/config/ConfigModule.ts +14 -0
- package/src/types/common.type.ts +8 -2
- 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/request.type-CJ-EGGcM.d.cts +0 -22
- package/dist/request.type-CJ-EGGcM.d.ts +0 -22
- package/dist/validations.type-D4ZhF5g6.d.cts +0 -6
- package/dist/validations.type-D4ZhF5g6.d.ts +0 -6
package/README.md
CHANGED
|
@@ -38,10 +38,11 @@ AzuraJS supports modular imports for tree-shaking and better organization:
|
|
|
38
38
|
|
|
39
39
|
```typescript
|
|
40
40
|
// Main package
|
|
41
|
-
import { AzuraClient
|
|
41
|
+
import { AzuraClient } from "azurajs";
|
|
42
42
|
|
|
43
43
|
// Decorators
|
|
44
44
|
import { Controller, Get, Post, Body, Param } from "azurajs/decorators";
|
|
45
|
+
import { applyDecorators } from "azurajs/decorators";
|
|
45
46
|
|
|
46
47
|
// Middleware
|
|
47
48
|
import { createLoggingMiddleware } from "azurajs/middleware";
|
|
@@ -101,7 +102,8 @@ export default config;
|
|
|
101
102
|
### 2. Create your server
|
|
102
103
|
|
|
103
104
|
```typescript
|
|
104
|
-
import { AzuraClient
|
|
105
|
+
import { AzuraClient } from "azurajs";
|
|
106
|
+
import { applyDecorators } from "azurajs/decorators";
|
|
105
107
|
import { Controller, Get, Post, Body, Param, Query, Res } from "azurajs/decorators";
|
|
106
108
|
import { createLoggingMiddleware } from "azurajs/middleware";
|
|
107
109
|
import type { ResponseServer } from "azurajs/types";
|
|
@@ -644,7 +646,8 @@ type ConfigTypes = {
|
|
|
644
646
|
### Complete CRUD API
|
|
645
647
|
|
|
646
648
|
```typescript
|
|
647
|
-
import { AzuraClient
|
|
649
|
+
import { AzuraClient } from "azurajs";
|
|
650
|
+
import { applyDecorators } from "azurajs/decorators";
|
|
648
651
|
import { Controller, Get, Post, Put, Delete, Body, Param, Res } from "azurajs/decorators";
|
|
649
652
|
import type { ResponseServer } from "azurajs/types";
|
|
650
653
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as RequestServer } from './common.type-DzWRjunB.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-qt4XEHnf.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-ydMVG8sw.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-Ccn3auo8.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.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-ydMVG8sw.js';
|
|
5
|
+
import { P as ProxyOptions } from './proxy.type-Ccn3auo8.js';
|
|
6
6
|
|
|
7
7
|
declare class AzuraClient {
|
|
8
8
|
private opts;
|
|
@@ -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-DzWRjunB.cjs';
|
|
5
|
+
import { P as ProxyOptions } from './proxy.type-qt4XEHnf.cjs';
|
|
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 };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { IncomingMessage, IncomingHttpHeaders } from 'node:http';
|
|
2
|
+
import { R as ResponseServer } from './response.type-d6e6eU9D.cjs';
|
|
3
|
+
|
|
4
|
+
interface RequestServer extends IncomingMessage {
|
|
5
|
+
path: string;
|
|
6
|
+
originalUrl: string;
|
|
7
|
+
method: string;
|
|
8
|
+
protocol: "http" | "https";
|
|
9
|
+
secure: boolean;
|
|
10
|
+
hostname: string;
|
|
11
|
+
subdomains: string[];
|
|
12
|
+
ip: string;
|
|
13
|
+
ips?: string[];
|
|
14
|
+
params: Record<string, string>;
|
|
15
|
+
query: Record<string, string>;
|
|
16
|
+
body: unknown;
|
|
17
|
+
cookies: Record<string, string>;
|
|
18
|
+
headers: IncomingHttpHeaders;
|
|
19
|
+
get(name: string): string | undefined;
|
|
20
|
+
header(name: string): string | undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type NextFunction = (err?: Error | any) => void | Promise<void>;
|
|
24
|
+
type TraditionalHandler = (req: RequestServer, res: ResponseServer, next?: NextFunction) => void | Promise<void> | unknown;
|
|
25
|
+
type DestructuredHandler = (ctx: {
|
|
26
|
+
req: RequestServer;
|
|
27
|
+
res: ResponseServer;
|
|
28
|
+
next?: NextFunction;
|
|
29
|
+
}) => void | Promise<void> | unknown;
|
|
30
|
+
type RequestHandler = TraditionalHandler | DestructuredHandler;
|
|
31
|
+
interface HttpContext {
|
|
32
|
+
request: RequestServer;
|
|
33
|
+
response: ResponseServer;
|
|
34
|
+
body?: Buffer | string | unknown;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type { HttpContext as H, RequestHandler as R, RequestServer as a };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { IncomingMessage, IncomingHttpHeaders } from 'node:http';
|
|
2
|
+
import { R as ResponseServer } from './response.type-d6e6eU9D.js';
|
|
3
|
+
|
|
4
|
+
interface RequestServer extends IncomingMessage {
|
|
5
|
+
path: string;
|
|
6
|
+
originalUrl: string;
|
|
7
|
+
method: string;
|
|
8
|
+
protocol: "http" | "https";
|
|
9
|
+
secure: boolean;
|
|
10
|
+
hostname: string;
|
|
11
|
+
subdomains: string[];
|
|
12
|
+
ip: string;
|
|
13
|
+
ips?: string[];
|
|
14
|
+
params: Record<string, string>;
|
|
15
|
+
query: Record<string, string>;
|
|
16
|
+
body: unknown;
|
|
17
|
+
cookies: Record<string, string>;
|
|
18
|
+
headers: IncomingHttpHeaders;
|
|
19
|
+
get(name: string): string | undefined;
|
|
20
|
+
header(name: string): string | undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type NextFunction = (err?: Error | any) => void | Promise<void>;
|
|
24
|
+
type TraditionalHandler = (req: RequestServer, res: ResponseServer, next?: NextFunction) => void | Promise<void> | unknown;
|
|
25
|
+
type DestructuredHandler = (ctx: {
|
|
26
|
+
req: RequestServer;
|
|
27
|
+
res: ResponseServer;
|
|
28
|
+
next?: NextFunction;
|
|
29
|
+
}) => void | Promise<void> | unknown;
|
|
30
|
+
type RequestHandler = TraditionalHandler | DestructuredHandler;
|
|
31
|
+
interface HttpContext {
|
|
32
|
+
request: RequestServer;
|
|
33
|
+
response: ResponseServer;
|
|
34
|
+
body?: Buffer | string | unknown;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
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":";;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E,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;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,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"]}
|