@zerooneit/expressive-tea 1.3.0-beta.6 → 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 (78) hide show
  1. package/.swcrc +61 -0
  2. package/README.md +564 -174
  3. package/classes/Boot.d.ts +89 -2
  4. package/classes/Boot.js +149 -31
  5. package/classes/Engine.d.ts +58 -10
  6. package/classes/Engine.js +69 -9
  7. package/classes/EngineRegistry.d.ts +154 -0
  8. package/classes/EngineRegistry.js +247 -0
  9. package/classes/LoadBalancer.js +2 -5
  10. package/classes/ProxyRoute.js +5 -5
  11. package/classes/Settings.d.ts +31 -2
  12. package/classes/Settings.js +64 -11
  13. package/decorators/annotations.d.ts +1 -1
  14. package/decorators/annotations.js +17 -17
  15. package/decorators/env.d.ts +145 -0
  16. package/decorators/env.js +177 -0
  17. package/decorators/health.d.ts +115 -0
  18. package/decorators/health.js +124 -0
  19. package/decorators/module.d.ts +15 -16
  20. package/decorators/module.js +14 -24
  21. package/decorators/proxy.d.ts +26 -11
  22. package/decorators/proxy.js +35 -49
  23. package/decorators/router.d.ts +17 -16
  24. package/decorators/router.js +31 -53
  25. package/decorators/server.d.ts +7 -7
  26. package/decorators/server.js +48 -50
  27. package/engines/health/index.d.ts +120 -0
  28. package/engines/health/index.js +179 -0
  29. package/engines/http/index.d.ts +6 -10
  30. package/engines/http/index.js +18 -17
  31. package/engines/index.d.ts +32 -0
  32. package/engines/index.js +112 -0
  33. package/engines/socketio/index.d.ts +2 -4
  34. package/engines/socketio/index.js +14 -7
  35. package/engines/teacup/index.d.ts +12 -2
  36. package/engines/teacup/index.js +56 -10
  37. package/engines/teapot/index.d.ts +12 -2
  38. package/engines/teapot/index.js +58 -17
  39. package/engines/websocket/index.d.ts +1 -1
  40. package/engines/websocket/index.js +8 -3
  41. package/eslint.config.mjs +138 -0
  42. package/exceptions/RequestExceptions.d.ts +3 -3
  43. package/helpers/boot-helper.d.ts +4 -4
  44. package/helpers/boot-helper.js +27 -22
  45. package/helpers/decorators.js +7 -6
  46. package/helpers/promise-helper.d.ts +1 -1
  47. package/helpers/promise-helper.js +1 -2
  48. package/helpers/server.d.ts +31 -5
  49. package/helpers/server.js +98 -60
  50. package/helpers/teapot-helper.d.ts +2 -3
  51. package/helpers/teapot-helper.js +34 -8
  52. package/helpers/websocket-helper.d.ts +1 -3
  53. package/helpers/websocket-helper.js +3 -3
  54. package/interfaces/index.d.ts +1 -1
  55. package/inversify.config.d.ts +4 -4
  56. package/inversify.config.js +1 -1
  57. package/libs/utilities.d.ts +21910 -0
  58. package/libs/utilities.js +420 -0
  59. package/mixins/module.d.ts +45 -0
  60. package/mixins/module.js +71 -0
  61. package/mixins/proxy.d.ts +46 -0
  62. package/mixins/proxy.js +86 -0
  63. package/mixins/route.d.ts +48 -0
  64. package/mixins/route.js +96 -0
  65. package/package.json +85 -73
  66. package/services/DependencyInjection.d.ts +94 -8
  67. package/services/DependencyInjection.js +121 -3
  68. package/services/WebsocketService.d.ts +2 -4
  69. package/services/WebsocketService.js +5 -3
  70. package/types/core.d.ts +14 -0
  71. package/types/core.js +2 -0
  72. package/types/injection-types.d.ts +6 -0
  73. package/types/injection-types.js +10 -0
  74. package/types/inversify.d.ts +5 -0
  75. package/types/inversify.js +3 -0
  76. package/.eslintrc.js +0 -44
  77. package/tsconfig.linter.json +0 -24
  78. package/tslint-to-eslint-config.log +0 -12
