@zerooneit/expressive-tea 1.3.0-beta.5 → 2.0.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.
Files changed (77) hide show
  1. package/.gitattributes +4 -0
  2. package/.swcrc +61 -0
  3. package/README.md +564 -174
  4. package/classes/Boot.d.ts +94 -3
  5. package/classes/Boot.js +171 -51
  6. package/classes/Engine.d.ts +59 -10
  7. package/classes/Engine.js +72 -11
  8. package/classes/EngineRegistry.d.ts +154 -0
  9. package/classes/EngineRegistry.js +247 -0
  10. package/classes/LoadBalancer.js +2 -5
  11. package/classes/ProxyRoute.d.ts +3 -3
  12. package/classes/ProxyRoute.js +5 -5
  13. package/classes/Settings.d.ts +31 -2
  14. package/classes/Settings.js +64 -11
  15. package/decorators/annotations.d.ts +1 -1
  16. package/decorators/annotations.js +17 -17
  17. package/decorators/env.d.ts +145 -0
  18. package/decorators/env.js +177 -0
  19. package/decorators/health.d.ts +115 -0
  20. package/decorators/health.js +124 -0
  21. package/decorators/module.d.ts +15 -15
  22. package/decorators/module.js +14 -23
  23. package/decorators/proxy.d.ts +26 -11
  24. package/decorators/proxy.js +35 -45
  25. package/decorators/router.d.ts +17 -16
  26. package/decorators/router.js +32 -52
  27. package/decorators/server.d.ts +8 -8
  28. package/decorators/server.js +48 -50
  29. package/engines/health/index.d.ts +120 -0
  30. package/engines/health/index.js +179 -0
  31. package/engines/http/index.d.ts +6 -7
  32. package/engines/http/index.js +22 -17
  33. package/engines/index.d.ts +32 -0
  34. package/engines/index.js +112 -0
  35. package/engines/socketio/index.d.ts +2 -1
  36. package/engines/socketio/index.js +16 -6
  37. package/engines/teacup/index.d.ts +13 -0
  38. package/engines/teacup/index.js +61 -11
  39. package/engines/teapot/index.d.ts +15 -2
  40. package/engines/teapot/index.js +61 -13
  41. package/engines/websocket/index.d.ts +4 -1
  42. package/engines/websocket/index.js +10 -2
  43. package/eslint.config.mjs +138 -0
  44. package/exceptions/RequestExceptions.d.ts +3 -3
  45. package/helpers/boot-helper.d.ts +6 -6
  46. package/helpers/boot-helper.js +30 -24
  47. package/helpers/decorators.js +7 -6
  48. package/helpers/promise-helper.d.ts +1 -1
  49. package/helpers/promise-helper.js +1 -2
  50. package/helpers/server.d.ts +32 -6
  51. package/helpers/server.js +101 -61
  52. package/helpers/teapot-helper.d.ts +5 -8
  53. package/helpers/teapot-helper.js +39 -11
  54. package/helpers/websocket-helper.d.ts +3 -5
  55. package/helpers/websocket-helper.js +3 -3
  56. package/interfaces/index.d.ts +1 -1
  57. package/inversify.config.d.ts +4 -4
  58. package/inversify.config.js +1 -1
  59. package/libs/utilities.d.ts +21910 -0
  60. package/libs/utilities.js +420 -0
  61. package/mixins/module.d.ts +45 -0
  62. package/mixins/module.js +71 -0
  63. package/mixins/proxy.d.ts +46 -0
  64. package/mixins/proxy.js +86 -0
  65. package/mixins/route.d.ts +48 -0
  66. package/mixins/route.js +96 -0
  67. package/package.json +91 -69
  68. package/services/DependencyInjection.d.ts +95 -7
  69. package/services/DependencyInjection.js +123 -5
  70. package/services/WebsocketService.d.ts +4 -6
  71. package/services/WebsocketService.js +5 -3
  72. package/types/core.d.ts +14 -0
  73. package/types/core.js +2 -0
  74. package/types/injection-types.d.ts +6 -0
  75. package/types/injection-types.js +10 -0
  76. package/types/inversify.d.ts +5 -0
  77. package/types/inversify.js +3 -0
