@lerianstudio/sindarian-server 1.0.0-beta.1 → 1.0.0-beta.12
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 +367 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +1 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/constants/keys.d.ts +5 -0
- package/dist/constants/keys.d.ts.map +1 -1
- package/dist/constants/keys.js +6 -1
- package/dist/constants/keys.js.map +1 -1
- package/dist/constants/scopes.d.ts +6 -0
- package/dist/constants/scopes.d.ts.map +1 -0
- package/dist/constants/scopes.js +10 -0
- package/dist/constants/scopes.js.map +1 -0
- package/dist/context/arguments-host.d.ts +14 -0
- package/dist/context/arguments-host.d.ts.map +1 -0
- package/dist/context/arguments-host.js +28 -0
- package/dist/context/arguments-host.js.map +1 -0
- package/dist/context/execution-context.d.ts +10 -0
- package/dist/context/execution-context.d.ts.map +1 -0
- package/dist/context/execution-context.js +19 -0
- package/dist/context/execution-context.js.map +1 -0
- package/dist/context/http-arguments-host.d.ts +8 -0
- package/dist/context/http-arguments-host.d.ts.map +1 -0
- package/dist/context/http-arguments-host.js +17 -0
- package/dist/context/http-arguments-host.js.map +1 -0
- package/dist/context/index.d.ts +4 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +20 -0
- package/dist/context/index.js.map +1 -0
- package/dist/controllers/base-controller.d.ts +0 -2
- package/dist/controllers/base-controller.d.ts.map +1 -1
- package/dist/controllers/base-controller.js +0 -15
- package/dist/controllers/base-controller.js.map +1 -1
- package/dist/controllers/decorators/body-decorator.d.ts +12 -17
- package/dist/controllers/decorators/body-decorator.d.ts.map +1 -1
- package/dist/controllers/decorators/body-decorator.js +55 -43
- package/dist/controllers/decorators/body-decorator.js.map +1 -1
- package/dist/controllers/decorators/controller-decorator.d.ts +5 -8
- package/dist/controllers/decorators/controller-decorator.d.ts.map +1 -1
- package/dist/controllers/decorators/controller-decorator.js +30 -66
- package/dist/controllers/decorators/controller-decorator.js.map +1 -1
- package/dist/controllers/decorators/param-decorator.d.ts +4 -9
- package/dist/controllers/decorators/param-decorator.d.ts.map +1 -1
- package/dist/controllers/decorators/param-decorator.js +33 -29
- package/dist/controllers/decorators/param-decorator.js.map +1 -1
- package/dist/controllers/decorators/query-decorator.d.ts +11 -15
- package/dist/controllers/decorators/query-decorator.d.ts.map +1 -1
- package/dist/controllers/decorators/query-decorator.js +24 -38
- package/dist/controllers/decorators/query-decorator.js.map +1 -1
- package/dist/controllers/decorators/request-decorator.d.ts +8 -12
- package/dist/controllers/decorators/request-decorator.d.ts.map +1 -1
- package/dist/controllers/decorators/request-decorator.js +21 -17
- package/dist/controllers/decorators/request-decorator.js.map +1 -1
- package/dist/controllers/decorators/route-decorator.d.ts +12 -1
- package/dist/controllers/decorators/route-decorator.d.ts.map +1 -1
- package/dist/controllers/decorators/route-decorator.js +24 -16
- package/dist/controllers/decorators/route-decorator.js.map +1 -1
- package/dist/dependency-injection/container.js +1 -1
- package/dist/dependency-injection/container.js.map +1 -1
- package/dist/dependency-injection/index.d.ts +2 -1
- package/dist/dependency-injection/index.d.ts.map +1 -1
- package/dist/dependency-injection/index.js +3 -2
- package/dist/dependency-injection/index.js.map +1 -1
- package/dist/dependency-injection/injectable-decorator.d.ts +7 -0
- package/dist/dependency-injection/injectable-decorator.d.ts.map +1 -0
- package/dist/dependency-injection/injectable-decorator.js +21 -0
- package/dist/dependency-injection/injectable-decorator.js.map +1 -0
- package/dist/exceptions/api-exception.d.ts +4 -7
- package/dist/exceptions/api-exception.d.ts.map +1 -1
- package/dist/exceptions/api-exception.js +8 -4
- package/dist/exceptions/api-exception.js.map +1 -1
- package/dist/exceptions/base-exception-filter.d.ts +8 -0
- package/dist/exceptions/base-exception-filter.d.ts.map +1 -0
- package/dist/exceptions/base-exception-filter.js +21 -0
- package/dist/exceptions/base-exception-filter.js.map +1 -0
- package/dist/exceptions/decorators/catch-decorator.d.ts +8 -0
- package/dist/exceptions/decorators/catch-decorator.d.ts.map +1 -0
- package/dist/exceptions/decorators/catch-decorator.js +14 -0
- package/dist/exceptions/decorators/catch-decorator.js.map +1 -0
- package/dist/exceptions/decorators/index.d.ts +3 -0
- package/dist/exceptions/decorators/index.d.ts.map +1 -0
- package/dist/exceptions/decorators/index.js +8 -0
- package/dist/exceptions/decorators/index.js.map +1 -0
- package/dist/exceptions/decorators/use-filters-decorator.d.ts +15 -0
- package/dist/exceptions/decorators/use-filters-decorator.d.ts.map +1 -0
- package/dist/exceptions/decorators/use-filters-decorator.js +47 -0
- package/dist/exceptions/decorators/use-filters-decorator.js.map +1 -0
- package/dist/exceptions/exception-filter.d.ts +6 -0
- package/dist/exceptions/exception-filter.d.ts.map +1 -0
- package/dist/exceptions/exception-filter.js +7 -0
- package/dist/exceptions/exception-filter.js.map +1 -0
- package/dist/exceptions/index.d.ts +3 -0
- package/dist/exceptions/index.d.ts.map +1 -1
- package/dist/exceptions/index.js +3 -0
- package/dist/exceptions/index.js.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/interceptor/call-handler.d.ts +4 -0
- package/dist/interceptor/call-handler.d.ts.map +1 -0
- package/dist/interceptor/call-handler.js +3 -0
- package/dist/interceptor/call-handler.js.map +1 -0
- package/dist/interceptor/decorators/index.d.ts +2 -0
- package/dist/interceptor/decorators/index.d.ts.map +1 -0
- package/dist/interceptor/decorators/index.js +6 -0
- package/dist/interceptor/decorators/index.js.map +1 -0
- package/dist/interceptor/decorators/use-interceptor-decorator.d.ts +15 -0
- package/dist/interceptor/decorators/use-interceptor-decorator.d.ts.map +1 -0
- package/dist/interceptor/decorators/use-interceptor-decorator.js +76 -0
- package/dist/interceptor/decorators/use-interceptor-decorator.js.map +1 -0
- package/dist/interceptor/index.d.ts +4 -0
- package/dist/interceptor/index.d.ts.map +1 -0
- package/dist/interceptor/index.js +20 -0
- package/dist/interceptor/index.js.map +1 -0
- package/dist/interceptor/interceptor.d.ts +3 -5
- package/dist/interceptor/interceptor.d.ts.map +1 -1
- package/dist/interceptor/interceptor.js.map +1 -1
- package/dist/logger/console-logger.d.ts +24 -0
- package/dist/logger/console-logger.d.ts.map +1 -0
- package/dist/logger/console-logger.js +78 -0
- package/dist/logger/console-logger.js.map +1 -0
- package/dist/logger/index.d.ts +4 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js +8 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/logger/logger-service.d.ts +34 -0
- package/dist/logger/logger-service.d.ts.map +1 -0
- package/dist/logger/logger-service.js +12 -0
- package/dist/logger/logger-service.js.map +1 -0
- package/dist/logger/logger.d.ts +21 -0
- package/dist/logger/logger.d.ts.map +1 -0
- package/dist/logger/logger.js +86 -0
- package/dist/logger/logger.js.map +1 -0
- package/dist/modules/module-decorator.d.ts +5 -3
- package/dist/modules/module-decorator.d.ts.map +1 -1
- package/dist/modules/module-decorator.js +78 -24
- package/dist/modules/module-decorator.js.map +1 -1
- package/dist/pipes/decorators/index.d.ts +2 -0
- package/dist/pipes/decorators/index.d.ts.map +1 -0
- package/dist/pipes/decorators/index.js +6 -0
- package/dist/pipes/decorators/index.js.map +1 -0
- package/dist/pipes/decorators/use-pipes.d.ts +19 -0
- package/dist/pipes/decorators/use-pipes.d.ts.map +1 -0
- package/dist/pipes/decorators/use-pipes.js +118 -0
- package/dist/pipes/decorators/use-pipes.js.map +1 -0
- package/dist/pipes/index.d.ts +3 -0
- package/dist/pipes/index.d.ts.map +1 -0
- package/dist/pipes/index.js +18 -0
- package/dist/pipes/index.js.map +1 -0
- package/dist/pipes/pipe-transform.d.ts +46 -0
- package/dist/pipes/pipe-transform.d.ts.map +1 -0
- package/dist/pipes/pipe-transform.js +3 -0
- package/dist/pipes/pipe-transform.js.map +1 -0
- package/dist/server/server-factory.d.ts +23 -6
- package/dist/server/server-factory.d.ts.map +1 -1
- package/dist/server/server-factory.js +114 -48
- package/dist/server/server-factory.js.map +1 -1
- package/dist/services/filters.d.ts +2 -0
- package/dist/services/filters.d.ts.map +1 -0
- package/dist/services/filters.js +5 -0
- package/dist/services/filters.js.map +1 -0
- package/dist/services/http-service.d.ts +68 -0
- package/dist/services/http-service.d.ts.map +1 -0
- package/dist/services/http-service.js +233 -0
- package/dist/services/http-service.js.map +1 -0
- package/dist/services/interceptor.d.ts +2 -0
- package/dist/services/interceptor.d.ts.map +1 -0
- package/dist/services/interceptor.js +5 -0
- package/dist/services/interceptor.js.map +1 -0
- package/dist/services/pipes.d.ts +2 -0
- package/dist/services/pipes.d.ts.map +1 -0
- package/dist/services/pipes.js +5 -0
- package/dist/services/pipes.js.map +1 -0
- package/dist/utils/form-data/get-form-data.d.ts +2 -0
- package/dist/utils/form-data/get-form-data.d.ts.map +1 -0
- package/dist/utils/form-data/get-form-data.js +11 -0
- package/dist/utils/form-data/get-form-data.js.map +1 -0
- package/dist/utils/search/create-query-string.d.ts +9 -0
- package/dist/utils/search/create-query-string.d.ts.map +1 -0
- package/dist/utils/search/create-query-string.js +26 -0
- package/dist/utils/search/create-query-string.js.map +1 -0
- package/dist/zod/create-zod-dto.d.ts +16 -0
- package/dist/zod/create-zod-dto.d.ts.map +1 -0
- package/dist/zod/create-zod-dto.js +14 -0
- package/dist/zod/create-zod-dto.js.map +1 -0
- package/dist/zod/index.d.ts +3 -0
- package/dist/zod/index.d.ts.map +1 -0
- package/dist/zod/index.js +8 -0
- package/dist/zod/index.js.map +1 -0
- package/dist/zod/zod-validation-pipe.d.ts +5 -0
- package/dist/zod/zod-validation-pipe.d.ts.map +1 -0
- package/dist/zod/zod-validation-pipe.js +35 -0
- package/dist/zod/zod-validation-pipe.js.map +1 -0
- package/package.json +7 -6
- package/dist/interceptor/decorators/use-interceptor.d.ts +0 -3
- package/dist/interceptor/decorators/use-interceptor.d.ts.map +0 -1
- package/dist/interceptor/decorators/use-interceptor.js +0 -9
- package/dist/interceptor/decorators/use-interceptor.js.map +0 -1
|
@@ -4,7 +4,12 @@ exports.moduleHandler = moduleHandler;
|
|
|
4
4
|
exports.Module = Module;
|
|
5
5
|
const container_1 = require("../dependency-injection/container");
|
|
6
6
|
const keys_1 = require("../constants/keys");
|
|
7
|
+
const scopes_1 = require("../constants/scopes");
|
|
7
8
|
const controller_decorator_1 = require("../controllers/decorators/controller-decorator");
|
|
9
|
+
const use_interceptor_decorator_1 = require("../interceptor/decorators/use-interceptor-decorator");
|
|
10
|
+
const logger_1 = require("../logger/logger");
|
|
11
|
+
const use_pipes_1 = require("../pipes/decorators/use-pipes");
|
|
12
|
+
const use_filters_decorator_1 = require("../exceptions/decorators/use-filters-decorator");
|
|
8
13
|
function moduleHandler(target, visited = new Set()) {
|
|
9
14
|
// Prevent infinite recursion by tracking visited modules
|
|
10
15
|
if (visited.has(target)) {
|
|
@@ -21,10 +26,11 @@ function moduleHandler(target, visited = new Set()) {
|
|
|
21
26
|
}
|
|
22
27
|
if (controllers) {
|
|
23
28
|
for (const controller of controllers) {
|
|
24
|
-
const controllerRoutes =
|
|
29
|
+
const controllerRoutes = controller_decorator_1.ControllerHandler.getRoutes(controller).map((route) => ({
|
|
25
30
|
...route,
|
|
26
31
|
controller
|
|
27
32
|
}));
|
|
33
|
+
logger_1.Logger.log(`Registered ${controllerRoutes.length} routes for controller ${controller.name}`);
|
|
28
34
|
routes.push(...controllerRoutes);
|
|
29
35
|
}
|
|
30
36
|
}
|
|
@@ -41,32 +47,16 @@ function Module(options) {
|
|
|
41
47
|
});
|
|
42
48
|
}
|
|
43
49
|
if (providers) {
|
|
44
|
-
providers.forEach((
|
|
45
|
-
if (typeof providerEntity === 'object') {
|
|
46
|
-
if (providerEntity.useClass) {
|
|
47
|
-
container.bind(providerEntity.provide).to(providerEntity.useClass);
|
|
48
|
-
}
|
|
49
|
-
else if (providerEntity.useFactory) {
|
|
50
|
-
container
|
|
51
|
-
.bind(providerEntity.provide)
|
|
52
|
-
.toDynamicValue(async (context) => {
|
|
53
|
-
return await providerEntity.useFactory(context);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
else if (providerEntity.useValue) {
|
|
57
|
-
container
|
|
58
|
-
.bind(providerEntity.provide)
|
|
59
|
-
.toConstantValue(providerEntity.useValue);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
container.bind(providerEntity).to(providerEntity);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
50
|
+
providers.forEach((provider) => registerProvider(container, provider));
|
|
66
51
|
}
|
|
67
52
|
if (controllers) {
|
|
68
53
|
controllers.forEach((controller) => {
|
|
69
|
-
|
|
54
|
+
// Bind the controller
|
|
55
|
+
container.bind(controller).to(controller).inSingletonScope();
|
|
56
|
+
// Bind other related decorators
|
|
57
|
+
use_interceptor_decorator_1.InterceptorHandler.register(container, controller);
|
|
58
|
+
use_pipes_1.PipeHandler.register(container, controller);
|
|
59
|
+
use_filters_decorator_1.FilterHandler.register(container, controller);
|
|
70
60
|
});
|
|
71
61
|
}
|
|
72
62
|
});
|
|
@@ -83,4 +73,68 @@ function Module(options) {
|
|
|
83
73
|
prototype[keys_1.CONTROLLERS_PROPERTY] = controllers;
|
|
84
74
|
};
|
|
85
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Register a provider in the container
|
|
78
|
+
* @param container
|
|
79
|
+
* @param provider
|
|
80
|
+
*/
|
|
81
|
+
function registerProvider(container, provider) {
|
|
82
|
+
// Checks if provider is a object with options
|
|
83
|
+
if (typeof provider === 'object') {
|
|
84
|
+
registerProviderObject(container, provider);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
// If not, it's a simple class type
|
|
88
|
+
container.bind(provider).to(provider);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Registers a provider object in the container
|
|
93
|
+
* @param container
|
|
94
|
+
* @param provider
|
|
95
|
+
* @returns
|
|
96
|
+
*/
|
|
97
|
+
function registerProviderObject(container, provider) {
|
|
98
|
+
// Protect the method by avoid non objects
|
|
99
|
+
if (typeof provider !== 'object') {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const { provide, useClass, useValue, useFactory, scope } = provider;
|
|
103
|
+
const bind = container.bind(provide);
|
|
104
|
+
if (useClass) {
|
|
105
|
+
registerScope(bind.to(useClass), scope);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (useFactory) {
|
|
109
|
+
registerScope(bind.toDynamicValue(async (context) => {
|
|
110
|
+
return await useFactory(context);
|
|
111
|
+
}), scope);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (useValue) {
|
|
115
|
+
bind.toConstantValue(useValue);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const message = `Module: Invalid provider ${provider.provide.toString()} configuration`;
|
|
119
|
+
logger_1.Logger.error(message);
|
|
120
|
+
throw new Error(message);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Registers a scope for a binding
|
|
124
|
+
* @param bind
|
|
125
|
+
* @param scope
|
|
126
|
+
* @returns
|
|
127
|
+
*/
|
|
128
|
+
function registerScope(bind, scope) {
|
|
129
|
+
switch (scope) {
|
|
130
|
+
case scopes_1.Scope.DEFAULT:
|
|
131
|
+
return bind.inSingletonScope();
|
|
132
|
+
case scopes_1.Scope.REQUEST:
|
|
133
|
+
return bind.inRequestScope();
|
|
134
|
+
case scopes_1.Scope.TRANSIENT:
|
|
135
|
+
return bind.inTransientScope();
|
|
136
|
+
default:
|
|
137
|
+
return bind.inSingletonScope();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
86
140
|
//# sourceMappingURL=module-decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-decorator.js","sourceRoot":"","sources":["../../src/modules/module-decorator.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"module-decorator.js","sourceRoot":"","sources":["../../src/modules/module-decorator.ts"],"names":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E,CAAC;QACb,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAA;QAC9B,OAAM;IACR,CAAC;IAED,MAAM,OAAO,GAAG,4BAA4B,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,gBAAgB,CAAA;IACvF,eAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACrB,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;AAC1B,CAAC;AAED;;;;;GAKG;AACH,SAAS,aAAa,CAAI,IAA2B,EAAE,KAAa;IAClE,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,cAAK,CAAC,OAAO;YAChB,OAAO,IAAI,CAAC,gBAAgB,EAAE,CAAA;QAChC,KAAK,cAAK,CAAC,OAAO;YAChB,OAAO,IAAI,CAAC,cAAc,EAAE,CAAA;QAC9B,KAAK,cAAK,CAAC,SAAS;YAClB,OAAO,IAAI,CAAC,gBAAgB,EAAE,CAAA;QAChC;YACE,OAAO,IAAI,CAAC,gBAAgB,EAAE,CAAA;IAClC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pipes/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UsePipes = void 0;
|
|
4
|
+
var use_pipes_1 = require("./use-pipes");
|
|
5
|
+
Object.defineProperty(exports, "UsePipes", { enumerable: true, get: function () { return use_pipes_1.UsePipes; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pipes/decorators/index.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AAA7B,qGAAA,QAAQ,OAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PipeTransform } from '../pipe-transform';
|
|
2
|
+
import { Class } from '../../types/class';
|
|
3
|
+
import { RouteContext } from '../../controllers/decorators/route-decorator';
|
|
4
|
+
import { Container } from '../../dependency-injection';
|
|
5
|
+
type PipeMetadata = {
|
|
6
|
+
pipes: (Class<PipeTransform> | PipeTransform)[];
|
|
7
|
+
};
|
|
8
|
+
export declare class PipeHandler {
|
|
9
|
+
static getClassMetadata(target: object): PipeMetadata | undefined;
|
|
10
|
+
static getMethodMetadata(target: object, propertyKey: string | symbol): PipeMetadata | undefined;
|
|
11
|
+
static register(container: Container, target: Class): void;
|
|
12
|
+
static fetch(container: Container, target: object, methodName: string | symbol): Promise<PipeTransform[]>;
|
|
13
|
+
static execute(target: object, propertyKey: string | symbol, pipes: PipeTransform[], args: RouteContext[]): Promise<any[]>;
|
|
14
|
+
private static _fetch;
|
|
15
|
+
private static _register;
|
|
16
|
+
}
|
|
17
|
+
export declare function UsePipes(...pipes: (Class<PipeTransform> | PipeTransform)[]): (target: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor) => void;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=use-pipes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-pipes.d.ts","sourceRoot":"","sources":["../../../src/pipes/decorators/use-pipes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAErC,OAAO,EACL,YAAY,EAEb,MAAM,0CAA0C,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAElD,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,aAAa,CAAC,EAAE,CAAA;CAChD,CAAA;AAED,qBAAa,WAAW;IACtB,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAIjE,MAAM,CAAC,iBAAiB,CACtB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,YAAY,GAAG,SAAS;IAgB3B,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK;WA4BtC,KAAK,CAChB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,GAAG,MAAM,GAC1B,OAAO,CAAC,aAAa,EAAE,CAAC;WA2Bd,OAAO,CAClB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,KAAK,EAAE,aAAa,EAAE,EACtB,IAAI,EAAE,YAAY,EAAE,GACnB,OAAO,CAAC,GAAG,EAAE,CAAC;mBAmCI,MAAM;mBAUN,SAAS;CAc/B;AAED,wBAAgB,QAAQ,CAAC,GAAG,KAAK,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,aAAa,CAAC,EAAE,IAEvE,QAAQ,GAAG,EACX,cAAc,MAAM,GAAG,MAAM,EAC7B,aAAa,kBAAkB,UA0BlC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PipeHandler = void 0;
|
|
4
|
+
exports.UsePipes = UsePipes;
|
|
5
|
+
const keys_1 = require("../../constants/keys");
|
|
6
|
+
const get_class_methods_1 = require("../../utils/class/get-class-methods");
|
|
7
|
+
const route_decorator_1 = require("../../controllers/decorators/route-decorator");
|
|
8
|
+
class PipeHandler {
|
|
9
|
+
static getClassMetadata(target) {
|
|
10
|
+
return Reflect.getOwnMetadata(keys_1.PIPE_KEY, target);
|
|
11
|
+
}
|
|
12
|
+
static getMethodMetadata(target, propertyKey) {
|
|
13
|
+
// First check if metadata exists directly on the target (method-level decorator)
|
|
14
|
+
let metadata = Reflect.getOwnMetadata(keys_1.PIPE_KEY, target, propertyKey);
|
|
15
|
+
// If not found, check on the constructor prototype (class-level decorator)
|
|
16
|
+
if (!metadata && target.constructor) {
|
|
17
|
+
metadata = Reflect.getOwnMetadata(keys_1.PIPE_KEY, target.constructor.prototype, propertyKey);
|
|
18
|
+
}
|
|
19
|
+
return metadata;
|
|
20
|
+
}
|
|
21
|
+
static register(container, target) {
|
|
22
|
+
const metadata = PipeHandler.getClassMetadata(target);
|
|
23
|
+
if (metadata && metadata?.pipes?.length !== 0) {
|
|
24
|
+
const { pipes } = metadata;
|
|
25
|
+
pipes.forEach((pipe) => {
|
|
26
|
+
PipeHandler._register(container, pipe);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
// Register methods pipes
|
|
30
|
+
const methodNames = (0, get_class_methods_1.getClassMethods)(target);
|
|
31
|
+
methodNames.forEach((methodName) => {
|
|
32
|
+
const methodMetadata = Reflect.getOwnMetadata(keys_1.PIPE_KEY, target.prototype, methodName);
|
|
33
|
+
if (methodMetadata) {
|
|
34
|
+
methodMetadata.pipes.forEach((pipe) => {
|
|
35
|
+
PipeHandler._register(container, pipe);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
static async fetch(container, target, methodName) {
|
|
41
|
+
const pipes = [];
|
|
42
|
+
const metadata = PipeHandler.getClassMetadata(target.constructor);
|
|
43
|
+
if (metadata && metadata.pipes.length > 0) {
|
|
44
|
+
pipes.push(...(await Promise.all(metadata.pipes.map((pipe) => PipeHandler._fetch(container, pipe)))));
|
|
45
|
+
}
|
|
46
|
+
const methodMetadata = PipeHandler.getMethodMetadata(target, methodName);
|
|
47
|
+
if (methodMetadata) {
|
|
48
|
+
pipes.push(...(await Promise.all(methodMetadata.pipes.map((pipe) => PipeHandler._fetch(container, pipe)))));
|
|
49
|
+
}
|
|
50
|
+
return pipes;
|
|
51
|
+
}
|
|
52
|
+
static async execute(target, propertyKey, pipes, args) {
|
|
53
|
+
const metadata = route_decorator_1.RouteHandler.getMetadata(target.constructor, propertyKey);
|
|
54
|
+
if (pipes.length === 0) {
|
|
55
|
+
return args;
|
|
56
|
+
}
|
|
57
|
+
// Get paramTypes from route metadata (which contains the method parameter types)
|
|
58
|
+
const paramTypes = metadata?.paramTypes || [];
|
|
59
|
+
const pipedArgs = await Promise.all(args.map(async (arg) => {
|
|
60
|
+
// Get the parameter type for this argument - prefer arg.paramType over paramTypes array
|
|
61
|
+
const metatype = arg.paramType || paramTypes[arg.parameterIndex];
|
|
62
|
+
// Process through pipes (pipes parameter contains resolved instances)
|
|
63
|
+
let result = arg.parameter;
|
|
64
|
+
for (const pipe of pipes) {
|
|
65
|
+
result = await pipe.transform(result, {
|
|
66
|
+
type: arg.type || 'custom',
|
|
67
|
+
metatype: metatype,
|
|
68
|
+
data: arg.parameter
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
...arg,
|
|
73
|
+
parameter: result
|
|
74
|
+
};
|
|
75
|
+
}));
|
|
76
|
+
return pipedArgs.map((arg) => arg.parameter);
|
|
77
|
+
}
|
|
78
|
+
static async _fetch(container, pipe) {
|
|
79
|
+
if (typeof pipe === 'function') {
|
|
80
|
+
return container.getAsync(pipe);
|
|
81
|
+
}
|
|
82
|
+
return container.getAsync(pipe.constructor);
|
|
83
|
+
}
|
|
84
|
+
static async _register(container, pipe) {
|
|
85
|
+
// If it's a class constructor (function), register it in the container
|
|
86
|
+
if (typeof pipe === 'function') {
|
|
87
|
+
if (!container.isBound(pipe)) {
|
|
88
|
+
container.bind(pipe).toSelf().inSingletonScope();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
// If it's an instance, bind it to its constructor class as a constant value
|
|
93
|
+
container.bind(pipe.constructor).toConstantValue(pipe);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.PipeHandler = PipeHandler;
|
|
98
|
+
function UsePipes(...pipes) {
|
|
99
|
+
return (target, propertyKey, descriptor) => {
|
|
100
|
+
if (descriptor && propertyKey) {
|
|
101
|
+
// Method decorator
|
|
102
|
+
Reflect.defineMetadata(keys_1.PIPE_KEY, { pipes }, target, propertyKey);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// Class decorator
|
|
107
|
+
const methodNames = (0, get_class_methods_1.getClassMethods)(target);
|
|
108
|
+
// Store class-level pipes metadata
|
|
109
|
+
Reflect.defineMetadata(keys_1.PIPE_KEY, { pipes, paramTypes: [] }, target);
|
|
110
|
+
// Process each method and store its paramTypes
|
|
111
|
+
methodNames.forEach((methodName) => {
|
|
112
|
+
// Store method-specific metadata with class pipes and method paramTypes
|
|
113
|
+
Reflect.defineMetadata(keys_1.PIPE_KEY, { pipes }, target.prototype, methodName);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=use-pipes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-pipes.js","sourceRoot":"","sources":["../../../src/pipes/decorators/use-pipes.ts"],"names":[],"mappings":";;;AAmKA,4BA8BC;AAjMD,2CAA2C;AAG3C,uEAAiE;AACjE,8EAGiD;AAOjD,MAAa,WAAW;IACtB,MAAM,CAAC,gBAAgB,CAAC,MAAc;QACpC,OAAO,OAAO,CAAC,cAAc,CAAC,eAAQ,EAAE,MAAM,CAAC,CAAA;IACjD,CAAC;IAED,MAAM,CAAC,iBAAiB,CACtB,MAAc,EACd,WAA4B;QAE5B,iFAAiF;QACjF,IAAI,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,eAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,CAAA;QAEpE,2EAA2E;QAC3E,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;YACpC,QAAQ,GAAG,OAAO,CAAC,cAAc,CAC/B,eAAQ,EACR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AAO,CACL,MAAW,EACX,WAA6B,EAC7B,UAA+B,EAC/B,EAAE;QACF,IAAI,UAAU,IAAI,WAAW,EAAE,CAAC;YAC9B,mBAAmB;YACnB,OAAO,CAAC,cAAc,CAAC,eAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,CAAA;YAEhE,OAAM;QACR,CAAC;aAAM,CAAC;YACN,kBAAkB;YAClB,MAAM,WAAW,GAAG,IAAA,mCAAe,EAAC,MAAM,CAAC,CAAA;YAE3C,mCAAmC;YACnC,OAAO,CAAC,cAAc,CAAC,eAAQ,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,CAAA;YAEnE,+CAA+C;YAC/C,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;gBACjC,wEAAwE;gBACxE,OAAO,CAAC,cAAc,CACpB,eAAQ,EACR,EAAE,KAAK,EAAE,EACT,MAAM,CAAC,SAAS,EAChB,UAAU,CACX,CAAA;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pipes/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./decorators"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pipes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Class } from '../types/class';
|
|
2
|
+
/**
|
|
3
|
+
* @publicApi
|
|
4
|
+
*/
|
|
5
|
+
export type Paramtype = 'body' | 'query' | 'param' | 'custom';
|
|
6
|
+
export type Transform<T = any> = (value: T, metadata: ArgumentMetadata) => any;
|
|
7
|
+
/**
|
|
8
|
+
* Interface describing a pipe implementation's `transform()` method metadata argument.
|
|
9
|
+
*
|
|
10
|
+
* @see [Pipes](https://docs.nestjs.com/pipes)
|
|
11
|
+
*
|
|
12
|
+
* @publicApi
|
|
13
|
+
*/
|
|
14
|
+
export interface ArgumentMetadata {
|
|
15
|
+
/**
|
|
16
|
+
* Indicates whether argument is a body, query, param, or custom parameter
|
|
17
|
+
*/
|
|
18
|
+
readonly type: Paramtype;
|
|
19
|
+
/**
|
|
20
|
+
* Underlying base type (e.g., `String`) of the parameter, based on the type
|
|
21
|
+
* definition in the route handler.
|
|
22
|
+
*/
|
|
23
|
+
readonly metatype?: Class<any> | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* String passed as an argument to the decorator.
|
|
26
|
+
* Example: `@Body('userId')` would yield `userId`
|
|
27
|
+
*/
|
|
28
|
+
readonly data?: string | undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Interface describing implementation of a pipe.
|
|
32
|
+
*
|
|
33
|
+
* @see [Pipes](https://docs.nestjs.com/pipes)
|
|
34
|
+
*
|
|
35
|
+
* @publicApi
|
|
36
|
+
*/
|
|
37
|
+
export interface PipeTransform<T = any, R = any> {
|
|
38
|
+
/**
|
|
39
|
+
* Method to implement a custom pipe. Called with two parameters
|
|
40
|
+
*
|
|
41
|
+
* @param value argument before it is received by route handler method
|
|
42
|
+
* @param metadata contains metadata about the value
|
|
43
|
+
*/
|
|
44
|
+
transform(value: T, metadata: ArgumentMetadata): R;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=pipe-transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe-transform.d.ts","sourceRoot":"","sources":["../../src/pipes/pipe-transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAErC;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAA;AAE7D,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,gBAAgB,KAAK,GAAG,CAAA;AAE9E;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAA;IAC1C;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACnC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG;IAC7C;;;;;OAKG;IACH,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,gBAAgB,GAAG,CAAC,CAAA;CACnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe-transform.js","sourceRoot":"","sources":["../../src/pipes/pipe-transform.ts"],"names":[],"mappings":""}
|
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
import { Container } from '../dependency-injection/container';
|
|
2
|
+
import { ExceptionFilter } from '../exceptions/exception-filter';
|
|
3
|
+
import { Interceptor } from '../interceptor/interceptor';
|
|
2
4
|
import { ModuleMetadata } from '../modules/module-decorator';
|
|
3
5
|
import { Class } from '../types/class';
|
|
4
6
|
import { NextRequest } from 'next/server';
|
|
7
|
+
import { LoggerService } from '../logger/logger-service';
|
|
8
|
+
import { PipeTransform } from '../pipes/pipe-transform';
|
|
9
|
+
export type ServerFactoryOptions = {
|
|
10
|
+
logger?: LoggerService | boolean;
|
|
11
|
+
};
|
|
5
12
|
export declare class ServerFactory {
|
|
6
13
|
private globalPrefix;
|
|
14
|
+
private globalFilters;
|
|
15
|
+
private globalInterceptors;
|
|
16
|
+
private globalPipes;
|
|
7
17
|
private readonly module;
|
|
8
18
|
private readonly container;
|
|
9
19
|
private readonly routes;
|
|
10
20
|
constructor(module: Class, container: Container, routes: ModuleMetadata[]);
|
|
11
|
-
static create(module: Class): ServerFactory;
|
|
21
|
+
static create(module: Class, options?: ServerFactoryOptions): ServerFactory;
|
|
12
22
|
/**
|
|
13
23
|
* Set the global prefix for the server
|
|
14
24
|
* @param prefix - The global prefix to set
|
|
15
25
|
*/
|
|
16
26
|
setGlobalPrefix(prefix: string): void;
|
|
27
|
+
useGlobalFilters(...filters: ExceptionFilter[]): void;
|
|
28
|
+
useGlobalInterceptors(...interceptors: Interceptor[]): void;
|
|
29
|
+
useGlobalPipes(...pipes: PipeTransform[]): void;
|
|
17
30
|
/**
|
|
18
31
|
* Handle a request
|
|
19
32
|
* @param request - The request to handle
|
|
@@ -23,6 +36,7 @@ export declare class ServerFactory {
|
|
|
23
36
|
handler(request: NextRequest, { params }: {
|
|
24
37
|
params: Promise<any>;
|
|
25
38
|
}): Promise<any>;
|
|
39
|
+
private static _registerLogger;
|
|
26
40
|
/**
|
|
27
41
|
* Parse the request
|
|
28
42
|
* @param request - The request to parse
|
|
@@ -36,12 +50,15 @@ export declare class ServerFactory {
|
|
|
36
50
|
* @returns The route
|
|
37
51
|
*/
|
|
38
52
|
private _fetchRoute;
|
|
53
|
+
private _fetchInterceptors;
|
|
54
|
+
private _fetchHandler;
|
|
55
|
+
private _fetchExceptionFilters;
|
|
39
56
|
/**
|
|
40
|
-
*
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
43
|
-
* @returns
|
|
57
|
+
* Fetch the pipes for a controller method
|
|
58
|
+
* @param controller
|
|
59
|
+
* @param methodName
|
|
60
|
+
* @returns
|
|
44
61
|
*/
|
|
45
|
-
private
|
|
62
|
+
private _fetchPipes;
|
|
46
63
|
}
|
|
47
64
|
//# sourceMappingURL=server-factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-factory.d.ts","sourceRoot":"","sources":["../../src/server/server-factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server-factory.d.ts","sourceRoot":"","sources":["../../src/server/server-factory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAI5D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAiB,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAI1E,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAErC,OAAO,EAAE,WAAW,EAAgB,MAAM,aAAa,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAIvD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,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