@@ -1,15 +1,13 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import type WebSocket from 'ws';
4
2
  import type * as http from 'http';
5
3
  import * as https from 'https';
6
4
  export default class WebsocketService {
7
- static instance: WebsocketService;
5
+ static instance: WebsocketService | undefined;
8
6
  private ws;
9
7
  private wss;
10
8
  httpServer: http.Server;
11
9
  httpsServer: https.Server;
12
- constructor(ws?: WebSocket.Server | never, wss?: WebSocket.Server | never);
10
+ constructor(ws?: WebSocket.Server, wss?: WebSocket.Server);
13
11
  getWebsocket(httpServer: http.Server | https.Server): WebSocket.Server;
14
12
  setHttpServer(httpServer: http.Server | https.Server): void;
15
13
  setWebSocket(ws: WebSocket.Server): void;
@@ -6,8 +6,10 @@ class WebsocketService {
6
6
  if (WebsocketService.instance) {
7
7
  return WebsocketService.instance;
8
8
  }
9
- this.ws = ws;
10
- this.wss = wss;
9
+ if (ws)
10
+ this.ws = ws;
11
+ if (wss)
12
+ this.wss = wss;
11
13
  WebsocketService.instance = this;
12
14
  }
13
15
  getWebsocket(httpServer) {
@@ -39,7 +41,7 @@ class WebsocketService {
39
41
  }
40
42
  }
41
43
  static clear() {
42
- delete WebsocketService.instance;
44
+ WebsocketService.instance = undefined;
43
45
  }
44
46
  }
45
47
  exports.default = WebsocketService;