@@ -1,5 +1,6 @@
1
- import { Express, Router } from 'express';
2
- import { ExpressiveTeaModuleProps } from '@expressive-tea/commons/interfaces';
1
+ import { type ExpressiveTeaModuleProps } from '@expressive-tea/commons';
2
+ import { type Constructor } from '../types/core';
3
+ import { type ModulizedClass } from '../mixins/module';
3
4
  /**
4
5
  * @typedef {Object} ExpressiveTeaModuleProps
5
6
  * @property {Object[]} controllers Controllers Assigned to Module
@@ -13,22 +14,21 @@ import { ExpressiveTeaModuleProps } from '@expressive-tea/commons/interfaces';
13
14
  * Module Decorator is a Class Decorator which is help to register a Module into Expressive Tea. A module is a
14
15
  * placeholder over a mountpoint. We can considerate a module like a container which provide isolation and modularity
15
16
  * for our project. This module can be mounted in different applications and will move all the controller routes too.
17
+ *
16
18
  * @decorator {ClassDecorator} Module - Module Class Register Decorator
17
- * @param {ExpressiveTeaModuleProps} options
19
+ * @template TBase - The base constructor type being decorated
20
+ * @param {ExpressiveTeaModuleProps} options - Module configuration options
21
+ * @returns {(target: TBase) => ModulizedClass<TBase>} Decorator function that returns a modulized class
18
22
  * @summary Module Decorator
23
+ *
19
24
  * @example
20
25
  * {REPLACE-AT}Module({
21
- * controllers: [],
22
- * providers: [],
23
- * mountpoint: '/'
26
+ * controllers: [UserController],
27
+ * providers: [UserService],
28
+ * mountpoint: '/api'
24
29
  * })
25
- * class Example {}
30
+ * class ApiModule {}
31
+ *
32
+ * @since 1.0.0
26
33
  */
27
- export declare function Module(options: ExpressiveTeaModuleProps): <T extends new (...args: any[]) => {}>(Module: T) => {
28
- new (...args: any[]): {
29
- readonly settings: ExpressiveTeaModuleProps;
30
- readonly router: Router;
31
- readonly controllers: any[];
32
- __register(server: Express): void;
33
- };
34
- } & T;
34
+ export declare function Module<TBase extends Constructor = Constructor>(options: ExpressiveTeaModuleProps): (target: TBase) => ModulizedClass<TBase>;
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Module = void 0;
4
- const express_1 = require("express");
5
- const lodash_1 = require("lodash");
6
- const DependencyInjection_1 = require("../services/DependencyInjection");
3
+ exports.Module = Module;
4
+ const module_1 = require("../mixins/module");
7
5
  /**
8
6
  * @typedef {Object} ExpressiveTeaModuleProps
9
7
  * @property {Object[]} controllers Controllers Assigned to Module
@@ -17,32 +15,25 @@ const DependencyInjection_1 = require("../services/DependencyInjection");
17
15
  * Module Decorator is a Class Decorator which is help to register a Module into Expressive Tea. A module is a
18
16
  * placeholder over a mountpoint. We can considerate a module like a container which provide isolation and modularity
19
17
  * for our project. This module can be mounted in different applications and will move all the controller routes too.
18
+ *
20
19
  * @decorator {ClassDecorator} Module - Module Class Register Decorator
21
- * @param {ExpressiveTeaModuleProps} options
20
+ * @template TBase - The base constructor type being decorated
21
+ * @param {ExpressiveTeaModuleProps} options - Module configuration options
22
+ * @returns {(target: TBase) => ModulizedClass<TBase>} Decorator function that returns a modulized class
22
23
  * @summary Module Decorator
24
+ *
23
25
  * @example
24
26
  * {REPLACE-AT}Module({
25
- * controllers: [],
26
- * providers: [],
27
- * mountpoint: '/'
27
+ * controllers: [UserController],
28
+ * providers: [UserService],
29
+ * mountpoint: '/api'
28
30
  * })
29
- * class Example {}
31
+ * class ApiModule {}
32
+ *
33
+ * @since 1.0.0
30
34
  */
