wynkjs 1.0.3 → 1.0.6
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 +528 -348
- package/dist/cors.d.ts +28 -0
- package/dist/cors.d.ts.map +1 -0
- package/dist/cors.js +121 -0
- package/dist/database.d.ts +1 -1
- package/dist/database.js +1 -1
- package/dist/decorators/exception.advanced.d.ts +286 -18
- package/dist/decorators/exception.advanced.d.ts.map +1 -1
- package/dist/decorators/exception.advanced.js +410 -17
- package/dist/decorators/exception.decorators.d.ts +93 -2
- package/dist/decorators/exception.decorators.d.ts.map +1 -1
- package/dist/decorators/exception.decorators.js +140 -8
- package/dist/decorators/formatter.decorators.d.ts +93 -0
- package/dist/decorators/formatter.decorators.d.ts.map +1 -0
- package/dist/decorators/formatter.decorators.js +131 -0
- package/dist/decorators/guard.decorators.d.ts +2 -2
- package/dist/decorators/guard.decorators.d.ts.map +1 -1
- package/dist/decorators/guard.decorators.js +11 -5
- package/dist/decorators/http.decorators.d.ts +10 -4
- package/dist/decorators/http.decorators.d.ts.map +1 -1
- package/dist/decorators/http.decorators.js +9 -2
- package/dist/decorators/interceptor.advanced.d.ts +9 -9
- package/dist/decorators/interceptor.advanced.d.ts.map +1 -1
- package/dist/decorators/interceptor.advanced.js +7 -7
- package/dist/decorators/interceptor.decorators.d.ts +9 -7
- package/dist/decorators/interceptor.decorators.d.ts.map +1 -1
- package/dist/decorators/interceptor.decorators.js +29 -18
- package/dist/decorators/param.decorators.d.ts +2 -2
- package/dist/decorators/param.decorators.js +1 -1
- package/dist/decorators/pipe.decorators.d.ts +4 -4
- package/dist/decorators/pipe.decorators.d.ts.map +1 -1
- package/dist/decorators/pipe.decorators.js +4 -4
- package/dist/dto.js +1 -1
- package/dist/factory.d.ts +30 -2
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +210 -186
- package/dist/filters/exception.filters.d.ts +124 -0
- package/dist/filters/exception.filters.d.ts.map +1 -0
- package/dist/filters/exception.filters.js +208 -0
- package/dist/global-prefix.d.ts +49 -0
- package/dist/global-prefix.d.ts.map +1 -0
- package/dist/global-prefix.js +155 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/interfaces/interceptor.interface.d.ts +15 -0
- package/dist/interfaces/interceptor.interface.d.ts.map +1 -0
- package/dist/interfaces/interceptor.interface.js +1 -0
- package/dist/optimized-handler.d.ts +31 -0
- package/dist/optimized-handler.d.ts.map +1 -0
- package/dist/optimized-handler.js +180 -0
- package/dist/pipes/validation.pipe.d.ts +12 -12
- package/dist/pipes/validation.pipe.d.ts.map +1 -1
- package/dist/pipes/validation.pipe.js +43 -15
- package/dist/schema-registry.d.ts +51 -0
- package/dist/schema-registry.d.ts.map +1 -0
- package/dist/schema-registry.js +134 -0
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +2 -2
- package/dist/ultra-optimized-handler.d.ts +51 -0
- package/dist/ultra-optimized-handler.d.ts.map +1 -0
- package/dist/ultra-optimized-handler.js +302 -0
- package/package.json +17 -10
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
import {
|
|
2
|
+
import { InterceptorContext } from "../interfaces/interceptor.interface";
|
|
3
|
+
type ExecutionContext = InterceptorContext;
|
|
3
4
|
/**
|
|
4
5
|
* Interceptor Decorators and Interfaces for WynkJS Framework
|
|
5
6
|
* Interceptors for request/response transformation
|
|
@@ -14,7 +15,7 @@ export interface CallHandler<T = any> {
|
|
|
14
15
|
* WynkInterceptor interface - All interceptors must implement this
|
|
15
16
|
*/
|
|
16
17
|
export interface WynkInterceptor {
|
|
17
|
-
intercept(context: ExecutionContext, next:
|
|
18
|
+
intercept(context: ExecutionContext, next: () => Promise<any>): Promise<any>;
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
21
|
* @UseInterceptors decorator - Apply interceptors to routes or controllers
|
|
@@ -32,7 +33,7 @@ export declare function UseInterceptors(...interceptors: (Function | WynkInterce
|
|
|
32
33
|
/**
|
|
33
34
|
* Helper function to execute interceptors
|
|
34
35
|
*/
|
|
35
|
-
export declare function executeInterceptors(interceptors: (Function | WynkInterceptor)[], context:
|
|
36
|
+
export declare function executeInterceptors(interceptors: (Function | WynkInterceptor)[], context: InterceptorContext, handler: () => Promise<any>): Promise<any>;
|
|
36
37
|
/**
|
|
37
38
|
* Common interceptor utilities
|
|
38
39
|
*/
|
|
@@ -50,7 +51,7 @@ export declare function executeInterceptors(interceptors: (Function | WynkInterc
|
|
|
50
51
|
export declare class TransformInterceptor implements WynkInterceptor {
|
|
51
52
|
private transformFn?;
|
|
52
53
|
constructor(transformFn?: ((data: any) => any) | undefined);
|
|
53
|
-
intercept(context:
|
|
54
|
+
intercept(context: InterceptorContext, next: () => Promise<any>): Promise<any>;
|
|
54
55
|
}
|
|
55
56
|
/**
|
|
56
57
|
* Timeout interceptor - Adds timeout to requests
|
|
@@ -63,7 +64,7 @@ export declare class TransformInterceptor implements WynkInterceptor {
|
|
|
63
64
|
export declare class TimeoutInterceptor implements WynkInterceptor {
|
|
64
65
|
private timeout;
|
|
65
66
|
constructor(timeout?: number);
|
|
66
|
-
intercept(context:
|
|
67
|
+
intercept(context: InterceptorContext, next: () => Promise<any>): Promise<any>;
|
|
67
68
|
}
|
|
68
69
|
/**
|
|
69
70
|
* Cache interceptor - Caches responses
|
|
@@ -76,7 +77,7 @@ export declare class CacheInterceptor implements WynkInterceptor {
|
|
|
76
77
|
private cache;
|
|
77
78
|
private ttl;
|
|
78
79
|
constructor(ttl?: number);
|
|
79
|
-
intercept(context:
|
|
80
|
+
intercept(context: InterceptorContext, next: () => Promise<any>): Promise<any>;
|
|
80
81
|
}
|
|
81
82
|
/**
|
|
82
83
|
* Logging interceptor - Logs requests and responses
|
|
@@ -86,6 +87,7 @@ export declare class CacheInterceptor implements WynkInterceptor {
|
|
|
86
87
|
* export class AppController {}
|
|
87
88
|
*/
|
|
88
89
|
export declare class LoggingInterceptor implements WynkInterceptor {
|
|
89
|
-
intercept(context:
|
|
90
|
+
intercept(context: InterceptorContext, next: () => Promise<any>): Promise<any>;
|
|
90
91
|
}
|
|
92
|
+
export {};
|
|
91
93
|
//# sourceMappingURL=interceptor.decorators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interceptor.decorators.d.ts","sourceRoot":"","sources":["../../core/decorators/interceptor.decorators.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"interceptor.decorators.d.ts","sourceRoot":"","sources":["../../core/decorators/interceptor.decorators.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAIzE,KAAK,gBAAgB,GAAG,kBAAkB,CAAC;AAK3C;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,GAAG;IAClC,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CAC9E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,GAAG,YAAY,EAAE,CAAC,QAAQ,GAAG,eAAe,CAAC,EAAE,GAC9C,eAAe,GAAG,cAAc,CA4BlC;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,YAAY,EAAE,CAAC,QAAQ,GAAG,eAAe,CAAC,EAAE,EAC5C,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GAC1B,OAAO,CAAC,GAAG,CAAC,CAyCd;AAED;;GAEG;AAEH;;;;;;;;;;GAUG;AACH,qBAAa,oBAAqB,YAAW,eAAe;IAC9C,OAAO,CAAC,WAAW,CAAC;gBAAZ,WAAW,CAAC,GAAE,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,aAAA;IAE9C,SAAS,CACb,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GACvB,OAAO,CAAC,GAAG,CAAC;CAahB;AAED;;;;;;;GAOG;AACH,qBAAa,kBAAmB,YAAW,eAAe;IAC5C,OAAO,CAAC,OAAO;gBAAP,OAAO,GAAE,MAAa;IAEpC,SAAS,CACb,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GACvB,OAAO,CAAC,GAAG,CAAC;CAQhB;AAED;;;;;;GAMG;AACH,qBAAa,gBAAiB,YAAW,eAAe;IACtD,OAAO,CAAC,KAAK,CAAuD;IACpE,OAAO,CAAC,GAAG,CAAS;gBAER,GAAG,GAAE,MAAc;IAIzB,SAAS,CACb,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GACvB,OAAO,CAAC,GAAG,CAAC;CAgBhB;AAED;;;;;;GAMG;AACH,qBAAa,kBAAmB,YAAW,eAAe;IAClD,SAAS,CACb,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GACvB,OAAO,CAAC,GAAG,CAAC;CAqBhB"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
+
import { container } from "tsyringe";
|
|
3
|
+
// Store singleton interceptor instances
|
|
4
|
+
const interceptorInstances = new Map();
|
|
2
5
|
/**
|
|
3
6
|
* @UseInterceptors decorator - Apply interceptors to routes or controllers
|
|
4
7
|
* @param interceptors Interceptor classes to apply
|
|
@@ -31,17 +34,27 @@ export function UseInterceptors(...interceptors) {
|
|
|
31
34
|
* Helper function to execute interceptors
|
|
32
35
|
*/
|
|
33
36
|
export async function executeInterceptors(interceptors, context, handler) {
|
|
34
|
-
// Build interceptor chain
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// Apply interceptors in
|
|
39
|
-
|
|
37
|
+
// Build interceptor chain
|
|
38
|
+
// First interceptor in array is innermost (transforms first, closest to handler)
|
|
39
|
+
// Last interceptor in array is outermost (transforms last, farthest from handler)
|
|
40
|
+
let next = handler;
|
|
41
|
+
// Apply interceptors in FORWARD order
|
|
42
|
+
// First wraps handler, second wraps first, etc.
|
|
43
|
+
for (let i = 0; i < interceptors.length; i++) {
|
|
40
44
|
const interceptor = interceptors[i];
|
|
41
|
-
const currentNext = next;
|
|
45
|
+
const currentNext = next; // Capture current next in closure
|
|
42
46
|
let interceptorInstance;
|
|
43
47
|
if (typeof interceptor === "function") {
|
|
44
|
-
|
|
48
|
+
// Always use singleton pattern - cache all interceptor instances by class
|
|
49
|
+
if (!interceptorInstances.has(interceptor)) {
|
|
50
|
+
try {
|
|
51
|
+
interceptorInstances.set(interceptor, container.resolve(interceptor));
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
interceptorInstances.set(interceptor, new interceptor());
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
interceptorInstance = interceptorInstances.get(interceptor);
|
|
45
58
|
}
|
|
46
59
|
else {
|
|
47
60
|
interceptorInstance = interceptor;
|
|
@@ -49,14 +62,12 @@ export async function executeInterceptors(interceptors, context, handler) {
|
|
|
49
62
|
if (!interceptorInstance.intercept) {
|
|
50
63
|
throw new Error(`Interceptor must implement WynkInterceptor interface`);
|
|
51
64
|
}
|
|
52
|
-
//
|
|
53
|
-
next = {
|
|
54
|
-
|
|
55
|
-
return interceptorInstance.intercept(context, currentNext);
|
|
56
|
-
},
|
|
65
|
+
// Wrap in a function that calls the interceptor
|
|
66
|
+
next = async () => {
|
|
67
|
+
return interceptorInstance.intercept(context, currentNext);
|
|
57
68
|
};
|
|
58
69
|
}
|
|
59
|
-
return next
|
|
70
|
+
return next();
|
|
60
71
|
}
|
|
61
72
|
/**
|
|
62
73
|
* Common interceptor utilities
|
|
@@ -78,7 +89,7 @@ export class TransformInterceptor {
|
|
|
78
89
|
this.transformFn = transformFn;
|
|
79
90
|
}
|
|
80
91
|
async intercept(context, next) {
|
|
81
|
-
const data = await next
|
|
92
|
+
const data = await next();
|
|
82
93
|
if (this.transformFn) {
|
|
83
94
|
return this.transformFn(data);
|
|
84
95
|
}
|
|
@@ -104,7 +115,7 @@ export class TimeoutInterceptor {
|
|
|
104
115
|
}
|
|
105
116
|
async intercept(context, next) {
|
|
106
117
|
return Promise.race([
|
|
107
|
-
next
|
|
118
|
+
next(),
|
|
108
119
|
new Promise((_, reject) => setTimeout(() => reject(new Error("Request timeout")), this.timeout)),
|
|
109
120
|
]);
|
|
110
121
|
}
|
|
@@ -131,7 +142,7 @@ export class CacheInterceptor {
|
|
|
131
142
|
return cached.data;
|
|
132
143
|
}
|
|
133
144
|
// Execute handler and cache result
|
|
134
|
-
const data = await next
|
|
145
|
+
const data = await next();
|
|
135
146
|
this.cache.set(cacheKey, { data, timestamp: Date.now() });
|
|
136
147
|
return data;
|
|
137
148
|
}
|
|
@@ -149,7 +160,7 @@ export class LoggingInterceptor {
|
|
|
149
160
|
const startTime = Date.now();
|
|
150
161
|
console.log(`📥 ${request.method} ${request.url} - Started`);
|
|
151
162
|
try {
|
|
152
|
-
const data = await next
|
|
163
|
+
const data = await next();
|
|
153
164
|
const duration = Date.now() - startTime;
|
|
154
165
|
console.log(`📤 ${request.method} ${request.url} - Completed in ${duration}ms`);
|
|
155
166
|
return data;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
/**
|
|
3
|
-
* Parameter Decorators for
|
|
3
|
+
* Parameter Decorators for WynkJS Framework
|
|
4
4
|
* Extract data from request context
|
|
5
5
|
*/
|
|
6
6
|
export type ParamType = "body" | "param" | "query" | "headers" | "request" | "response" | "context" | "user" | "file" | "files";
|
|
@@ -80,7 +80,7 @@ export declare function Res(): ParameterDecorator;
|
|
|
80
80
|
*/
|
|
81
81
|
export declare const Response: typeof Res;
|
|
82
82
|
/**
|
|
83
|
-
* @Context decorator - Injects full
|
|
83
|
+
* @Context decorator - Injects full WynkJS context
|
|
84
84
|
* @example
|
|
85
85
|
* @Get()
|
|
86
86
|
* getData(@Context() ctx: any) {}
|
|
@@ -47,7 +47,7 @@ export declare function executePipes(pipes: (Function | WynkPipeTransform)[], va
|
|
|
47
47
|
* create(@Body() dto: CreateDto) {}
|
|
48
48
|
*
|
|
49
49
|
* @example
|
|
50
|
-
* // Custom formatting
|
|
50
|
+
* // Custom formatting with detailed errors
|
|
51
51
|
* const customPipe = new ValidationPipe({
|
|
52
52
|
* exceptionFactory: (errors) => ({
|
|
53
53
|
* statusCode: 400,
|
|
@@ -66,12 +66,12 @@ export declare class ValidationPipe implements WynkPipeTransform {
|
|
|
66
66
|
});
|
|
67
67
|
transform(value: any, metadata: ArgumentMetadata): Promise<any>;
|
|
68
68
|
/**
|
|
69
|
-
* Format
|
|
69
|
+
* Format WynkJS validation error
|
|
70
70
|
* Called by ValidationExceptionFilter
|
|
71
71
|
*/
|
|
72
72
|
formatError(exception: any): any;
|
|
73
73
|
/**
|
|
74
|
-
* Parse validation error from
|
|
74
|
+
* Parse validation error from WynkJS exception
|
|
75
75
|
*/
|
|
76
76
|
private parseValidationError;
|
|
77
77
|
/**
|
|
@@ -161,7 +161,7 @@ export declare class TrimPipe implements WynkPipeTransform<string, string> {
|
|
|
161
161
|
}
|
|
162
162
|
/**
|
|
163
163
|
* FormatErrorPipe - Formats validation errors as { [field]: [messages] }
|
|
164
|
-
*
|
|
164
|
+
* Object format with field names as keys
|
|
165
165
|
*
|
|
166
166
|
* @example
|
|
167
167
|
* // In index.ts or controller
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipe.decorators.d.ts","sourceRoot":"","sources":["../../core/decorators/pipe.decorators.ts"],"names":[],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OAAO,CAAC,MAAM,CAAC;CAU5E;AAED;;;;;;GAMG;AACH,qBAAa,aAAa,CAAC,CAAC,GAAG,GAAG,CAAE,YAAW,iBAAiB,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7D,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,GAAG;IAE3B,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,CAAC,CAAC;CAavE;AAED;;;;;GAKG;AACH,qBAAa,gBAAgB,CAAC,CAAC,GAAG,GAAG,CAAE,YAAW,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC;IAC3D,OAAO,CAAC,YAAY;gBAAZ,YAAY,EAAE,CAAC;IAE7B,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,CAAC,CAAC;CAMlE;AAED;;;;;GAKG;AACH,qBAAa,QAAS,YAAW,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC;IAC1D,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;CAM5E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,eAAgB,SAAQ,cAAc;;CA6BlD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,eAAgB,SAAQ,cAAc;;CAsBlD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,iBAAkB,SAAQ,cAAc;;CAgCpD"}
|
|
@@ -60,7 +60,7 @@ export async function executePipes(pipes, value, metadata) {
|
|
|
60
60
|
* create(@Body() dto: CreateDto) {}
|
|
61
61
|
*
|
|
62
62
|
* @example
|
|
63
|
-
* // Custom formatting
|
|
63
|
+
* // Custom formatting with detailed errors
|
|
64
64
|
* const customPipe = new ValidationPipe({
|
|
65
65
|
* exceptionFactory: (errors) => ({
|
|
66
66
|
* statusCode: 400,
|
|
@@ -92,7 +92,7 @@ export class ValidationPipe {
|
|
|
92
92
|
return value;
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
|
-
* Format
|
|
95
|
+
* Format WynkJS validation error
|
|
96
96
|
* Called by ValidationExceptionFilter
|
|
97
97
|
*/
|
|
98
98
|
formatError(exception) {
|
|
@@ -105,7 +105,7 @@ export class ValidationPipe {
|
|
|
105
105
|
return this.defaultFormatError(validationError);
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
|
-
* Parse validation error from
|
|
108
|
+
* Parse validation error from WynkJS exception
|
|
109
109
|
*/
|
|
110
110
|
parseValidationError(exception) {
|
|
111
111
|
let validationData;
|
|
@@ -288,7 +288,7 @@ export class TrimPipe {
|
|
|
288
288
|
}
|
|
289
289
|
/**
|
|
290
290
|
* FormatErrorPipe - Formats validation errors as { [field]: [messages] }
|
|
291
|
-
*
|
|
291
|
+
* Object format with field names as keys
|
|
292
292
|
*
|
|
293
293
|
* @example
|
|
294
294
|
* // In index.ts or controller
|
package/dist/dto.js
CHANGED
package/dist/factory.d.ts
CHANGED
|
@@ -1,31 +1,43 @@
|
|
|
1
1
|
import { Elysia } from "elysia";
|
|
2
2
|
import "reflect-metadata";
|
|
3
|
-
import { ErrorFormatter } from "./decorators/
|
|
3
|
+
import { ErrorFormatter } from "./decorators/formatter.decorators";
|
|
4
|
+
import { CorsOptions } from "./cors";
|
|
4
5
|
/**
|
|
5
6
|
* Application Factory for WynkJS Framework
|
|
6
7
|
* Creates and configures Elysia app with all decorators support
|
|
7
8
|
*/
|
|
8
9
|
export interface ApplicationOptions {
|
|
9
|
-
cors?: boolean |
|
|
10
|
+
cors?: boolean | CorsOptions;
|
|
10
11
|
globalPrefix?: string;
|
|
11
12
|
logger?: boolean;
|
|
12
13
|
validationErrorFormatter?: ErrorFormatter;
|
|
14
|
+
providers?: any[];
|
|
13
15
|
}
|
|
14
16
|
export declare class WynkFramework {
|
|
15
17
|
private app;
|
|
16
18
|
private controllers;
|
|
19
|
+
private providers;
|
|
17
20
|
private globalGuards;
|
|
18
21
|
private globalInterceptors;
|
|
19
22
|
private globalPipes;
|
|
20
23
|
private globalFilters;
|
|
21
24
|
private validationFormatter?;
|
|
25
|
+
private shutdownHandlersRegistered;
|
|
26
|
+
private globalPrefix?;
|
|
27
|
+
private isBuilt;
|
|
22
28
|
constructor(options?: ApplicationOptions);
|
|
23
29
|
/**
|
|
24
30
|
* Static convenience creator to align with documentation examples
|
|
25
31
|
*/
|
|
26
32
|
static create(options?: ApplicationOptions & {
|
|
27
33
|
controllers?: any[];
|
|
34
|
+
providers?: any[];
|
|
28
35
|
}): WynkFramework;
|
|
36
|
+
/**
|
|
37
|
+
* Register providers with the application
|
|
38
|
+
* Providers are singleton services that are initialized when the app starts
|
|
39
|
+
*/
|
|
40
|
+
registerProviders(...providers: any[]): this;
|
|
29
41
|
/**
|
|
30
42
|
* Register controllers with the application
|
|
31
43
|
*/
|
|
@@ -46,10 +58,20 @@ export declare class WynkFramework {
|
|
|
46
58
|
* Register global exception filters
|
|
47
59
|
*/
|
|
48
60
|
useGlobalFilters(...filters: any[]): this;
|
|
61
|
+
/**
|
|
62
|
+
* Initialize all registered providers
|
|
63
|
+
* Providers with onModuleInit() method will be called
|
|
64
|
+
*/
|
|
65
|
+
private initializeProviders;
|
|
49
66
|
/**
|
|
50
67
|
* Build the application - register all routes
|
|
51
68
|
*/
|
|
52
69
|
build(): Promise<Elysia>;
|
|
70
|
+
/**
|
|
71
|
+
* Cleanup all providers when app shuts down
|
|
72
|
+
* Providers with onModuleDestroy() method will be called
|
|
73
|
+
*/
|
|
74
|
+
private destroyProviders;
|
|
53
75
|
/**
|
|
54
76
|
* Start listening on a port
|
|
55
77
|
*/
|
|
@@ -58,6 +80,11 @@ export declare class WynkFramework {
|
|
|
58
80
|
* Get the underlying Elysia instance
|
|
59
81
|
*/
|
|
60
82
|
getApp(): Elysia;
|
|
83
|
+
/**
|
|
84
|
+
* Handle an HTTP request
|
|
85
|
+
* Automatically builds the app if not already built
|
|
86
|
+
*/
|
|
87
|
+
handle(request: Request): Promise<Response>;
|
|
61
88
|
/**
|
|
62
89
|
* Register a single controller
|
|
63
90
|
*/
|
|
@@ -73,6 +100,7 @@ export declare function createApp(options?: ApplicationOptions): WynkFramework;
|
|
|
73
100
|
export declare class WynkFactory {
|
|
74
101
|
static create(options?: ApplicationOptions & {
|
|
75
102
|
controllers?: any[];
|
|
103
|
+
providers?: any[];
|
|
76
104
|
}): WynkFramework;
|
|
77
105
|
}
|
|
78
106
|
export { WynkFramework as ElysiaFramework };
|
package/dist/factory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../core/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,kBAAkB,CAAC;AAc1B,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../core/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,kBAAkB,CAAC;AAc1B,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAa,MAAM,QAAQ,CAAC;AAOhD;;;GAGG;AAEH,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,wBAAwB,CAAC,EAAE,cAAc,CAAC;IAC1C,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC;CACnB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO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