bootifyjs 0.1.1 → 1.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/api.d.ts +8 -27
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +68 -134
- package/dist/api.js.map +1 -1
- package/dist/cache/bootstrap.d.ts +6 -0
- package/dist/cache/bootstrap.d.ts.map +1 -0
- package/dist/cache/bootstrap.js +23 -0
- package/dist/cache/bootstrap.js.map +1 -0
- package/dist/cache/cache.service.d.ts +9 -0
- package/dist/cache/cache.service.d.ts.map +1 -0
- package/dist/cache/cache.service.js +40 -0
- package/dist/cache/cache.service.js.map +1 -0
- package/dist/cache/cache.types.d.ts +14 -0
- package/dist/cache/cache.types.d.ts.map +1 -0
- package/dist/cache/cache.types.js +8 -0
- package/dist/cache/cache.types.js.map +1 -0
- package/dist/cache/decorators.d.ts +12 -0
- package/dist/cache/decorators.d.ts.map +1 -0
- package/dist/cache/decorators.js +53 -0
- package/dist/cache/decorators.js.map +1 -0
- package/dist/cache/in-memory-cache.store.d.ts +8 -0
- package/dist/cache/in-memory-cache.store.d.ts.map +1 -0
- package/dist/cache/in-memory-cache.store.js +39 -0
- package/dist/cache/in-memory-cache.store.js.map +1 -0
- package/dist/cache/index.d.ts +5 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +21 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/core/component-registry.d.ts +7 -0
- package/dist/core/component-registry.d.ts.map +1 -0
- package/dist/core/component-registry.js +9 -0
- package/dist/core/component-registry.js.map +1 -0
- package/dist/core/decorators.d.ts +38 -22
- package/dist/core/decorators.d.ts.map +1 -0
- package/dist/core/decorators.js +155 -174
- package/dist/core/decorators.js.map +1 -1
- package/dist/core/di-container.d.ts +31 -0
- package/dist/core/di-container.d.ts.map +1 -0
- package/dist/core/di-container.js +219 -0
- package/dist/core/di-container.js.map +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +21 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/request-context.service.d.ts +24 -0
- package/dist/core/request-context.service.d.ts.map +1 -0
- package/dist/core/request-context.service.js +52 -0
- package/dist/core/request-context.service.js.map +1 -0
- package/dist/core/router.d.ts +4 -32
- package/dist/core/router.d.ts.map +1 -0
- package/dist/core/router.js +81 -258
- package/dist/core/router.js.map +1 -1
- package/dist/events/bootstrap.d.ts +8 -0
- package/dist/events/bootstrap.d.ts.map +1 -0
- package/dist/events/bootstrap.js +37 -0
- package/dist/events/bootstrap.js.map +1 -0
- package/dist/events/decorators.d.ts +16 -0
- package/dist/events/decorators.d.ts.map +1 -0
- package/dist/events/decorators.js +37 -0
- package/dist/events/decorators.js.map +1 -0
- package/dist/events/event-bus.service.d.ts +21 -0
- package/dist/events/event-bus.service.d.ts.map +1 -0
- package/dist/events/event-bus.service.js +78 -0
- package/dist/events/event-bus.service.js.map +1 -0
- package/dist/events/event.types.d.ts +17 -0
- package/dist/events/event.types.d.ts.map +1 -0
- package/dist/events/event.types.js.map +1 -0
- package/dist/events/index.d.ts +5 -13
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +4 -54
- package/dist/events/index.js.map +1 -1
- package/dist/examples/controllers/health.controller.d.ts +7 -0
- package/dist/examples/controllers/health.controller.d.ts.map +1 -0
- package/dist/{events/examples/system.events.js → examples/controllers/health.controller.js} +16 -15
- package/dist/examples/controllers/health.controller.js.map +1 -0
- package/dist/examples/controllers/todo.controller.d.ts +31 -0
- package/dist/examples/controllers/todo.controller.d.ts.map +1 -0
- package/dist/examples/controllers/todo.controller.js +102 -0
- package/dist/examples/controllers/todo.controller.js.map +1 -0
- package/dist/examples/events/TodoEventHandler.d.ts +2 -0
- package/dist/examples/events/TodoEventHandler.d.ts.map +1 -0
- package/dist/examples/events/TodoEventHandler.js +31 -0
- package/dist/examples/events/TodoEventHandler.js.map +1 -0
- package/dist/examples/events/todo.events.d.ts +16 -0
- package/dist/examples/events/todo.events.d.ts.map +1 -0
- package/dist/examples/events/todo.events.js +13 -0
- package/dist/examples/events/todo.events.js.map +1 -0
- package/dist/examples/index.d.ts +2 -0
- package/dist/examples/index.d.ts.map +1 -0
- package/dist/examples/index.js +35 -0
- package/dist/examples/index.js.map +1 -0
- package/dist/examples/repositories/todo.repository.d.ts +20 -0
- package/dist/examples/repositories/todo.repository.d.ts.map +1 -0
- package/dist/examples/repositories/todo.repository.js +33 -0
- package/dist/examples/repositories/todo.repository.js.map +1 -0
- package/dist/examples/services/todo.service.d.ts +33 -0
- package/dist/examples/services/todo.service.d.ts.map +1 -0
- package/dist/examples/services/todo.service.js +80 -0
- package/dist/examples/services/todo.service.js.map +1 -0
- package/dist/examples/todos/schema.d.ts +54 -0
- package/dist/examples/todos/schema.d.ts.map +1 -0
- package/dist/examples/todos/schema.js +20 -0
- package/dist/examples/todos/schema.js.map +1 -0
- package/dist/index.d.ts +7 -17
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -95
- package/dist/index.js.map +1 -1
- package/dist/logging/config/logging.config.d.ts +31 -3
- package/dist/logging/config/logging.config.d.ts.map +1 -0
- package/dist/logging/config/logging.config.js +43 -93
- package/dist/logging/config/logging.config.js.map +1 -1
- package/dist/logging/core/decorators.d.ts +16 -0
- package/dist/logging/core/decorators.d.ts.map +1 -0
- package/dist/logging/core/decorators.js +74 -0
- package/dist/logging/core/decorators.js.map +1 -0
- package/dist/logging/core/logger.provider.d.ts +4 -0
- package/dist/logging/core/logger.provider.d.ts.map +1 -0
- package/dist/logging/core/logger.provider.js +68 -0
- package/dist/logging/core/logger.provider.js.map +1 -0
- package/dist/logging/core/logger.service.d.ts +9 -27
- package/dist/logging/core/logger.service.d.ts.map +1 -0
- package/dist/logging/core/logger.service.js +34 -164
- package/dist/logging/core/logger.service.js.map +1 -1
- package/dist/logging/core/{startup-logger.service.d.ts → startup.logger.d.ts} +4 -6
- package/dist/logging/core/startup.logger.d.ts.map +1 -0
- package/dist/logging/core/{startup-logger.service.js → startup.logger.js} +36 -42
- package/dist/logging/core/startup.logger.js.map +1 -0
- package/dist/logging/index.d.ts +7 -14
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +17 -28
- package/dist/logging/index.js.map +1 -1
- package/dist/middleware/auth.middleware.d.ts +3 -0
- package/dist/middleware/auth.middleware.d.ts.map +1 -0
- package/dist/middleware/auth.middleware.js +18 -0
- package/dist/middleware/auth.middleware.js.map +1 -0
- package/dist/middleware/context.middleware.d.ts +7 -0
- package/dist/middleware/context.middleware.d.ts.map +1 -0
- package/dist/middleware/context.middleware.js +25 -0
- package/dist/middleware/context.middleware.js.map +1 -0
- package/dist/middleware/index.d.ts +4 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +20 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/request-logger.middleware.d.ts +4 -0
- package/dist/middleware/request-logger.middleware.d.ts.map +1 -0
- package/dist/middleware/request-logger.middleware.js +18 -0
- package/dist/middleware/request-logger.middleware.js.map +1 -0
- package/package.json +52 -47
- package/LICENSE +0 -21
- package/README.md +0 -423
- package/dist/config/app.config.d.ts +0 -29
- package/dist/config/app.config.js +0 -55
- package/dist/config/app.config.js.map +0 -1
- package/dist/controllers/config.controller.d.ts +0 -16
- package/dist/controllers/config.controller.js +0 -66
- package/dist/controllers/config.controller.js.map +0 -1
- package/dist/controllers/events.controller.d.ts +0 -66
- package/dist/controllers/events.controller.js +0 -145
- package/dist/controllers/events.controller.js.map +0 -1
- package/dist/controllers/health.controller.d.ts +0 -20
- package/dist/controllers/health.controller.js +0 -92
- package/dist/controllers/health.controller.js.map +0 -1
- package/dist/controllers/user.controller.d.ts +0 -13
- package/dist/controllers/user.controller.js +0 -209
- package/dist/controllers/user.controller.js.map +0 -1
- package/dist/core/application.d.ts +0 -21
- package/dist/core/application.js +0 -90
- package/dist/core/application.js.map +0 -1
- package/dist/core/config.d.ts +0 -3
- package/dist/core/config.js +0 -78
- package/dist/core/config.js.map +0 -1
- package/dist/core/container.d.ts +0 -17
- package/dist/core/container.js +0 -92
- package/dist/core/container.js.map +0 -1
- package/dist/core/errors.d.ts +0 -18
- package/dist/core/errors.js +0 -74
- package/dist/core/errors.js.map +0 -1
- package/dist/core/middleware.d.ts +0 -8
- package/dist/core/middleware.js +0 -23
- package/dist/core/middleware.js.map +0 -1
- package/dist/core/openapi.d.ts +0 -80
- package/dist/core/openapi.js +0 -189
- package/dist/core/openapi.js.map +0 -1
- package/dist/core/utils.d.ts +0 -7
- package/dist/core/utils.js +0 -75
- package/dist/core/utils.js.map +0 -1
- package/dist/core/validation.d.ts +0 -15
- package/dist/core/validation.js +0 -161
- package/dist/core/validation.js.map +0 -1
- package/dist/events/core/event-bus.d.ts +0 -26
- package/dist/events/core/event-bus.js +0 -253
- package/dist/events/core/event-bus.js.map +0 -1
- package/dist/events/core/event-registry.d.ts +0 -31
- package/dist/events/core/event-registry.js +0 -170
- package/dist/events/core/event-registry.js.map +0 -1
- package/dist/events/decorators/event.decorators.d.ts +0 -11
- package/dist/events/decorators/event.decorators.js +0 -123
- package/dist/events/decorators/event.decorators.js.map +0 -1
- package/dist/events/examples/system.events.d.ts +0 -15
- package/dist/events/examples/system.events.js.map +0 -1
- package/dist/events/examples/user.events.d.ts +0 -68
- package/dist/events/examples/user.events.js +0 -73
- package/dist/events/examples/user.events.js.map +0 -1
- package/dist/events/examples/user.handlers.d.ts +0 -20
- package/dist/events/examples/user.handlers.js +0 -157
- package/dist/events/examples/user.handlers.js.map +0 -1
- package/dist/events/middleware/logging.middleware.d.ts +0 -7
- package/dist/events/middleware/logging.middleware.js +0 -44
- package/dist/events/middleware/logging.middleware.js.map +0 -1
- package/dist/events/middleware/metrics.middleware.d.ts +0 -11
- package/dist/events/middleware/metrics.middleware.js +0 -87
- package/dist/events/middleware/metrics.middleware.js.map +0 -1
- package/dist/events/middleware/validation.middleware.d.ts +0 -8
- package/dist/events/middleware/validation.middleware.js +0 -63
- package/dist/events/middleware/validation.middleware.js.map +0 -1
- package/dist/events/store/memory-event-store.d.ts +0 -21
- package/dist/events/store/memory-event-store.js +0 -81
- package/dist/events/store/memory-event-store.js.map +0 -1
- package/dist/events/types/event.types.d.ts +0 -57
- package/dist/events/types/event.types.js.map +0 -1
- package/dist/examples/basic-api.d.ts +0 -1
- package/dist/examples/basic-api.js +0 -120
- package/dist/examples/basic-api.js.map +0 -1
- package/dist/logging/core/log-context.service.d.ts +0 -11
- package/dist/logging/core/log-context.service.js +0 -40
- package/dist/logging/core/log-context.service.js.map +0 -1
- package/dist/logging/core/startup-logger.service.js.map +0 -1
- package/dist/logging/decorators/log.decorator.d.ts +0 -11
- package/dist/logging/decorators/log.decorator.js +0 -80
- package/dist/logging/decorators/log.decorator.js.map +0 -1
- package/dist/logging/middleware/context.middleware.d.ts +0 -2
- package/dist/logging/middleware/context.middleware.js +0 -29
- package/dist/logging/middleware/context.middleware.js.map +0 -1
- package/dist/logging/middleware/request-logging.middleware.d.ts +0 -3
- package/dist/logging/middleware/request-logging.middleware.js +0 -78
- package/dist/logging/middleware/request-logging.middleware.js.map +0 -1
- package/dist/logging/types/logging.types.d.ts +0 -79
- package/dist/logging/types/logging.types.js +0 -3
- package/dist/logging/types/logging.types.js.map +0 -1
- package/dist/middlewares/auth.middleware.d.ts +0 -2
- package/dist/middlewares/auth.middleware.js +0 -20
- package/dist/middlewares/auth.middleware.js.map +0 -1
- package/dist/middlewares/cors.middleware.d.ts +0 -2
- package/dist/middlewares/cors.middleware.js +0 -16
- package/dist/middlewares/cors.middleware.js.map +0 -1
- package/dist/middlewares/swagger.middleware.d.ts +0 -6
- package/dist/middlewares/swagger.middleware.js +0 -84
- package/dist/middlewares/swagger.middleware.js.map +0 -1
- package/dist/repositories/user.repository.d.ts +0 -16
- package/dist/repositories/user.repository.js +0 -110
- package/dist/repositories/user.repository.js.map +0 -1
- package/dist/schemas/user.schemas.d.ts +0 -214
- package/dist/schemas/user.schemas.js +0 -71
- package/dist/schemas/user.schemas.js.map +0 -1
- package/dist/services/config-demo.service.d.ts +0 -10
- package/dist/services/config-demo.service.js +0 -88
- package/dist/services/config-demo.service.js.map +0 -1
- package/dist/services/user.service.d.ts +0 -21
- package/dist/services/user.service.js +0 -201
- package/dist/services/user.service.js.map +0 -1
- /package/dist/events/{types/event.types.js → event.types.js} +0 -0
@@ -1,28 +1,44 @@
|
|
1
1
|
import 'reflect-metadata';
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
import { ZodSchema } from 'zod';
|
3
|
+
import { FastifyRequest, FastifyReply } from 'fastify';
|
4
|
+
import { ComponentOptions } from './di-container';
|
5
|
+
export declare const METADATA_KEYS: {
|
6
|
+
controllerPrefix: string;
|
7
|
+
routes: string;
|
8
|
+
validationSchema: string;
|
9
|
+
paramTypes: string;
|
10
|
+
middleware: string;
|
11
|
+
autowiredProperties: string;
|
12
|
+
autowiredParams: string;
|
13
|
+
};
|
14
|
+
export type FastifyMiddleware = (request: FastifyRequest, reply: FastifyReply) => Promise<void> | void;
|
15
|
+
export declare const Component: (options?: ComponentOptions) => ClassDecorator;
|
16
|
+
export declare const Service: (options?: ComponentOptions) => ClassDecorator;
|
17
|
+
export declare const Repository: (options?: ComponentOptions) => ClassDecorator;
|
9
18
|
export declare const Controller: (prefix?: string) => ClassDecorator;
|
10
19
|
export declare const Get: (path?: string) => MethodDecorator;
|
11
20
|
export declare const Post: (path?: string) => MethodDecorator;
|
12
21
|
export declare const Put: (path?: string) => MethodDecorator;
|
13
22
|
export declare const Delete: (path?: string) => MethodDecorator;
|
14
|
-
export declare const
|
15
|
-
export declare const
|
16
|
-
export declare const
|
17
|
-
export declare const Param: (name: string) =>
|
18
|
-
export declare const
|
19
|
-
export declare const
|
20
|
-
export
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
export declare const Patch: (path?: string) => MethodDecorator;
|
24
|
+
export declare const Body: () => (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
25
|
+
export declare const Query: (name?: string) => (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
26
|
+
export declare const Param: (name: string) => (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
27
|
+
export declare const Req: () => (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
28
|
+
export declare const Res: () => (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
29
|
+
export interface ValidationDecoratorOptions {
|
30
|
+
body?: ZodSchema<any>;
|
31
|
+
query?: ZodSchema<any>;
|
32
|
+
params?: ZodSchema<any>;
|
33
|
+
/**
|
34
|
+
* Define response schemas for different HTTP status codes.
|
35
|
+
* The key is the status code (e.g., 200, 201) and the value is the Zod schema.
|
36
|
+
*/
|
37
|
+
responses?: {
|
38
|
+
[statusCode: number]: ZodSchema<any>;
|
39
|
+
};
|
40
|
+
}
|
41
|
+
export declare const Schema: (schema: ValidationDecoratorOptions) => MethodDecorator;
|
42
|
+
export declare const UseMiddleware: (...middlewares: FastifyMiddleware[]) => MethodDecorator & ClassDecorator;
|
43
|
+
export declare const Autowired: (token?: any) => any;
|
44
|
+
//# sourceMappingURL=decorators.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/core/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAA;AACzB,OAAO,EAAK,SAAS,EAAE,MAAM,KAAK,CAAA;AAClC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAoB,MAAM,gBAAgB,CAAA;AAInE,eAAO,MAAM,aAAa;;;;;;;;CAQzB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,CAC9B,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,YAAY,KAChB,OAAO,CAAC,IAAI,CAAC,GA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;IACH,SAAS,CAAC,EAAE;QACV,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,CAAA;KACrC,CAAA;CACF;AASD,eAAO,MAAM,MAAM,WANO,0BAA0B,KAAG,eAMzB,CAAA;AAE9B,eAAO,MAAM,aAAa,GACxB,GAAG,aAAa,iBAAiB,EAAE,KAClC,eAAe,GAAG,cAWpB,CAAA;AA0DD,eAAO,MAAM,SAAS,GAAI,QAAQ,GAAG,KAAG,GAqCvC,CAAA"}
|
package/dist/core/decorators.js
CHANGED
@@ -1,204 +1,185 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.Autowired = exports.UseMiddleware = exports.Schema = exports.Res = exports.Req = exports.Param = exports.Query = exports.Body = exports.Patch = exports.Delete = exports.Put = exports.Post = exports.Get = exports.Controller = exports.Repository = exports.Service = exports.Component = exports.METADATA_KEYS = void 0;
|
4
4
|
require("reflect-metadata");
|
5
|
-
const
|
6
|
-
|
7
|
-
|
5
|
+
const di_container_1 = require("./di-container");
|
6
|
+
const component_registry_1 = require("./component-registry");
|
7
|
+
// --- Metadata Keys ---
|
8
|
+
exports.METADATA_KEYS = {
|
9
|
+
controllerPrefix: 'bootify:controller-prefix',
|
10
|
+
routes: 'bootify:routes',
|
11
|
+
validationSchema: 'bootify:validation-schema',
|
12
|
+
paramTypes: 'bootify:param-types',
|
13
|
+
middleware: 'bootify:middleware',
|
14
|
+
autowiredProperties: 'bootify:autowired-properties',
|
15
|
+
autowiredParams: 'bootify:autowired-params',
|
16
|
+
};
|
17
|
+
// export interface ComponentOptions {
|
18
|
+
// scope?: Scope
|
19
|
+
// /**
|
20
|
+
// * An array of tokens that this class should be bound to in the DI container.
|
21
|
+
// * Allows this class to be injected using an interface or symbol.
|
22
|
+
// */
|
23
|
+
// bindTo?: any[]
|
24
|
+
// }
|
25
|
+
const Component = (options = {}) => {
|
8
26
|
return (target) => {
|
9
|
-
|
10
|
-
|
11
|
-
};
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
27
|
+
const scope = options.scope || di_container_1.Scope.SINGLETON;
|
28
|
+
// 1. Register the class by its own type (as before)
|
29
|
+
di_container_1.container.register(target, { useClass: target, scope: scope });
|
30
|
+
// 2. Add to the global component registry (as before)
|
31
|
+
component_registry_1.registeredComponents.add(target);
|
32
|
+
// 3. NEW: Automatically handle the interface/token bindings
|
33
|
+
if (options.bindTo && Array.isArray(options.bindTo)) {
|
34
|
+
console.log(`[DI] Binding '${target.name}' to tokens: [${options.bindTo
|
35
|
+
.map((t) => String(t))
|
36
|
+
.join(', ')}]`);
|
37
|
+
for (const token of options.bindTo) {
|
38
|
+
// Map the abstract token to this concrete class
|
39
|
+
di_container_1.container.register(token, { useClass: target, scope: scope });
|
40
|
+
}
|
41
|
+
}
|
16
42
|
};
|
17
43
|
};
|
44
|
+
exports.Component = Component;
|
45
|
+
const Service = (options = {}) => (0, exports.Component)(options);
|
18
46
|
exports.Service = Service;
|
19
|
-
|
20
|
-
|
21
|
-
container_1.container.register(target, scope);
|
22
|
-
};
|
23
|
-
};
|
47
|
+
// Repository can also be updated
|
48
|
+
const Repository = (options = {}) => (0, exports.Component)(options);
|
24
49
|
exports.Repository = Repository;
|
25
|
-
const Controller = (prefix = '') => {
|
26
|
-
|
27
|
-
|
28
|
-
container_1.container.register(target);
|
29
|
-
};
|
50
|
+
const Controller = (prefix = '') => (target) => {
|
51
|
+
Reflect.defineMetadata(exports.METADATA_KEYS.controllerPrefix, prefix, target);
|
52
|
+
di_container_1.container.register(target, { useClass: target, scope: di_container_1.Scope.SINGLETON });
|
30
53
|
};
|
31
54
|
exports.Controller = Controller;
|
32
|
-
|
33
|
-
const Get = (path = '') => {
|
34
|
-
return (target, propertyKey) => {
|
35
|
-
Reflect.defineMetadata('route:method', 'GET', target, propertyKey);
|
36
|
-
Reflect.defineMetadata('route:path', path, target, propertyKey);
|
37
|
-
};
|
38
|
-
};
|
39
|
-
exports.Get = Get;
|
40
|
-
const Post = (path = '') => {
|
41
|
-
return (target, propertyKey) => {
|
42
|
-
Reflect.defineMetadata('route:method', 'POST', target, propertyKey);
|
43
|
-
Reflect.defineMetadata('route:path', path, target, propertyKey);
|
44
|
-
};
|
45
|
-
};
|
46
|
-
exports.Post = Post;
|
47
|
-
const Put = (path = '') => {
|
48
|
-
return (target, propertyKey) => {
|
49
|
-
Reflect.defineMetadata('route:method', 'PUT', target, propertyKey);
|
50
|
-
Reflect.defineMetadata('route:path', path, target, propertyKey);
|
51
|
-
};
|
52
|
-
};
|
53
|
-
exports.Put = Put;
|
54
|
-
const Delete = (path = '') => {
|
55
|
+
const createRouteDecorator = (method) => (path = '/') => {
|
55
56
|
return (target, propertyKey) => {
|
56
|
-
Reflect.
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
exports.
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
};
|
78
|
-
};
|
57
|
+
const routes = Reflect.getMetadata(exports.METADATA_KEYS.routes, target.constructor) || [];
|
58
|
+
routes.push({
|
59
|
+
method,
|
60
|
+
path,
|
61
|
+
handlerName: propertyKey,
|
62
|
+
});
|
63
|
+
Reflect.defineMetadata(exports.METADATA_KEYS.routes, routes, target.constructor);
|
64
|
+
};
|
65
|
+
};
|
66
|
+
exports.Get = createRouteDecorator('GET');
|
67
|
+
exports.Post = createRouteDecorator('POST');
|
68
|
+
exports.Put = createRouteDecorator('PUT');
|
69
|
+
exports.Delete = createRouteDecorator('DELETE');
|
70
|
+
exports.Patch = createRouteDecorator('PATCH');
|
71
|
+
// --- Parameter Decorators ---
|
72
|
+
const createParamDecorator = (type, name) => (target, propertyKey, parameterIndex) => {
|
73
|
+
const params = Reflect.getMetadata(exports.METADATA_KEYS.paramTypes, target, propertyKey) || [];
|
74
|
+
params[parameterIndex] = { type, name };
|
75
|
+
Reflect.defineMetadata(exports.METADATA_KEYS.paramTypes, params, target, propertyKey);
|
76
|
+
};
|
77
|
+
const Body = () => createParamDecorator('body');
|
79
78
|
exports.Body = Body;
|
80
|
-
const
|
81
|
-
|
82
|
-
|
83
|
-
};
|
84
|
-
};
|
79
|
+
const Query = (name) => createParamDecorator('query', name);
|
80
|
+
exports.Query = Query;
|
81
|
+
const Param = (name) => createParamDecorator('param', name);
|
85
82
|
exports.Param = Param;
|
86
|
-
const
|
87
|
-
|
88
|
-
|
83
|
+
const Req = () => createParamDecorator('request');
|
84
|
+
exports.Req = Req;
|
85
|
+
const Res = () => createParamDecorator('reply');
|
86
|
+
exports.Res = Res;
|
87
|
+
// --- Validation Decorators ---
|
88
|
+
const Validate = (schema) => {
|
89
|
+
return (target, propertyKey) => {
|
90
|
+
Reflect.defineMetadata(exports.METADATA_KEYS.validationSchema, schema, target, propertyKey);
|
89
91
|
};
|
90
92
|
};
|
91
|
-
exports.
|
92
|
-
// Middleware Decorators
|
93
|
+
exports.Schema = Validate;
|
93
94
|
const UseMiddleware = (...middlewares) => {
|
94
95
|
return (target, propertyKey) => {
|
96
|
+
const key = exports.METADATA_KEYS.middleware;
|
95
97
|
if (propertyKey) {
|
96
|
-
// Method
|
97
|
-
Reflect.defineMetadata(
|
98
|
+
// Method Decorator
|
99
|
+
Reflect.defineMetadata(key, middlewares, target, propertyKey);
|
98
100
|
}
|
99
101
|
else {
|
100
|
-
// Class
|
101
|
-
Reflect.defineMetadata(
|
102
|
+
// Class Decorator
|
103
|
+
Reflect.defineMetadata(key, middlewares, target);
|
102
104
|
}
|
103
105
|
};
|
104
106
|
};
|
105
107
|
exports.UseMiddleware = UseMiddleware;
|
106
|
-
//
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
//
|
140
|
-
|
108
|
+
// export const Autowired = (): PropertyDecorator => {
|
109
|
+
// return (target: any, propertyKey: string | symbol) => {
|
110
|
+
// // Get the type of the property being decorated (e.g., TodoService class)
|
111
|
+
// const propertyType = Reflect.getMetadata('design:type', target, propertyKey)
|
112
|
+
// if (!propertyType) {
|
113
|
+
// throw new Error(
|
114
|
+
// `Could not resolve type for property '${String(propertyKey)}' on class '${
|
115
|
+
// target.constructor.name
|
116
|
+
// }'. Make sure 'emitDecoratorMetadata' is true in your tsconfig.json and the type is not a primitive or interface.`
|
117
|
+
// )
|
118
|
+
// }
|
119
|
+
// // Get existing autowired properties for the target class or initialize a new array
|
120
|
+
// const properties =
|
121
|
+
// Reflect.getMetadata(METADATA_KEYS.autowiredProperties, target.constructor) || []
|
122
|
+
// properties.push({
|
123
|
+
// propertyKey,
|
124
|
+
// type: propertyType,
|
125
|
+
// })
|
126
|
+
// // Save the updated list of properties back to the class metadata
|
127
|
+
// Reflect.defineMetadata(METADATA_KEYS.autowiredProperties, properties, target.constructor)
|
128
|
+
// }
|
129
|
+
// }
|
130
|
+
// export const Autowired = (token?: any): any => {
|
131
|
+
// return (target: any, propertyKey: string | symbol | undefined, parameterIndex?: number) => {
|
132
|
+
// // Check if it's being used as a Parameter Decorator
|
133
|
+
// if (typeof parameterIndex === 'number') {
|
134
|
+
// const constructorParams = Reflect.getMetadata('autowired:params', target) || []
|
135
|
+
// constructorParams[parameterIndex] = token
|
136
|
+
// Reflect.defineMetadata('autowired:params', constructorParams, target)
|
137
|
+
// return
|
138
|
+
// }
|
139
|
+
// // Existing Property Decorator logic
|
140
|
+
// const propertyType = propertyKey
|
141
|
+
// ? Reflect.getMetadata('design:type', target, propertyKey)
|
142
|
+
// : undefined
|
143
|
+
// if (!propertyType) {
|
144
|
+
// /* ... error handling ... */
|
145
|
+
// }
|
146
|
+
// const properties =
|
147
|
+
// Reflect.getMetadata(METADATA_KEYS.autowiredProperties, target.constructor) || []
|
148
|
+
// properties.push({
|
149
|
+
// propertyKey,
|
150
|
+
// // Use the explicit token if provided, otherwise fall back to the type
|
151
|
+
// token: token || propertyType,
|
152
|
+
// })
|
153
|
+
// Reflect.defineMetadata(METADATA_KEYS.autowiredProperties, properties, target.constructor)
|
154
|
+
// }
|
155
|
+
// }
|
156
|
+
const Autowired = (token) => {
|
141
157
|
return (target, propertyKey, parameterIndex) => {
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
return (target) => {
|
152
|
-
const existingMeta = Reflect.getMetadata('openapi:controller', target) || {};
|
153
|
-
existingMeta.tags = [...(existingMeta.tags || []), ...tags];
|
154
|
-
Reflect.defineMetadata('openapi:controller', existingMeta, target);
|
155
|
-
};
|
156
|
-
};
|
157
|
-
exports.ApiTags = ApiTags;
|
158
|
-
const ApiSecurity = (security) => {
|
159
|
-
return (target, propertyKey) => {
|
160
|
-
if (propertyKey) {
|
161
|
-
// Method decorator
|
162
|
-
const existingMeta = Reflect.getMetadata('openapi:method', target, propertyKey) || {};
|
163
|
-
existingMeta.security = security;
|
164
|
-
Reflect.defineMetadata('openapi:method', existingMeta, target, propertyKey);
|
158
|
+
// Constructor Parameter Injection
|
159
|
+
if (typeof parameterIndex === 'number') {
|
160
|
+
if (!token) {
|
161
|
+
throw new Error(`[DI] @Autowired token is required for constructor parameter injection in '${target.name}'. This is needed for interfaces.`);
|
162
|
+
}
|
163
|
+
const constructorParams = Reflect.getMetadata(exports.METADATA_KEYS.autowiredParams, target) || [];
|
164
|
+
constructorParams[parameterIndex] = token;
|
165
|
+
Reflect.defineMetadata(exports.METADATA_KEYS.autowiredParams, constructorParams, target);
|
166
|
+
return;
|
165
167
|
}
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
168
|
+
// Property (Field) Injection
|
169
|
+
const propertyType = propertyKey
|
170
|
+
? Reflect.getMetadata('design:type', target, propertyKey)
|
171
|
+
: undefined;
|
172
|
+
const properties = Reflect.getMetadata(exports.METADATA_KEYS.autowiredProperties, target.constructor) || [];
|
173
|
+
const tokenToInject = token || propertyType;
|
174
|
+
if (!tokenToInject) {
|
175
|
+
throw new Error(`[DI] Could not resolve type for property '${String(propertyKey)}' on class '${target.constructor.name}'.`);
|
171
176
|
}
|
177
|
+
properties.push({
|
178
|
+
propertyKey,
|
179
|
+
token: tokenToInject,
|
180
|
+
});
|
181
|
+
Reflect.defineMetadata(exports.METADATA_KEYS.autowiredProperties, properties, target.constructor);
|
172
182
|
};
|
173
183
|
};
|
174
|
-
exports.
|
175
|
-
const ApiResponse = (statusCode, response) => {
|
176
|
-
return (target, propertyKey) => {
|
177
|
-
if (propertyKey) {
|
178
|
-
// Method decorator
|
179
|
-
const existingMeta = Reflect.getMetadata('openapi:method', target, propertyKey) || {};
|
180
|
-
if (!existingMeta.responses)
|
181
|
-
existingMeta.responses = {};
|
182
|
-
existingMeta.responses[statusCode.toString()] = response;
|
183
|
-
Reflect.defineMetadata('openapi:method', existingMeta, target, propertyKey);
|
184
|
-
}
|
185
|
-
else {
|
186
|
-
// Class decorator
|
187
|
-
const existingMeta = Reflect.getMetadata('openapi:controller', target) || {};
|
188
|
-
if (!existingMeta.responses)
|
189
|
-
existingMeta.responses = {};
|
190
|
-
existingMeta.responses[statusCode.toString()] = response;
|
191
|
-
Reflect.defineMetadata('openapi:controller', existingMeta, target);
|
192
|
-
}
|
193
|
-
};
|
194
|
-
};
|
195
|
-
exports.ApiResponse = ApiResponse;
|
196
|
-
const ApiOperation = (operation) => {
|
197
|
-
return (target, propertyKey) => {
|
198
|
-
const existingMeta = Reflect.getMetadata('openapi:method', target, propertyKey) || {};
|
199
|
-
existingMeta.operation = operation;
|
200
|
-
Reflect.defineMetadata('openapi:method', existingMeta, target, propertyKey);
|
201
|
-
};
|
202
|
-
};
|
203
|
-
exports.ApiOperation = ApiOperation;
|
184
|
+
exports.Autowired = Autowired;
|
204
185
|
//# sourceMappingURL=decorators.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/core/decorators.ts"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/core/decorators.ts"],"names":[],"mappings":";;;AAAA,4BAAyB;AAGzB,iDAAmE;AACnE,6DAA2D;AAE3D,wBAAwB;AACX,QAAA,aAAa,GAAG;IAC3B,gBAAgB,EAAE,2BAA2B;IAC7C,MAAM,EAAE,gBAAgB;IACxB,gBAAgB,EAAE,2BAA2B;IAC7C,UAAU,EAAE,qBAAqB;IACjC,UAAU,EAAE,oBAAoB;IAChC,mBAAmB,EAAE,8BAA8B;IACnD,eAAe,EAAE,0BAA0B;CAC5C,CAAA;AAOD,sCAAsC;AACtC,kBAAkB;AAClB,QAAQ;AACR,kFAAkF;AAClF,sEAAsE;AACtE,QAAQ;AACR,mBAAmB;AACnB,IAAI;AACG,MAAM,SAAS,GAAG,CAAC,UAA4B,EAAE,EAAkB,EAAE;IAC1E,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,oBAAK,CAAC,SAAS,CAAA;QAE9C,oDAAoD;QACpD,wBAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAY,EAAE,CAAC,CAAA;QAErE,sDAAsD;QACtD,yCAAoB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QAEhC,4DAA4D;QAC5D,IAAI,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,E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AC,WAAW,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,CAAC;YACzD,CAAC,CAAC,SAAS,CAAA;QACb,MAAM,UAAU,GACd,OAAO,CAAC,WAAW,CAAC,qBAAa,CAAC,mBAAmB,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAA;QAElF,MAAM,aAAa,GAAG,KAAK,IAAI,YAAY,CAAA;QAC3C,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CACb,6CAA6C,MAAM,CAAC,WAAW,CAAC,eAC9D,MAAM,CAAC,WAAW,CAAC,IACrB,IAAI,CACL,CAAA;QACH,CAAC;QAED,UAAU,CAAC,IAAI,CAAC;YACd,WAAW;YACX,KAAK,EAAE,aAAa;SACrB,CAAC,CAAA;QACF,OAAO,CAAC,cAAc,CAAC,qBAAa,CAAC,mBAAmB,EAAE,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,CAAA;IAC3F,CAAC,CAAA;AACH,CAAC,CAAA;AArCY,QAAA,SAAS,aAqCrB"}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
export declare enum Scope {
|
2
|
+
SINGLETON = "singleton",
|
3
|
+
TRANSIENT = "transient"
|
4
|
+
}
|
5
|
+
import 'reflect-metadata';
|
6
|
+
export type Constructor<T = any> = new (...args: any[]) => T;
|
7
|
+
export type DiToken = any;
|
8
|
+
export type BindingScope = 'Singleton' | 'Transient';
|
9
|
+
export interface ComponentOptions {
|
10
|
+
bindTo?: DiToken[];
|
11
|
+
scope?: BindingScope;
|
12
|
+
eager?: boolean;
|
13
|
+
}
|
14
|
+
export interface RegistrationOptions {
|
15
|
+
useClass?: Constructor;
|
16
|
+
useFactory?: () => any;
|
17
|
+
scope?: BindingScope;
|
18
|
+
}
|
19
|
+
export declare const eagerIdentifiers: Set<any>;
|
20
|
+
export declare class Container {
|
21
|
+
private readonly services;
|
22
|
+
private readonly resolving;
|
23
|
+
register(token: DiToken, options: RegistrationOptions): void;
|
24
|
+
resolve<T>(token: DiToken): T;
|
25
|
+
private resolveConstructorArgs;
|
26
|
+
private performPropertyInjection;
|
27
|
+
getRegisteredComponents(): Constructor[];
|
28
|
+
isRegistered(token: DiToken): boolean;
|
29
|
+
}
|
30
|
+
export declare const container: Container;
|
31
|
+
//# sourceMappingURL=di-container.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"di-container.d.ts","sourceRoot":"","sources":["../../src/core/di-container.ts"],"names":[],"mappings":"AAMA,oBAAY,KAAK;IACf,SAAS,cAAc;IACvB,SAAS,cAAc;CACxB;AAkJD,OAAO,kBAAkB,CAAA;AAIzB,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,GAAG,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;AAC5D,MAAM,MAAM,OAAO,GAAG,GAAG,CAAA;AACzB,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,WAAW,CAAA;AAEpD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,OAAO,EAAE,CAAA;IAClB,KAAK,CAAC,EAAE,YAAY,CAAA;IACpB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,WAAW,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,GAAG,CAAA;IACtB,KAAK,CAAC,EAAE,YAAY,CAAA;CACrB;AAUD,eAAO,MAAM,gBAAgB,UAAqB,CAAA;AAGlD,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAwC;IACjE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAExC,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,mBAAmB,GAAG,IAAI;IAa5D,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC;IA2CpC,OAAO,CAAC,sBAAsB;IAgB9B,OAAO,CAAC,wBAAwB;IAQzB,uBAAuB,IAAI,WAAW,EAAE;IAKxC,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;CAG7C;AAED,eAAO,MAAM,SAAS,WAAkB,CAAA"}
|