31
35
  function Module(options) {
32
36
  return (Module) => {
33
- return class ExpressiveTeaModule extends Module {
34
- constructor(...args) {
35
- super(...args);
36
- this.router = (0, express_1.Router)();
37
- this.settings = options;
38
- (0, lodash_1.each)(this.settings.providers, P => DependencyInjection_1.default.setProvider(P));
39
- this.controllers = (0, lodash_1.map)(this.settings.controllers, C => new C());
40
- }
41
- __register(server) {
42
- (0, lodash_1.each)(this.controllers, c => c.__mount(this.router));
43
- server.use(this.settings.mountpoint, this.router);
44
- }
45
- };
37
+ return (0, module_1.Modulize)(Module, options);
46
38
  };
47
39
  }
48
- exports.Module = Module;
@@ -1,13 +1,28 @@
1
- import { ExpressiveTeaProxyOptions, ExpressiveTeaProxyProperty, MethodDecorator } from '@expressive-tea/commons/types';
2
- import { Express, RequestHandler } from 'express';
3
- export declare function ProxyContainer(source: string, targetUrl: string): <T extends new (...args: any[]) => any>(ProxyContainerClass: T) => {
4
- new (...args: any[]): {
5
- [x: string]: any;
6
- readonly source: string;
7
- readonly target: string;
8
- readonly proxyHandler: RequestHandler;
9
- __register(server: Express): void;
10
- };
11
- } & T;
1
+ import { type ExpressiveTeaProxyOptions, type ExpressiveTeaProxyProperty, type MethodDecorator } from '@expressive-tea/commons';
2
+ import { type ProxifiedClass } from '../mixins/proxy';
3
+ import { type Constructor } from '../types/core';
4
+ /**
5
+ * ProxyContainer decorator - Creates an HTTP proxy for a microservice
6
+ *
7
+ * Transforms a class into an HTTP proxy that forwards requests from a source path
8
+ * to a target URL. Supports custom request/response transformations and options.
9
+ *
10
+ * @template TBase - The base constructor type being decorated
11
+ * @param {string} source - The source path to proxy from (e.g., '/api')
12
+ * @param {string} targetUrl - The target URL to proxy to (e.g., 'http://api.example.com')
13
+ * @returns {(target: TBase) => ProxifiedClass<TBase>} Decorator function that returns a proxified class
14
+ *
15
+ * @example
16
+ * {REPLACE-AT}ProxyContainer('/api', 'http://api.example.com')
17
+ * class ApiProxy {
18
+ * {REPLACE-AT}ProxyOption('host')
19
+ * getHost() {
20
+ * return 'http://api.example.com';
21
+ * }
22
+ * }
23
+ *
24
+ * @since 1.0.0
25
+ */
26
+ export declare function ProxyContainer<TBase extends Constructor = Constructor>(source: string, targetUrl: string): (ProxyContainerClass: TBase) => ProxifiedClass<TBase>;
12
27
  export declare function ProxyOption(option: ExpressiveTeaProxyOptions): MethodDecorator;
13
28
  export declare function ProxyProperty(option: ExpressiveTeaProxyProperty, value: any): PropertyDecorator;
@@ -1,70 +1,60 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProxyProperty = exports.ProxyOption = exports.ProxyContainer = void 0;
4
- const Metadata_1 = require("@expressive-tea/commons/classes/Metadata");
5
- const httpProxy = require("express-http-proxy");
6
- const object_helper_1 = require("@expressive-tea/commons/helpers/object-helper");
7
- const lodash_1 = require("lodash");
3
+ exports.ProxyContainer = ProxyContainer;
4
+ exports.ProxyOption = ProxyOption;
5
+ exports.ProxyProperty = ProxyProperty;
6
+ const commons_1 = require("@expressive-tea/commons");
7
+ const commons_2 = require("@expressive-tea/commons");
8
8
  const RequestExceptions_1 = require("../exceptions/RequestExceptions");
