node-honest 0.0.7 → 0.1.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/index.cjs +2185 -0
- package/dist/index.d.cts +1539 -0
- package/dist/index.d.ts +1539 -16
- package/dist/index.js +2116 -15
- package/package.json +12 -9
- package/dist/application/plugin-entries.d.ts +0 -13
- package/dist/application/plugin-entries.js +0 -38
- package/dist/application/startup-guide.d.ts +0 -4
- package/dist/application/startup-guide.js +0 -53
- package/dist/application-context.d.ts +0 -13
- package/dist/application-context.js +0 -22
- package/dist/application.d.ts +0 -34
- package/dist/application.js +0 -224
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.js +0 -1
- package/dist/components/layout.component.d.ts +0 -31
- package/dist/components/layout.component.js +0 -94
- package/dist/constants/index.d.ts +0 -2
- package/dist/constants/index.js +0 -2
- package/dist/constants/pipeline.constants.d.ts +0 -6
- package/dist/constants/pipeline.constants.js +0 -6
- package/dist/constants/version.constants.d.ts +0 -5
- package/dist/constants/version.constants.js +0 -5
- package/dist/decorators/controller.decorator.d.ts +0 -9
- package/dist/decorators/controller.decorator.js +0 -16
- package/dist/decorators/http-method.decorator.d.ts +0 -43
- package/dist/decorators/http-method.decorator.js +0 -44
- package/dist/decorators/index.d.ts +0 -11
- package/dist/decorators/index.js +0 -11
- package/dist/decorators/module.decorator.d.ts +0 -8
- package/dist/decorators/module.decorator.js +0 -12
- package/dist/decorators/mvc.decorator.d.ts +0 -26
- package/dist/decorators/mvc.decorator.js +0 -36
- package/dist/decorators/parameter.decorator.d.ts +0 -41
- package/dist/decorators/parameter.decorator.js +0 -59
- package/dist/decorators/service.decorator.d.ts +0 -6
- package/dist/decorators/service.decorator.js +0 -11
- package/dist/decorators/use-component.decorator.d.ts +0 -10
- package/dist/decorators/use-component.decorator.js +0 -19
- package/dist/decorators/use-filters.decorator.d.ts +0 -8
- package/dist/decorators/use-filters.decorator.js +0 -17
- package/dist/decorators/use-guards.decorator.d.ts +0 -9
- package/dist/decorators/use-guards.decorator.js +0 -18
- package/dist/decorators/use-middleware.decorator.d.ts +0 -9
- package/dist/decorators/use-middleware.decorator.js +0 -18
- package/dist/decorators/use-pipes.decorator.d.ts +0 -9
- package/dist/decorators/use-pipes.decorator.js +0 -18
- package/dist/di/container.d.ts +0 -34
- package/dist/di/container.js +0 -114
- package/dist/di/index.d.ts +0 -1
- package/dist/di/index.js +0 -1
- package/dist/errors/framework.error.d.ts +0 -19
- package/dist/errors/framework.error.js +0 -23
- package/dist/errors/index.d.ts +0 -1
- package/dist/errors/index.js +0 -1
- package/dist/handlers/error.handler.d.ts +0 -28
- package/dist/handlers/error.handler.js +0 -17
- package/dist/handlers/index.d.ts +0 -2
- package/dist/handlers/index.js +0 -2
- package/dist/handlers/not-found.handler.d.ts +0 -14
- package/dist/handlers/not-found.handler.js +0 -17
- package/dist/helpers/create-error-response.helper.d.ts +0 -25
- package/dist/helpers/create-error-response.helper.js +0 -90
- package/dist/helpers/create-http-method-decorator.helper.d.ts +0 -16
- package/dist/helpers/create-http-method-decorator.helper.js +0 -30
- package/dist/helpers/create-param-decorator.helper.d.ts +0 -16
- package/dist/helpers/create-param-decorator.helper.js +0 -60
- package/dist/helpers/index.d.ts +0 -3
- package/dist/helpers/index.js +0 -3
- package/dist/interfaces/application-context.interface.d.ts +0 -35
- package/dist/interfaces/application-context.interface.js +0 -1
- package/dist/interfaces/controller-options.interface.d.ts +0 -17
- package/dist/interfaces/controller-options.interface.js +0 -1
- package/dist/interfaces/di-container.interface.d.ts +0 -35
- package/dist/interfaces/di-container.interface.js +0 -1
- package/dist/interfaces/error-response.interface.d.ts +0 -13
- package/dist/interfaces/error-response.interface.js +0 -1
- package/dist/interfaces/filter.interface.d.ts +0 -20
- package/dist/interfaces/filter.interface.js +0 -1
- package/dist/interfaces/guard.interface.d.ts +0 -21
- package/dist/interfaces/guard.interface.js +0 -1
- package/dist/interfaces/handler-invocation.interface.d.ts +0 -10
- package/dist/interfaces/handler-invocation.interface.js +0 -1
- package/dist/interfaces/honest-options.interface.d.ts +0 -121
- package/dist/interfaces/honest-options.interface.js +0 -1
- package/dist/interfaces/http-method-options.interface.d.ts +0 -38
- package/dist/interfaces/http-method-options.interface.js +0 -1
- package/dist/interfaces/index.d.ts +0 -21
- package/dist/interfaces/index.js +0 -21
- package/dist/interfaces/logger.interface.d.ts +0 -23
- package/dist/interfaces/logger.interface.js +0 -1
- package/dist/interfaces/metadata-repository.interface.d.ts +0 -30
- package/dist/interfaces/metadata-repository.interface.js +0 -1
- package/dist/interfaces/middleware.interface.d.ts +0 -22
- package/dist/interfaces/middleware.interface.js +0 -1
- package/dist/interfaces/module-options.interface.d.ts +0 -18
- package/dist/interfaces/module-options.interface.js +0 -1
- package/dist/interfaces/parameter-metadata.interface.d.ts +0 -27
- package/dist/interfaces/parameter-metadata.interface.js +0 -1
- package/dist/interfaces/parameter-resolution.interface.d.ts +0 -14
- package/dist/interfaces/parameter-resolution.interface.js +0 -1
- package/dist/interfaces/pipe.interface.d.ts +0 -37
- package/dist/interfaces/pipe.interface.js +0 -1
- package/dist/interfaces/pipeline-context.interface.d.ts +0 -9
- package/dist/interfaces/pipeline-context.interface.js +0 -1
- package/dist/interfaces/plugin.interface.d.ts +0 -74
- package/dist/interfaces/plugin.interface.js +0 -1
- package/dist/interfaces/route-definition.interface.d.ts +0 -51
- package/dist/interfaces/route-definition.interface.js +0 -1
- package/dist/interfaces/route-info.interface.d.ts +0 -42
- package/dist/interfaces/route-info.interface.js +0 -1
- package/dist/interfaces/service-registry.interface.d.ts +0 -7
- package/dist/interfaces/service-registry.interface.js +0 -1
- package/dist/loggers/console.logger.d.ts +0 -7
- package/dist/loggers/console.logger.js +0 -21
- package/dist/loggers/index.d.ts +0 -2
- package/dist/loggers/index.js +0 -2
- package/dist/loggers/noop.logger.d.ts +0 -7
- package/dist/loggers/noop.logger.js +0 -8
- package/dist/managers/component.manager.d.ts +0 -48
- package/dist/managers/component.manager.js +0 -209
- package/dist/managers/handler.invoker.d.ts +0 -7
- package/dist/managers/handler.invoker.js +0 -37
- package/dist/managers/index.d.ts +0 -5
- package/dist/managers/index.js +0 -5
- package/dist/managers/parameter.resolver.d.ts +0 -13
- package/dist/managers/parameter.resolver.js +0 -57
- package/dist/managers/pipeline.executor.d.ts +0 -28
- package/dist/managers/pipeline.executor.js +0 -68
- package/dist/managers/route.manager.d.ts +0 -36
- package/dist/managers/route.manager.js +0 -147
- package/dist/registries/index.d.ts +0 -4
- package/dist/registries/index.js +0 -4
- package/dist/registries/metadata.registry.d.ts +0 -163
- package/dist/registries/metadata.registry.js +0 -250
- package/dist/registries/metadata.repository.d.ts +0 -30
- package/dist/registries/metadata.repository.js +0 -151
- package/dist/registries/route.registry.d.ts +0 -16
- package/dist/registries/route.registry.js +0 -46
- package/dist/registries/service.registry.d.ts +0 -8
- package/dist/registries/service.registry.js +0 -9
- package/dist/testing/create-controller-test-application.d.ts +0 -5
- package/dist/testing/create-controller-test-application.js +0 -11
- package/dist/testing/create-service-test-container.d.ts +0 -5
- package/dist/testing/create-service-test-container.js +0 -31
- package/dist/testing/create-test-application.d.ts +0 -5
- package/dist/testing/create-test-application.js +0 -20
- package/dist/testing/create-testing-module.d.ts +0 -6
- package/dist/testing/create-testing-module.js +0 -13
- package/dist/testing/fixtures/application-test-fixtures.d.ts +0 -17
- package/dist/testing/fixtures/application-test-fixtures.js +0 -230
- package/dist/testing/index.d.ts +0 -5
- package/dist/testing/index.js +0 -5
- package/dist/testing/testing.interface.d.ts +0 -96
- package/dist/testing/testing.interface.js +0 -1
- package/dist/types/constructor.type.d.ts +0 -12
- package/dist/types/constructor.type.js +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.js +0 -1
- package/dist/utils/common.util.d.ts +0 -117
- package/dist/utils/common.util.js +0 -140
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GET method decorator
|
|
3
|
-
* The GET method requests a representation of the specified resource.
|
|
4
|
-
* Requests using GET should only retrieve data and should not contain a request content.
|
|
5
|
-
* @param path - The route path
|
|
6
|
-
*/
|
|
7
|
-
export declare const Get: (path?: string, options?: import("..").HttpMethodOptions) => MethodDecorator;
|
|
8
|
-
/**
|
|
9
|
-
* POST method decorator
|
|
10
|
-
* The POST method submits an entity to the specified resource,
|
|
11
|
-
* often causing a change in state or side effects on the server.
|
|
12
|
-
* @param path - The route path
|
|
13
|
-
*/
|
|
14
|
-
export declare const Post: (path?: string, options?: import("..").HttpMethodOptions) => MethodDecorator;
|
|
15
|
-
/**
|
|
16
|
-
* PUT method decorator
|
|
17
|
-
* The PUT method replaces all current representations of the target resource with the request content.
|
|
18
|
-
* @param path - The route path
|
|
19
|
-
*/
|
|
20
|
-
export declare const Put: (path?: string, options?: import("..").HttpMethodOptions) => MethodDecorator;
|
|
21
|
-
/**
|
|
22
|
-
* DELETE method decorator
|
|
23
|
-
* The DELETE method deletes the specified resource.
|
|
24
|
-
* @param path - The route path
|
|
25
|
-
*/
|
|
26
|
-
export declare const Delete: (path?: string, options?: import("..").HttpMethodOptions) => MethodDecorator;
|
|
27
|
-
/**
|
|
28
|
-
* PATCH method decorator
|
|
29
|
-
* The PATCH method applies partial modifications to a resource.
|
|
30
|
-
* @param path - The route path
|
|
31
|
-
*/
|
|
32
|
-
export declare const Patch: (path?: string, options?: import("..").HttpMethodOptions) => MethodDecorator;
|
|
33
|
-
/**
|
|
34
|
-
* OPTIONS method decorator
|
|
35
|
-
* The OPTIONS method describes the communication options for the target resource.
|
|
36
|
-
* @param path - The route path
|
|
37
|
-
*/
|
|
38
|
-
export declare const Options: (path?: string, options?: import("..").HttpMethodOptions) => MethodDecorator;
|
|
39
|
-
/**
|
|
40
|
-
* ALL method decorator (matches all HTTP methods)
|
|
41
|
-
* @param path - The route path
|
|
42
|
-
*/
|
|
43
|
-
export declare const All: (path?: string, options?: import("..").HttpMethodOptions) => MethodDecorator;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { createHttpMethodDecorator } from '../helpers';
|
|
2
|
-
/**
|
|
3
|
-
* GET method decorator
|
|
4
|
-
* The GET method requests a representation of the specified resource.
|
|
5
|
-
* Requests using GET should only retrieve data and should not contain a request content.
|
|
6
|
-
* @param path - The route path
|
|
7
|
-
*/
|
|
8
|
-
export const Get = createHttpMethodDecorator('get');
|
|
9
|
-
/**
|
|
10
|
-
* POST method decorator
|
|
11
|
-
* The POST method submits an entity to the specified resource,
|
|
12
|
-
* often causing a change in state or side effects on the server.
|
|
13
|
-
* @param path - The route path
|
|
14
|
-
*/
|
|
15
|
-
export const Post = createHttpMethodDecorator('post');
|
|
16
|
-
/**
|
|
17
|
-
* PUT method decorator
|
|
18
|
-
* The PUT method replaces all current representations of the target resource with the request content.
|
|
19
|
-
* @param path - The route path
|
|
20
|
-
*/
|
|
21
|
-
export const Put = createHttpMethodDecorator('put');
|
|
22
|
-
/**
|
|
23
|
-
* DELETE method decorator
|
|
24
|
-
* The DELETE method deletes the specified resource.
|
|
25
|
-
* @param path - The route path
|
|
26
|
-
*/
|
|
27
|
-
export const Delete = createHttpMethodDecorator('delete');
|
|
28
|
-
/**
|
|
29
|
-
* PATCH method decorator
|
|
30
|
-
* The PATCH method applies partial modifications to a resource.
|
|
31
|
-
* @param path - The route path
|
|
32
|
-
*/
|
|
33
|
-
export const Patch = createHttpMethodDecorator('patch');
|
|
34
|
-
/**
|
|
35
|
-
* OPTIONS method decorator
|
|
36
|
-
* The OPTIONS method describes the communication options for the target resource.
|
|
37
|
-
* @param path - The route path
|
|
38
|
-
*/
|
|
39
|
-
export const Options = createHttpMethodDecorator('options');
|
|
40
|
-
/**
|
|
41
|
-
* ALL method decorator (matches all HTTP methods)
|
|
42
|
-
* @param path - The route path
|
|
43
|
-
*/
|
|
44
|
-
export const All = createHttpMethodDecorator('all');
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export * from './controller.decorator';
|
|
2
|
-
export * from './http-method.decorator';
|
|
3
|
-
export * from './module.decorator';
|
|
4
|
-
export * from './mvc.decorator';
|
|
5
|
-
export * from './parameter.decorator';
|
|
6
|
-
export * from './service.decorator';
|
|
7
|
-
export * from './use-component.decorator';
|
|
8
|
-
export * from './use-filters.decorator';
|
|
9
|
-
export * from './use-guards.decorator';
|
|
10
|
-
export * from './use-middleware.decorator';
|
|
11
|
-
export * from './use-pipes.decorator';
|
package/dist/decorators/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export * from './controller.decorator';
|
|
2
|
-
export * from './http-method.decorator';
|
|
3
|
-
export * from './module.decorator';
|
|
4
|
-
export * from './mvc.decorator';
|
|
5
|
-
export * from './parameter.decorator';
|
|
6
|
-
export * from './service.decorator';
|
|
7
|
-
export * from './use-component.decorator';
|
|
8
|
-
export * from './use-filters.decorator';
|
|
9
|
-
export * from './use-guards.decorator';
|
|
10
|
-
export * from './use-middleware.decorator';
|
|
11
|
-
export * from './use-pipes.decorator';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ModuleOptions } from '../interfaces';
|
|
2
|
-
/**
|
|
3
|
-
* Decorator that marks a class as a module
|
|
4
|
-
* Modules are used to organize the application structure and dependencies
|
|
5
|
-
* @param options - Configuration options for the module
|
|
6
|
-
* @returns A class decorator function
|
|
7
|
-
*/
|
|
8
|
-
export declare function Module(options?: ModuleOptions): ClassDecorator;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { MetadataRegistry } from '../registries';
|
|
2
|
-
/**
|
|
3
|
-
* Decorator that marks a class as a module
|
|
4
|
-
* Modules are used to organize the application structure and dependencies
|
|
5
|
-
* @param options - Configuration options for the module
|
|
6
|
-
* @returns A class decorator function
|
|
7
|
-
*/
|
|
8
|
-
export function Module(options = {}) {
|
|
9
|
-
return (target) => {
|
|
10
|
-
MetadataRegistry.setModuleOptions(target, options);
|
|
11
|
-
};
|
|
12
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { ControllerOptions, ModuleOptions } from '../interfaces';
|
|
2
|
-
import type { Constructor } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Decorator that marks a class as a controller
|
|
5
|
-
* Controllers are responsible for handling incoming requests and returning responses
|
|
6
|
-
* @param route - The base route for all endpoints in this controller
|
|
7
|
-
* @param options - Configuration options for the controller
|
|
8
|
-
* @returns A class decorator function
|
|
9
|
-
*/
|
|
10
|
-
export declare function View(route?: string, options?: ControllerOptions): ClassDecorator;
|
|
11
|
-
/**
|
|
12
|
-
* GET method decorator
|
|
13
|
-
* The GET method requests a representation of the specified resource.
|
|
14
|
-
* Requests using GET should only retrieve data and should not contain a request content.
|
|
15
|
-
* @param path - The route path
|
|
16
|
-
*/
|
|
17
|
-
export declare const Page: (path?: string, options?: import("..").HttpMethodOptions) => MethodDecorator;
|
|
18
|
-
/**
|
|
19
|
-
* Decorator that marks a class as a module
|
|
20
|
-
* Modules are used to organize the application structure and dependencies
|
|
21
|
-
* @param options - Configuration options for the module
|
|
22
|
-
* @returns A class decorator function
|
|
23
|
-
*/
|
|
24
|
-
export declare function MvcModule(options?: ModuleOptions & {
|
|
25
|
-
views?: Constructor[];
|
|
26
|
-
}): ClassDecorator;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Controller } from './controller.decorator';
|
|
2
|
-
import { Get } from './http-method.decorator';
|
|
3
|
-
import { Module } from './module.decorator';
|
|
4
|
-
/**
|
|
5
|
-
* Decorator that marks a class as a controller
|
|
6
|
-
* Controllers are responsible for handling incoming requests and returning responses
|
|
7
|
-
* @param route - The base route for all endpoints in this controller
|
|
8
|
-
* @param options - Configuration options for the controller
|
|
9
|
-
* @returns A class decorator function
|
|
10
|
-
*/
|
|
11
|
-
export function View(route = '', options = {
|
|
12
|
-
prefix: null,
|
|
13
|
-
version: null
|
|
14
|
-
}) {
|
|
15
|
-
return Controller(route, options);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* GET method decorator
|
|
19
|
-
* The GET method requests a representation of the specified resource.
|
|
20
|
-
* Requests using GET should only retrieve data and should not contain a request content.
|
|
21
|
-
* @param path - The route path
|
|
22
|
-
*/
|
|
23
|
-
export const Page = Get;
|
|
24
|
-
/**
|
|
25
|
-
* Decorator that marks a class as a module
|
|
26
|
-
* Modules are used to organize the application structure and dependencies
|
|
27
|
-
* @param options - Configuration options for the module
|
|
28
|
-
* @returns A class decorator function
|
|
29
|
-
*/
|
|
30
|
-
export function MvcModule(options = {}) {
|
|
31
|
-
return Module({
|
|
32
|
-
imports: options.imports,
|
|
33
|
-
services: options.services,
|
|
34
|
-
controllers: (options.views || []).concat(options.controllers || [])
|
|
35
|
-
});
|
|
36
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Decorator that binds the request body to a parameter
|
|
3
|
-
* @param data - Optional property name to extract from the body
|
|
4
|
-
*/
|
|
5
|
-
export declare const Body: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
6
|
-
/**
|
|
7
|
-
* Decorator that binds a route parameter to a parameter
|
|
8
|
-
* @param data - The parameter name in the route
|
|
9
|
-
*/
|
|
10
|
-
export declare const Param: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
11
|
-
/**
|
|
12
|
-
* Decorator that binds a query parameter to a parameter
|
|
13
|
-
* @param data - The query parameter name
|
|
14
|
-
*/
|
|
15
|
-
export declare const Query: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
16
|
-
/**
|
|
17
|
-
* Decorator that binds a header value to a parameter
|
|
18
|
-
* @param data - The header name
|
|
19
|
-
*/
|
|
20
|
-
export declare const Header: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
21
|
-
/**
|
|
22
|
-
* Decorator that binds the request object to a parameter
|
|
23
|
-
*/
|
|
24
|
-
export declare const Req: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
25
|
-
export declare const Request: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
26
|
-
/**
|
|
27
|
-
* Decorator that binds the response object to a parameter
|
|
28
|
-
*/
|
|
29
|
-
export declare const Res: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
30
|
-
export declare const Response: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
31
|
-
/**
|
|
32
|
-
* Decorator that binds the context object to a parameter
|
|
33
|
-
*/
|
|
34
|
-
export declare const Ctx: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
35
|
-
export declare const Context: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
36
|
-
/**
|
|
37
|
-
* Decorator that binds a context variable to a parameter
|
|
38
|
-
* @param data - The variable name to retrieve from context
|
|
39
|
-
*/
|
|
40
|
-
export declare const Var: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
41
|
-
export declare const Variable: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { HONEST_PIPELINE_BODY_CACHE_KEY } from '../constants';
|
|
2
|
-
import { createParamDecorator } from '../helpers';
|
|
3
|
-
/**
|
|
4
|
-
* Decorator that binds the request body to a parameter
|
|
5
|
-
* @param data - Optional property name to extract from the body
|
|
6
|
-
*/
|
|
7
|
-
export const Body = createParamDecorator('body', async (data, ctx) => {
|
|
8
|
-
let body = ctx.get(HONEST_PIPELINE_BODY_CACHE_KEY);
|
|
9
|
-
if (body === undefined) {
|
|
10
|
-
body = await ctx.req.json();
|
|
11
|
-
ctx.set(HONEST_PIPELINE_BODY_CACHE_KEY, body);
|
|
12
|
-
}
|
|
13
|
-
if (data && body && typeof body === 'object') {
|
|
14
|
-
return body[String(data)];
|
|
15
|
-
}
|
|
16
|
-
return body;
|
|
17
|
-
});
|
|
18
|
-
/**
|
|
19
|
-
* Decorator that binds a route parameter to a parameter
|
|
20
|
-
* @param data - The parameter name in the route
|
|
21
|
-
*/
|
|
22
|
-
export const Param = createParamDecorator('param', (data, ctx) => {
|
|
23
|
-
return data ? ctx.req.param(String(data)) : ctx.req.param();
|
|
24
|
-
});
|
|
25
|
-
/**
|
|
26
|
-
* Decorator that binds a query parameter to a parameter
|
|
27
|
-
* @param data - The query parameter name
|
|
28
|
-
*/
|
|
29
|
-
export const Query = createParamDecorator('query', (data, ctx) => {
|
|
30
|
-
return data ? ctx.req.query(String(data)) : ctx.req.query();
|
|
31
|
-
});
|
|
32
|
-
/**
|
|
33
|
-
* Decorator that binds a header value to a parameter
|
|
34
|
-
* @param data - The header name
|
|
35
|
-
*/
|
|
36
|
-
export const Header = createParamDecorator('header', (data, ctx) => {
|
|
37
|
-
return data ? ctx.req.header(String(data)) : ctx.req.header();
|
|
38
|
-
});
|
|
39
|
-
/**
|
|
40
|
-
* Decorator that binds the request object to a parameter
|
|
41
|
-
*/
|
|
42
|
-
export const Req = createParamDecorator('request', (_, ctx) => ctx.req);
|
|
43
|
-
export const Request = createParamDecorator('request', (_, ctx) => ctx.req);
|
|
44
|
-
/**
|
|
45
|
-
* Decorator that binds the response object to a parameter
|
|
46
|
-
*/
|
|
47
|
-
export const Res = createParamDecorator('response', (_, ctx) => ctx.res);
|
|
48
|
-
export const Response = createParamDecorator('response', (_, ctx) => ctx.res);
|
|
49
|
-
/**
|
|
50
|
-
* Decorator that binds the context object to a parameter
|
|
51
|
-
*/
|
|
52
|
-
export const Ctx = createParamDecorator('context', (_, ctx) => ctx);
|
|
53
|
-
export const Context = createParamDecorator('context', (_, ctx) => ctx);
|
|
54
|
-
/**
|
|
55
|
-
* Decorator that binds a context variable to a parameter
|
|
56
|
-
* @param data - The variable name to retrieve from context
|
|
57
|
-
*/
|
|
58
|
-
export const Var = createParamDecorator('variable', (data, ctx) => data === undefined ? undefined : ctx.get(String(data)));
|
|
59
|
-
export const Variable = createParamDecorator('variable', (data, ctx) => data === undefined ? undefined : ctx.get(String(data)));
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { MetadataRegistry } from '../registries';
|
|
2
|
-
/**
|
|
3
|
-
* Decorator that marks a class as a service
|
|
4
|
-
* Services are singleton classes that can be injected as dependencies
|
|
5
|
-
* @returns A class decorator function
|
|
6
|
-
*/
|
|
7
|
-
export function Service() {
|
|
8
|
-
return (target) => {
|
|
9
|
-
MetadataRegistry.addService(target);
|
|
10
|
-
};
|
|
11
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ComponentType, ComponentTypeMap } from '../registries';
|
|
2
|
-
import type { Constructor } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Generic decorator that applies components of a specific type to a controller class or method
|
|
5
|
-
* @template T - The type of component being applied
|
|
6
|
-
* @param type - The component type identifier
|
|
7
|
-
* @param components - Array of components to apply
|
|
8
|
-
* @returns A decorator function that can be used at class or method level
|
|
9
|
-
*/
|
|
10
|
-
export declare function UseComponent<T extends ComponentType>(type: T, ...components: ComponentTypeMap[T][]): (target: Constructor | object, propertyKey?: string | symbol) => void;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { MetadataRegistry } from '../registries';
|
|
2
|
-
/**
|
|
3
|
-
* Generic decorator that applies components of a specific type to a controller class or method
|
|
4
|
-
* @template T - The type of component being applied
|
|
5
|
-
* @param type - The component type identifier
|
|
6
|
-
* @param components - Array of components to apply
|
|
7
|
-
* @returns A decorator function that can be used at class or method level
|
|
8
|
-
*/
|
|
9
|
-
export function UseComponent(type, ...components) {
|
|
10
|
-
return (target, propertyKey) => {
|
|
11
|
-
if (propertyKey) {
|
|
12
|
-
const controllerClass = target.constructor;
|
|
13
|
-
components.forEach((component) => MetadataRegistry.registerHandler(type, controllerClass, propertyKey, component));
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
components.forEach((component) => MetadataRegistry.registerController(type, target, component));
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { FilterType } from '../interfaces';
|
|
2
|
-
import type { Constructor } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Decorator that applies exception filters to a controller class or method
|
|
5
|
-
* @param filters - Array of exception filters to apply
|
|
6
|
-
* @returns A decorator function that can be used at class or method level
|
|
7
|
-
*/
|
|
8
|
-
export declare function UseFilters(...filters: FilterType[]): (target: Constructor | object, propertyKey?: string | symbol) => void;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { MetadataRegistry } from '../registries';
|
|
2
|
-
/**
|
|
3
|
-
* Decorator that applies exception filters to a controller class or method
|
|
4
|
-
* @param filters - Array of exception filters to apply
|
|
5
|
-
* @returns A decorator function that can be used at class or method level
|
|
6
|
-
*/
|
|
7
|
-
export function UseFilters(...filters) {
|
|
8
|
-
return (target, propertyKey) => {
|
|
9
|
-
if (propertyKey) {
|
|
10
|
-
const controllerClass = target.constructor;
|
|
11
|
-
filters.forEach((filter) => MetadataRegistry.registerHandler('filter', controllerClass, propertyKey, filter));
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
filters.forEach((filter) => MetadataRegistry.registerController('filter', target, filter));
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { GuardType } from '../interfaces';
|
|
2
|
-
import type { Constructor } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Decorator that applies guards to a controller class or method
|
|
5
|
-
* Guards determine whether a request should be handled by the route handler
|
|
6
|
-
* @param guards - Array of guards to apply
|
|
7
|
-
* @returns A decorator function that can be used at class or method level
|
|
8
|
-
*/
|
|
9
|
-
export declare function UseGuards(...guards: GuardType[]): (target: Constructor | object, propertyKey?: string | symbol) => void;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { MetadataRegistry } from '../registries';
|
|
2
|
-
/**
|
|
3
|
-
* Decorator that applies guards to a controller class or method
|
|
4
|
-
* Guards determine whether a request should be handled by the route handler
|
|
5
|
-
* @param guards - Array of guards to apply
|
|
6
|
-
* @returns A decorator function that can be used at class or method level
|
|
7
|
-
*/
|
|
8
|
-
export function UseGuards(...guards) {
|
|
9
|
-
return (target, propertyKey) => {
|
|
10
|
-
if (propertyKey) {
|
|
11
|
-
const controllerClass = target.constructor;
|
|
12
|
-
guards.forEach((guard) => MetadataRegistry.registerHandler('guard', controllerClass, propertyKey, guard));
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
guards.forEach((guard) => MetadataRegistry.registerController('guard', target, guard));
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { MiddlewareType } from '../interfaces';
|
|
2
|
-
import type { Constructor } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Decorator that applies middleware to a controller class or method
|
|
5
|
-
* Middleware functions run before the route handler and can modify the request/response
|
|
6
|
-
* @param middleware - Array of middleware functions to apply
|
|
7
|
-
* @returns A decorator function that can be used at class or method level
|
|
8
|
-
*/
|
|
9
|
-
export declare function UseMiddleware(...middleware: MiddlewareType[]): (target: Constructor | object, propertyKey?: string | symbol) => void;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { MetadataRegistry } from '../registries';
|
|
2
|
-
/**
|
|
3
|
-
* Decorator that applies middleware to a controller class or method
|
|
4
|
-
* Middleware functions run before the route handler and can modify the request/response
|
|
5
|
-
* @param middleware - Array of middleware functions to apply
|
|
6
|
-
* @returns A decorator function that can be used at class or method level
|
|
7
|
-
*/
|
|
8
|
-
export function UseMiddleware(...middleware) {
|
|
9
|
-
return (target, propertyKey) => {
|
|
10
|
-
if (propertyKey) {
|
|
11
|
-
const controllerClass = target.constructor;
|
|
12
|
-
middleware.forEach((mw) => MetadataRegistry.registerHandler('middleware', controllerClass, propertyKey, mw));
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
middleware.forEach((mw) => MetadataRegistry.registerController('middleware', target, mw));
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { PipeType } from '../interfaces';
|
|
2
|
-
import type { Constructor } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Decorator that applies transformation pipes to a controller class or method
|
|
5
|
-
* Pipes transform input data before it reaches the route handler
|
|
6
|
-
* @param pipes - Array of pipes to apply
|
|
7
|
-
* @returns A decorator function that can be used at class or method level
|
|
8
|
-
*/
|
|
9
|
-
export declare function UsePipes(...pipes: PipeType[]): (target: Constructor | object, propertyKey?: string | symbol) => void;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { MetadataRegistry } from '../registries';
|
|
2
|
-
/**
|
|
3
|
-
* Decorator that applies transformation pipes to a controller class or method
|
|
4
|
-
* Pipes transform input data before it reaches the route handler
|
|
5
|
-
* @param pipes - Array of pipes to apply
|
|
6
|
-
* @returns A decorator function that can be used at class or method level
|
|
7
|
-
*/
|
|
8
|
-
export function UsePipes(...pipes) {
|
|
9
|
-
return (target, propertyKey) => {
|
|
10
|
-
if (propertyKey) {
|
|
11
|
-
const controllerClass = target.constructor;
|
|
12
|
-
pipes.forEach((pipe) => MetadataRegistry.registerHandler('pipe', controllerClass, propertyKey, pipe));
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
pipes.forEach((pipe) => MetadataRegistry.registerController('pipe', target, pipe));
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
}
|
package/dist/di/container.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { DiContainer, ILogger, IServiceRegistry } from '../interfaces';
|
|
2
|
-
import type { Constructor } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Dependency Injection container that manages class instances and their dependencies
|
|
5
|
-
*/
|
|
6
|
-
export declare class Container implements DiContainer {
|
|
7
|
-
private readonly serviceRegistry;
|
|
8
|
-
private readonly logger;
|
|
9
|
-
private readonly debugDi;
|
|
10
|
-
constructor(serviceRegistry?: IServiceRegistry, logger?: ILogger, debugDi?: boolean);
|
|
11
|
-
/**
|
|
12
|
-
* Map of class constructors to their instances
|
|
13
|
-
*/
|
|
14
|
-
private instances;
|
|
15
|
-
private emitLog;
|
|
16
|
-
/**
|
|
17
|
-
* Resolves a class instance, creating it if necessary and injecting its dependencies
|
|
18
|
-
* @param target - The class constructor to resolve
|
|
19
|
-
* @returns An instance of the target class
|
|
20
|
-
*/
|
|
21
|
-
resolve<T>(target: Constructor<T>): T;
|
|
22
|
-
/**
|
|
23
|
-
* Internal recursive resolver with circular dependency tracking
|
|
24
|
-
*/
|
|
25
|
-
private resolveWithTracking;
|
|
26
|
-
/**
|
|
27
|
-
* Registers a pre-created instance for a class
|
|
28
|
-
* @param target - The class constructor to register
|
|
29
|
-
* @param instance - The instance to register
|
|
30
|
-
*/
|
|
31
|
-
register<T>(target: Constructor<T>, instance: T): void;
|
|
32
|
-
has<T>(target: Constructor<T>): boolean;
|
|
33
|
-
clear(): void;
|
|
34
|
-
}
|
package/dist/di/container.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { NoopLogger } from '../loggers';
|
|
2
|
-
import { StaticServiceRegistry } from '../registries';
|
|
3
|
-
/**
|
|
4
|
-
* Dependency Injection container that manages class instances and their dependencies
|
|
5
|
-
*/
|
|
6
|
-
export class Container {
|
|
7
|
-
serviceRegistry;
|
|
8
|
-
logger;
|
|
9
|
-
debugDi;
|
|
10
|
-
constructor(serviceRegistry = new StaticServiceRegistry(), logger = new NoopLogger(), debugDi = false) {
|
|
11
|
-
this.serviceRegistry = serviceRegistry;
|
|
12
|
-
this.logger = logger;
|
|
13
|
-
this.debugDi = debugDi;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Map of class constructors to their instances
|
|
17
|
-
*/
|
|
18
|
-
instances = new Map();
|
|
19
|
-
emitLog(event) {
|
|
20
|
-
if (!this.debugDi) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
this.logger.emit(event);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Resolves a class instance, creating it if necessary and injecting its dependencies
|
|
27
|
-
* @param target - The class constructor to resolve
|
|
28
|
-
* @returns An instance of the target class
|
|
29
|
-
*/
|
|
30
|
-
resolve(target) {
|
|
31
|
-
return this.resolveWithTracking(target, new Set());
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Internal recursive resolver with circular dependency tracking
|
|
35
|
-
*/
|
|
36
|
-
resolveWithTracking(target, resolving) {
|
|
37
|
-
if (this.instances.has(target)) {
|
|
38
|
-
this.emitLog({
|
|
39
|
-
level: 'debug',
|
|
40
|
-
category: 'di',
|
|
41
|
-
message: `Resolved ${target.name} from DI cache`
|
|
42
|
-
});
|
|
43
|
-
return this.instances.get(target);
|
|
44
|
-
}
|
|
45
|
-
if (resolving.has(target)) {
|
|
46
|
-
const cycle = [...resolving.keys(), target].map((t) => t.name).join(' -> ');
|
|
47
|
-
this.emitLog({
|
|
48
|
-
level: 'error',
|
|
49
|
-
category: 'di',
|
|
50
|
-
message: `Circular dependency detected while resolving ${target.name}`,
|
|
51
|
-
details: { cycle }
|
|
52
|
-
});
|
|
53
|
-
throw new Error(`Circular dependency detected: ${cycle}`);
|
|
54
|
-
}
|
|
55
|
-
resolving.add(target);
|
|
56
|
-
this.emitLog({
|
|
57
|
-
level: 'debug',
|
|
58
|
-
category: 'di',
|
|
59
|
-
message: `Resolving ${target.name}`,
|
|
60
|
-
details: { resolving: [...resolving].map((constructor) => constructor.name) }
|
|
61
|
-
});
|
|
62
|
-
const paramTypes = Reflect.getMetadata('design:paramtypes', target) || [];
|
|
63
|
-
if (target.length > 0 && paramTypes.length === 0) {
|
|
64
|
-
if (!this.serviceRegistry.isService(target)) {
|
|
65
|
-
this.emitLog({
|
|
66
|
-
level: 'error',
|
|
67
|
-
category: 'di',
|
|
68
|
-
message: `Cannot resolve ${target.name}: missing @Service() decorator`
|
|
69
|
-
});
|
|
70
|
-
throw new Error(`Cannot resolve ${target.name}: it is not decorated with @Service(). Did you forget to add @Service() to the class?`);
|
|
71
|
-
}
|
|
72
|
-
this.emitLog({
|
|
73
|
-
level: 'error',
|
|
74
|
-
category: 'di',
|
|
75
|
-
message: `Cannot resolve ${target.name}: missing constructor metadata`
|
|
76
|
-
});
|
|
77
|
-
throw new Error(`Cannot resolve dependencies for ${target.name}: constructor metadata is missing. Ensure 'reflect-metadata' is imported and 'emitDecoratorMetadata' is enabled.`);
|
|
78
|
-
}
|
|
79
|
-
const dependencies = paramTypes.map((paramType, index) => {
|
|
80
|
-
if (!paramType || paramType === Object || paramType === Array || paramType === Function) {
|
|
81
|
-
this.emitLog({
|
|
82
|
-
level: 'error',
|
|
83
|
-
category: 'di',
|
|
84
|
-
message: `Cannot resolve dependency at index ${index} of ${target.name}`
|
|
85
|
-
});
|
|
86
|
-
throw new Error(`Cannot resolve dependency at index ${index} of ${target.name}. Use concrete class types for constructor dependencies.`);
|
|
87
|
-
}
|
|
88
|
-
return this.resolveWithTracking(paramType, new Set(resolving));
|
|
89
|
-
});
|
|
90
|
-
const instance = new target(...dependencies);
|
|
91
|
-
this.instances.set(target, instance);
|
|
92
|
-
this.emitLog({
|
|
93
|
-
level: 'debug',
|
|
94
|
-
category: 'di',
|
|
95
|
-
message: `Created ${target.name} instance`,
|
|
96
|
-
details: { dependencyCount: dependencies.length }
|
|
97
|
-
});
|
|
98
|
-
return instance;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Registers a pre-created instance for a class
|
|
102
|
-
* @param target - The class constructor to register
|
|
103
|
-
* @param instance - The instance to register
|
|
104
|
-
*/
|
|
105
|
-
register(target, instance) {
|
|
106
|
-
this.instances.set(target, instance);
|
|
107
|
-
}
|
|
108
|
-
has(target) {
|
|
109
|
-
return this.instances.has(target);
|
|
110
|
-
}
|
|
111
|
-
clear() {
|
|
112
|
-
this.instances.clear();
|
|
113
|
-
}
|
|
114
|
-
}
|
package/dist/di/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './container';
|
package/dist/di/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './container';
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export interface FrameworkErrorOptions {
|
|
2
|
-
status?: number;
|
|
3
|
-
code: string;
|
|
4
|
-
category: string;
|
|
5
|
-
remediation?: string;
|
|
6
|
-
details?: Record<string, unknown>;
|
|
7
|
-
cause?: unknown;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Structured framework-level error with machine-readable metadata.
|
|
11
|
-
*/
|
|
12
|
-
export declare class FrameworkError extends Error {
|
|
13
|
-
readonly status?: number;
|
|
14
|
-
readonly code: string;
|
|
15
|
-
readonly category: string;
|
|
16
|
-
readonly remediation?: string;
|
|
17
|
-
readonly details?: Record<string, unknown>;
|
|
18
|
-
constructor(message: string, options: FrameworkErrorOptions);
|
|
19
|
-
}
|