@@ -0,0 +1,14 @@
1
+ import { type IExpressiveTeaModule, IExpressiveTeaProxy, type IExpressiveTeaRoute } from '@expressive-tea/commons';
2
+ export type TFunction<T = any> = (...args: any[]) => T;
3
+ export type Constructor<T = Record<string, any>> = new (...args: any[]) => T;
4
+ export type MixinConstructor<T = Record<string, any>> = Constructor<T>;
5
+ export type ExpressiveTeaModule = MixinConstructor<IExpressiveTeaModule>;
6
+ export type ExpressiveTeaRoute = MixinConstructor<IExpressiveTeaRoute>;
7
+ export type ExpressiveTeaProxy = MixinConstructor<IExpressiveTeaProxy>;
8
+ /**
9
+ * Legacy type aliases - kept for backward compatibility
10
+ * @deprecated Use the typed versions from mixins instead
11
+ */
12
+ export type ModulizedExpressiveTeaModule<TBase> = IExpressiveTeaModule & TBase;
13
+ export type RouterizedExpressiveTeaRoute<TBase> = IExpressiveTeaRoute & TBase;
14
+ export type ProxifyExpressiveTeaRoute<TBase> = IExpressiveTeaProxy & TBase;
package/types/core.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ export declare const TYPES: {
2
+ Context: symbol;
3
+ Server: symbol;
4
+ SecureServer: symbol;
5
+ Settings: symbol;
6
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TYPES = void 0;
4
+ // Service identifiers for dependency injection
5
+ exports.TYPES = {
6
+ Context: Symbol.for('Context'),
7
+ Server: Symbol.for('Server'),
8
+ SecureServer: Symbol.for('SecureServer'),
9
+ Settings: Symbol.for('Settings')
10
+ };
@@ -0,0 +1,5 @@
1
+ import { ServiceIdentifier as InversifyServiceIdentifier } from 'inversify';
2
+ export type ServiceIdentifier<T = any> = InversifyServiceIdentifier<T> | (abstract new (...args: any[]) => T);
3
+ export type LazyInversifyDecorator<T = any> = (serviceIdentifier: ServiceIdentifier<T>) => (proto: any, key: string) => void;
4
+ export type LazyInversifyNamedDecorator<T = any> = (serviceIdentifier: ServiceIdentifier<T>, named: string) => (proto: any, key: string) => void;
5
+ export type LazyInversifyTaggedDecorator<T = any> = (serviceIdentifier: ServiceIdentifier<T>, key: string, value: any) => (proto: any, propertyName: string) => void;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-enable @typescript-eslint/no-explicit-any */
package/.eslintrc.js DELETED
@@ -1,44 +0,0 @@
1
- /*
2
- 👋 Hi! This file was autogenerated by tslint-to-eslint-config.
3
- https://github.com/typescript-eslint/tslint-to-eslint-config
4
-
5
- It represents the closest reasonable ESLint configuration to this
6
- project's original TSLint configuration.
7
-
8
- We recommend eventually switching this configuration to extend from
9
- the recommended rulesets in typescript-eslint.
10
- https://github.com/typescript-eslint/tslint-to-eslint-config/blob/master/docs/FAQs.md
11
-
12
- Happy linting! 💖
13
- */
14
- module.exports = {
15
- env: {
16
- browser: true,
17
- es6: true,
18
- node: true
19
- },
20
- extends: ['love', 'prettier'],
21
- parser: '@typescript-eslint/parser',
22
- parserOptions: {
23
- project: 'tsconfig.linter.json',
24
- sourceType: 'module'
25
- },
26
- plugins: ['eslint-plugin-jsdoc', 'eslint-plugin-prefer-arrow', '@typescript-eslint'],
27
- root: true,
28
- rules: {
29
- semi: 'off',
30
- '@typescript-eslint/array-type': ['error', { default: 'array'}],
31
- '@typescript-eslint/semi': 'off',
32
- '@typescript-eslint/return-await': 'off',
33
- '@typescript-eslint/strict-boolean-expressions': 'off',
34
- '@typescript-eslint/explicit-function-return-type': [0, {allowExpressions: true}],
35
- '@typescript-eslint/no-extraneous-class': 'off',
36
- '@typescript-eslint/no-unsafe-argument': 'warn',
37
- 'no-duplicate-imports': 'off'
38
- },
39
- ignorePatterns: [
40
- 'benchmark/**/*.ts',
41
- '__test__/mock/*',
42
- '__test__/**/helper/*',
43
- ]
44
- };
@@ -1,24 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "noImplicitAny": false,
4
- "module": "commonjs",
5
- "target": "es2017",
6
- "emitDecoratorMetadata": true,
7
- "experimentalDecorators": true,
8
- "strictNullChecks": true,
9
- "strict": false,
10
- "moduleResolution": "node",
11
- "allowSyntheticDefaultImports": true,
12
- "importHelpers": true,
13
- "baseUrl": ".",
14
- "declaration": true,
15
- "skipLibCheck": true,
16
- "lib": [
17
- "es2017",
18
- "dom"
19
- ]
20
- },
21
- "exclude": [
22
- "node_modules"
23
- ]
24
- }
@@ -1,12 +0,0 @@
1
- 5 ESLint rules behave differently from their TSLint counterparts:
2
- * no-invalid-this:
3
- - Functions in methods will no longer be ignored.
4
- * @typescript-eslint/no-unused-expressions:
5
- - The TSLint optional config "allow-new" is the default ESLint behavior and will no longer be ignored.
6
- * prefer-arrow/prefer-arrow-functions:
7
- - ESLint (eslint-plugin-prefer-arrow plugin) does not support allowing named functions defined with the function keyword.
8
- * eqeqeq:
9
- - Option "smart" allows for comparing two literal values, evaluating the value of typeof and null comparisons.
10
- * no-underscore-dangle:
11
- - Leading and trailing underscores (_) on identifiers will now be ignored.
12
-