9
- const constants_1 = require("@expressive-tea/commons/constants");
10
- const NON_ASYNC_METHODS = ['host'];
9
+ const commons_3 = require("@expressive-tea/commons");
10
+ const proxy_1 = require("../mixins/proxy");
11
+ const NON_ASYNC_METHODS = new Set(['host']);
12
+ /**
13
+ * ProxyContainer decorator - Creates an HTTP proxy for a microservice
14
+ *
15
+ * Transforms a class into an HTTP proxy that forwards requests from a source path
16
+ * to a target URL. Supports custom request/response transformations and options.
17
+ *
18
+ * @template TBase - The base constructor type being decorated
19
+ * @param {string} source - The source path to proxy from (e.g., '/api')
20
+ * @param {string} targetUrl - The target URL to proxy to (e.g., 'http://api.example.com')
21
+ * @returns {(target: TBase) => ProxifiedClass<TBase>} Decorator function that returns a proxified class
22
+ *
23
+ * @example
24
+ * {REPLACE-AT}ProxyContainer('/api', 'http://api.example.com')
25
+ * class ApiProxy {
26
+ * {REPLACE-AT}ProxyOption('host')
27
+ * getHost() {
28
+ * return 'http://api.example.com';
29
+ * }
30
+ * }
31
+ *
32
+ * @since 1.0.0
33
+ */
11
34
  function ProxyContainer(source, targetUrl) {
12
35
  return (ProxyContainerClass) => {
13
- class ExpressiveTeaProxy extends ProxyContainerClass {
14
- constructor(...args) {
15
- super(...args);
16
- this.source = source;
17
- this.target = targetUrl;
18
- const options = {};
19
- const host = Metadata_1.default.get(constants_1.PROXY_SETTING_KEY, this, constants_1.PROXY_METHODS.HOST);
20
- for (const value of Object.values(constants_1.PROXY_METHODS)) {
21
- if (value !== constants_1.PROXY_METHODS.HOST) {
22
- options[value] = Metadata_1.default.get(constants_1.PROXY_SETTING_KEY, this, value);
23
- }
24
- }
25
- for (const value of Object.values(constants_1.PROXY_PROPERTIES)) {
26
- const key = Metadata_1.default.get(constants_1.PROXY_SETTING_KEY, this, value);
27
- if (!(0, lodash_1.isUndefined)(key)) {
28
- // @ts-ignore:next-line
29
- options[value] = this[key];
30
- }
31
- }
32
- this.proxyHandler = httpProxy(host ? host.value.bind(this) : this.target);
33
- }
34
- __register(server) {
35
- const proxyMetadata = Metadata_1.default.get(constants_1.PROXY_SETTING_KEY, (0, object_helper_1.getClass)(this));
36
- console.info(`[PROXY - ${proxyMetadata.name}] ${this.source} -> ${this.target}`);
37
- server.use(this.source, this.proxyHandler);
38
- }
39
- }
40
- ;
41
36
  const settings = {
42
37
  source,
43
38
  targetUrl,
44
39
  name: ProxyContainerClass.name
45
40
  };
46
- Metadata_1.default.set(constants_1.PROXY_SETTING_KEY, settings, ProxyContainerClass);
47
- return ExpressiveTeaProxy;
41
+ commons_1.Metadata.set(commons_3.PROXY_SETTING_KEY, settings, ProxyContainerClass);
42
+ return (0, proxy_1.Proxify)(ProxyContainerClass, source, targetUrl);
48
43
  };
49
44
  }
50
- exports.ProxyContainer = ProxyContainer;
51
45
  function ProxyOption(option) {
52
46
  return (target, propertyKey, descriptor) => {
53
- if (NON_ASYNC_METHODS.includes(option) && (0, object_helper_1.isAsyncFunction)(descriptor.value)) {
47
+ if (NON_ASYNC_METHODS.has(option) && (0, commons_2.isAsyncFunction)(descriptor.value)) {
54
48
  throw new RequestExceptions_1.GenericRequestException(`${String(propertyKey)} must not be declared as Async Function.`);
55
49
  }
56
- Metadata_1.default.set(constants_1.PROXY_SETTING_KEY, descriptor, target, option);
50
+ commons_1.Metadata.set(commons_3.PROXY_SETTING_KEY, descriptor, target, option);
57
51
  };
58
52
  }
59
- exports.ProxyOption = ProxyOption;
60
53
  function ProxyProperty(option, value) {
61
54
  return (target, propertyKey) => {
62
- Metadata_1.default.set(constants_1.PROXY_SETTING_KEY, propertyKey, target, option);
63
- let currentValue = target[propertyKey];
55
+ commons_1.Metadata.set(commons_3.PROXY_SETTING_KEY, propertyKey, target, option);
64
56
  Object.defineProperty(target, propertyKey, {
65
57
  get: () => value,
66
- set: () => { currentValue = value; }
67
58
  });
68
59
  };
69
60
  }
70
- exports.ProxyProperty = ProxyProperty;
@@ -1,6 +1,7 @@
1
- import { Router } from 'express';
2
- import { ExpressiveTeaHandlerOptions } from '@expressive-tea/commons/interfaces';
3
- import { ClassDecorator, ExpressMiddlewareHandler, MethodDecorator } from '@expressive-tea/commons/types';
1
+ import { type ClassDecorator, type MethodDecorator } from '@expressive-tea/commons';
2
+ import { type RouterizedClass } from '../mixins/route';
3
+ import { type Constructor, TFunction } from '../types/core';
4
+ import { type RequestHandler } from 'express';
4
5
  /**
5
6
  * @module Decorators/Router
6
7
  */
@@ -11,21 +12,21 @@ import { ClassDecorator, ExpressMiddlewareHandler, MethodDecorator } from '@expr
11
12
  * to allow Expressive Tea Setting up the Controller as part of a Module.
12
13
  *
13
14
  * @decorator {ClassDecorator} Route - Assign a route to controller endpoints.
15
+ * @template TBase - The base constructor type being decorated
16
+ * @param {string} mountpoint - Register the url part to mount the Controller (default: '/')
17
+ * @returns {(target: TBase) => RouterizedClass<TBase>} Decorator function that returns a routerized class
14
18
  * @summary Generate a Placeholder endpoint root for controller routes.
15
- * @param {string} mountpoint Register the url part to mount the Controller.
19
+ *
16
20
  * @example
17
- * {REPLACE-AT}Route('/)
18
- * class Example {}
21
+ * {REPLACE-AT}Route('/users')
22
+ * class UserController {
23
+ * {REPLACE-AT}Get('/')
24
+ * getUsers() { return ['user1', 'user2']; }
25
+ * }
26
+ *
27
+ * @since 1.0.0
19
28
  */
20
- export declare function Route(mountpoint?: string): <T extends new (...args: any[]) => any>(RouterClass: T) => {
21
- new (...args: any[]): {
22
- [x: string]: any;
23
- readonly router: Router;
24
- readonly mountpoint: string;
25
- __mount(parent: Router): any;
26
- __registerHandler(options: ExpressiveTeaHandlerOptions): ExpressMiddlewareHandler;
27
- };
28
- } & T;
29
+ export declare function Route<TBase extends Constructor = Constructor>(mountpoint?: string): (RouterClass: TBase) => RouterizedClass<TBase>;
29
30
  /**
30
31
  * Define a GET Endpoint response over the controller router and can define in which route should be responds and
31
32
  * by default this is responding to everything on the controller root path.
@@ -178,7 +179,7 @@ export declare function Param(route?: string): (target: object, propertyKey: str
178
179
  *
179
180
  * @param {Function} middleware Register a middleware over router.
180
181
  */
181
- export declare function Middleware(middleware: any): ClassDecorator & MethodDecorator;
182
+ export declare function Middleware(middleware: RequestHandler | TFunction<RequestHandler>): ClassDecorator & MethodDecorator;
182
183
  /**
183
184
  * Will generate a GET route to respond rendering a view template setting up before; the controller method <b>MUST</b>
184
185
  * return an object in order to fulfilled the local variables into the view.
@@ -1,12 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.View = exports.Middleware = exports.Param = exports.Delete = exports.Patch = exports.Put = exports.Post = exports.Get = exports.Route = void 0;
4
- const express_1 = require("express");
5
- const lodash_1 = require("lodash");
6
- const Metadata_1 = require("@expressive-tea/commons/classes/Metadata");
3
+ exports.Route = Route;
4
+ exports.Get = Get;
5
+ exports.Post = Post;
6
+ exports.Put = Put;
7
+ exports.Patch = Patch;
8
+ exports.Delete = Delete;
9
+ exports.Param = Param;
10
+ exports.Middleware = Middleware;
11
+ exports.View = View;
12
+ const commons_1 = require("@expressive-tea/commons");
13
+ /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call */
7
14
  const decorators_1 = require("../helpers/decorators");
8
15
  const server_1 = require("../helpers/server");
9
- const constants_1 = require("@expressive-tea/commons/constants");
16
+ const commons_2 = require("@expressive-tea/commons");
17
+ const route_1 = require("../mixins/route");
10
18
  /**
11
19
  * @module Decorators/Router
12
20
  */
@@ -17,45 +25,25 @@ const constants_1 = require("@expressive-tea/commons/constants");
17
25
  * to allow Expressive Tea Setting up the Controller as part of a Module.
18
26
  *
19
27
  * @decorator {ClassDecorator} Route - Assign a route to controller endpoints.
28
+ * @template TBase - The base constructor type being decorated
29
+ * @param {string} mountpoint - Register the url part to mount the Controller (default: '/')
30
+ * @returns {(target: TBase) => RouterizedClass<TBase>} Decorator function that returns a routerized class
20
31
  * @summary Generate a Placeholder endpoint root for controller routes.
21
- * @param {string} mountpoint Register the url part to mount the Controller.
32
+ *
22
33
  * @example
23
- * {REPLACE-AT}Route('/)
24
- * class Example {}
34
+ * {REPLACE-AT}Route('/users')
35
+ * class UserController {
36
+ * {REPLACE-AT}Get('/')
37
+ * getUsers() { return ['user1', 'user2']; }
38
+ * }
39
+ *
40
+ * @since 1.0.0
25
41
  */
26
42
  function Route(mountpoint = '/') {
27
43
  return (RouterClass) => {
28
- return class ExpressiveTeaRoute extends RouterClass {
29
- constructor(...args) {
30
- super(...args);
31
- const handlers = Metadata_1.default.get(constants_1.ROUTER_HANDLERS_KEY, this) || [];
32
- this.router = (0, express_1.Router)();
33
- this.mountpoint = mountpoint;
34
- (0, lodash_1.each)(handlers, h => {
35
- const middlewares = h.handler.$middlewares || [];
36
- this.router[h.verb](h.route, ...middlewares, this.__registerHandler(h));
37
- });
38
- }
39
- __mount(parent) {
40
- const rootMiddlewares = Metadata_1.default.get(constants_1.ROUTER_MIDDLEWARES_KEY, this) || [];
41
- parent.use(this.mountpoint, ...rootMiddlewares, this.router);
42
- return this;
43
- }
44
- __registerHandler(options) {
45
- const self = this;
46
- const decoratedArguments = Metadata_1.default.get(constants_1.ARGUMENTS_KEY, options.target, options.propertyKey);
47
- const annotations = Metadata_1.default.get(constants_1.ROUTER_ANNOTATIONS_KEY, options.target, options.propertyKey);
48
- return server_1.executeRequest.bind({
49
- options,
50
- decoratedArguments,
51
- annotations,
52
- self
53
- });
54
- }
55
- };
44
+ return (0, route_1.Routerize)(RouterClass, mountpoint);
56
45
  };
57
46
  }
58
- exports.Route = Route;
59
47
  /**
60
48
  * Define a GET Endpoint response over the controller router and can define in which route should be responds and
61
49
  * by default this is responding to everything on the controller root path.
@@ -76,7 +64,6 @@ exports.Route = Route;
76
64
  function Get(route = '*') {
77
65
  return (0, server_1.generateRoute)(route, 'get');
78
66
  }
79
- exports.Get = Get;
80
67
  /**
81
68
  * Define a POST Endpoint response over the controller router and can define in which route should be responds and
82
69
  * by default this is responding to everything on the controller root path.
@@ -97,7 +84,6 @@ exports.Get = Get;
97
84
  function Post(route = '*') {
98
85
  return (0, server_1.generateRoute)(route, 'post');
99
86
  }
100
- exports.Post = Post;
101
87
  /**
102
88
  * Define a PUT Endpoint response over the controller router and can define in which route should be responds and
103
89
  * by default this is responding to everything on the controller root path.
@@ -118,7 +104,6 @@ exports.Post = Post;
118
104
  function Put(route = '*') {
119
105
  return (0, server_1.generateRoute)(route, 'put');
120
106
  }
121
- exports.Put = Put;
122
107
  /**
123
108
  * Define a PATCH Endpoint response over the controller router and can define in which route should be responds and
124
109
  * by default this is responding to everything on the controller root path.
@@ -139,7 +124,6 @@ exports.Put = Put;
139
124
  function Patch(route = '*') {
140
125
  return (0, server_1.generateRoute)(route, 'patch');
141
126
  }
142
- exports.Patch = Patch;
143
127
  /**
144
128
  * Define a DELETE Endpoint response over the controller router and can define in which route should be responds and
145
129
  * by default this is responding to everything on the controller root path.
@@ -160,7 +144,6 @@ exports.Patch = Patch;
160
144
  function Delete(route = '*') {
161
145
  return (0, server_1.generateRoute)(route, 'delete');
162
146
  }
163
- exports.Delete = Delete;
164
147
  /**
165
148
  * Define a Route path parameter transformation method as mentioned on Express this is just call by controller endpoints
166
149
  * route paths and it helps to define logic on each route path parameters. Example, you can require transform userId
@@ -197,7 +180,6 @@ exports.Delete = Delete;
197
180
  function Param(route = '*') {
198
181
  return (0, server_1.generateRoute)(route, 'param');
199
182
  }
200
- exports.Param = Param;
201
183
  /**
202
184
  * Middleware Decorator is following the middleware functionality inheritance from Express framework itself and follow
203
185
  * the same rules, that execute any code before response the request and can change the current request or response
@@ -228,15 +210,14 @@ exports.Param = Param;
228
210
  */
229
211
  function Middleware(middleware) {
230
212
  return (target, property, descriptor) => {
231
- if (!property) {
232
- rootMiddleware(target, middleware);
213
+ if (property) {
214
+ routeMiddleware(target, descriptor, middleware);
233
215
  }
234
216
  else {
235
- routeMiddleware(target, descriptor, middleware);
217
+ rootMiddleware(target, middleware);
236
218
  }
237
219
  };
238
220
  }
239
- exports.Middleware = Middleware;
240
221
  /**
241
222
  * Will generate a GET route to respond rendering a view template setting up before; the controller method <b>MUST</b>
242
223
  * return an object in order to fulfilled the local variables into the view.
@@ -254,19 +235,18 @@ exports.Middleware = Middleware;
254
235
  *
255
236
  */
256
237
  function View(viewName, route) {
257
- route = route || `/${viewName}`;
238
+ route = route !== null && route !== void 0 ? route : `/${viewName}`;
258
239
  return (target, propertyKey, descriptor) => {
259
240
  (0, decorators_1.addAnnotation)('view', target, propertyKey, viewName);
260
241
  (0, server_1.router)('get', route, target, descriptor.value, propertyKey);
261
242
  };
262
243
  }
263
- exports.View = View;
264
244
  function rootMiddleware(target, middleware) {
265
- const existedRoutesHandlers = Metadata_1.default.get(constants_1.ROUTER_MIDDLEWARES_KEY, target) || [];
245
+ const existedRoutesHandlers = commons_1.Metadata.get(commons_2.ROUTER_MIDDLEWARES_KEY, target) || [];
266
246
  existedRoutesHandlers.unshift(middleware);
267
- Metadata_1.default.set(constants_1.ROUTER_MIDDLEWARES_KEY, existedRoutesHandlers, target);
247
+ commons_1.Metadata.set(commons_2.ROUTER_MIDDLEWARES_KEY, existedRoutesHandlers, target);
268
248
  }
269
- function routeMiddleware(target, descriptor, middleware) {
249
+ function routeMiddleware(_, descriptor, middleware) {
270
250
  descriptor.value.$middlewares = descriptor.value.$middlewares || [];
271
251
  descriptor.value.$middlewares.unshift(middleware);
272
252
  }
@@ -1,6 +1,7 @@
1
- import { Express } from 'express';
2
- import { BOOT_STAGES } from '@expressive-tea/commons/constants';
3
- import { ExpressiveTeaPotSettings, ExpressiveTeaServerProps, ExpressiveTeaStaticFileServer, ExpressiveTeaCupSettings } from '@expressive-tea/commons/interfaces';
1
+ import { type Express } from 'express';
2
+ import { type BOOT_STAGES } from '@expressive-tea/commons';
3
+ import { type ExpressiveTeaPotSettings, type ExpressiveTeaServerProps, type ExpressiveTeaStaticFileServer, type ExpressiveTeaCupSettings } from '@expressive-tea/commons';
4
+ import { Newable } from 'inversify';
4
5
  /**
5
6
  * Plug Class Decorator create a simple plugin to execute in one of the public stages defined on BOOT_STAGES, might
6
7
  * be useful to attach a simple Express Server configuration.
@@ -16,7 +17,7 @@ import { ExpressiveTeaPotSettings, ExpressiveTeaServerProps, ExpressiveTeaStatic
16
17
  * {REPLACE-AT}Plug(BOOT_STAGES.BOOT_DEPENDENCIES, 'test', s => console.log, true)
17
18
  * class Example extends Boot {}
18
19
  */
19
- export declare function Plug(stage: BOOT_STAGES, name: string, method: (server?: Express | never, ...extraArgs: unknown[]) => Promise<any> | any, required?: boolean): (target: any) => void;
20
+ export declare function Plug(stage: BOOT_STAGES, name: string, method: (server?: Express, ...extraArgs: unknown[]) => Promise<void> | void, required?: boolean): (target: any) => void;
20
21
  /**
21
22
  * Since version 1.1.0 Expressive Tea allow to use external plugins using the node
22
23
  * package @expressive-tea/plugin. This plugin engine allows to create more complex plugin configuration and provision
@@ -29,7 +30,7 @@ export declare function Plug(stage: BOOT_STAGES, name: string, method: (server?:
29
30
  * @version 1.1.0
30
31
  * @link https://www.npmjs.com/package/@expressive-tea/plugin Expressive Tea Plugin
31
32
  */
32
- export declare function Pour(Plugin: any, ...pluginArgs: any[]): (target: any) => void;
33
+ export declare function Pour(Plugin: Newable<any>, ...pluginArgs: any[]): (target: any) => void;
33
34
  /**
34
35
  * Server Settings Singleton Class Decorator this Provide the Configuration to the server or another component on
35
36
  * the projects,is working as a container to store user and library settings.
@@ -67,9 +68,8 @@ export declare function ExpressDirective(name: string, ...settings: any[]): (tar
67
68
  * All properties will contains the settings value or undefined if current settings is not founded.
68
69
  * @decorator {PropertyDecorator} Setting - Assign Server Settings to Property as default value.
69
70
  * @summary Automatically assign a settings declared on the Server Settings decorator to a class property.
70
- * @param {string} settingName The Setting name tha
71
71
  */
72
- export declare function Setting(settingName: string): (target: any, propertyName: string) => any;
72
+ export declare function Setting(): (target: any, propertyName: string) => any;
73
73
  /**
74
74
  * Register Modules Method Decorator this Method Decorator is used at bootstrap level and should decorate bootstrap class
75
75
  * and register modules.
@@ -87,6 +87,6 @@ export declare function Proxies(proxyContainers: any[]): (target: any) => void;
87
87
  * @param {Class} Module
88
88
  * @deprecated Use the new decorator Modules that allow add modules into registered modules.
89
89
  */
90
- export declare function RegisterModule(Module: any): (target: any, property: any) => void;
90
+ export declare function RegisterModule(Module: any): (_: any, __: any) => never;
91
91
  export declare function Teapot(teapotSettings: ExpressiveTeaPotSettings): (target: object) => void;
92
92
  export declare function Teacup(teacupSettings: ExpressiveTeaCupSettings): (target: object) => void;