@zerooneit/expressive-tea 1.3.0-beta.5 → 1.3.0-beta.6

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 (42) hide show
  1. package/.eslintrc.js +44 -0
  2. package/.gitattributes +4 -0
  3. package/classes/Boot.d.ts +6 -2
  4. package/classes/Boot.js +44 -42
  5. package/classes/Engine.d.ts +1 -0
  6. package/classes/Engine.js +3 -2
  7. package/classes/LoadBalancer.js +1 -1
  8. package/classes/ProxyRoute.d.ts +3 -3
  9. package/decorators/annotations.d.ts +1 -1
  10. package/decorators/module.d.ts +4 -3
  11. package/decorators/module.js +2 -1
  12. package/decorators/proxy.d.ts +2 -2
  13. package/decorators/proxy.js +5 -1
  14. package/decorators/router.d.ts +4 -4
  15. package/decorators/router.js +6 -4
  16. package/decorators/server.d.ts +4 -4
  17. package/engines/http/index.d.ts +3 -0
  18. package/engines/http/index.js +9 -5
  19. package/engines/socketio/index.d.ts +3 -0
  20. package/engines/socketio/index.js +3 -0
  21. package/engines/teacup/index.d.ts +3 -0
  22. package/engines/teacup/index.js +7 -3
  23. package/engines/teapot/index.d.ts +5 -2
  24. package/engines/teapot/index.js +7 -0
  25. package/engines/websocket/index.d.ts +3 -0
  26. package/engines/websocket/index.js +3 -0
  27. package/exceptions/RequestExceptions.d.ts +1 -1
  28. package/helpers/boot-helper.d.ts +2 -2
  29. package/helpers/boot-helper.js +3 -2
  30. package/helpers/server.d.ts +3 -3
  31. package/helpers/server.js +6 -4
  32. package/helpers/teapot-helper.d.ts +4 -6
  33. package/helpers/teapot-helper.js +7 -5
  34. package/helpers/websocket-helper.d.ts +2 -2
  35. package/interfaces/index.d.ts +1 -1
  36. package/inversify.config.d.ts +4 -4
  37. package/package.json +42 -32
  38. package/services/DependencyInjection.d.ts +4 -2
  39. package/services/DependencyInjection.js +2 -2
  40. package/services/WebsocketService.d.ts +2 -2
  41. package/tsconfig.linter.json +24 -0
  42. package/tslint-to-eslint-config.log +12 -0
package/.eslintrc.js ADDED
@@ -0,0 +1,44 @@
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
+ };
package/.gitattributes ADDED
@@ -0,0 +1,4 @@
1
+ /.yarn/** linguist-vendored
2
+ /.yarn/releases/* binary
3
+ /.yarn/plugins/**/* binary
4
+ /.pnp.* binary linguist-generated
package/classes/Boot.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import 'reflect-metadata';
2
- import { Express } from 'express';
3
- import { ExpressiveTeaApplication } from '@expressive-tea/commons/interfaces';
2
+ import { type Express } from 'express';
3
+ import { type ExpressiveTeaApplication } from '@expressive-tea/commons/interfaces';
4
4
  import Settings from '../classes/Settings';
5
5
  /**
6
6
  * Expressive Tea Application interface is the response from an started application, contains the express application
@@ -36,6 +36,7 @@ declare abstract class Boot {
36
36
  * @summary Express Application instance internal property.
37
37
  */
38
38
  private readonly server;
39
+ private readonly containerDI;
39
40
  constructor();
40
41
  /**
41
42
  * Get Express Application
@@ -50,5 +51,8 @@ declare abstract class Boot {
50
51
  * @returns {Promise<ExpressiveTeaApplication>}
51
52
  */
52
53
  start(): Promise<ExpressiveTeaApplication>;
54
+ private initializeEngines;
55
+ private initializeHttp;
56
+ private initializeContainer;
53
57
  }
54
58
  export default Boot;
package/classes/Boot.js CHANGED
@@ -2,11 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  require("reflect-metadata");
4
4
  const inversify_config_1 = require("../inversify.config");
5
- // tslint:disable-next-line:no-duplicate-imports
6
5
  const express = require("express");
7
- const constants_1 = require("@expressive-tea/commons/constants");
8
- const Metadata_1 = require("@expressive-tea/commons/classes/Metadata");
9
- const object_helper_1 = require("@expressive-tea/commons/helpers/object-helper");
10
6
  const http_1 = require("../engines/http");
11
7
  const websocket_1 = require("../engines/websocket");
12
8
  const index_1 = require("../engines/teapot/index");
@@ -43,6 +39,7 @@ class Boot {
43
39
  * @summary Express Application instance internal property.
44
40
  */
45
41
  this.server = express();
42
+ this.containerDI = inversify_config_1.default.createChild();
46
43
  this.settings = Settings_1.default.getInstance(this);
47
44
  }
48
45
  /**
@@ -60,44 +57,49 @@ class Boot {
60
57
  * @returns {Promise<ExpressiveTeaApplication>}
61
58
  */
62
59
  async start() {
63
- return new Promise(async (resolver, reject) => {
64
- try {
65
- const localContainer = inversify_config_1.default.createChild();
66
- const privateKey = this.settings.get('privateKey');
67
- const certificate = this.settings.get('certificate');
68
- const server = http.createServer(this.server);
69
- const secureServer = privateKey && certificate && https.createServer({
70
- cert: fs.readFileSync(certificate).toString('utf-8'),
71
- key: fs.readFileSync(privateKey).toString('utf-8')
72
- });
73
- // Injectables
74
- localContainer.bind('server').toConstantValue(server);
75
- localContainer.bind('secureServer').toConstantValue(secureServer || undefined);
76
- localContainer.bind('context').toConstantValue(this);
77
- localContainer.bind('settings').toConstantValue(this.settings);
78
- // Activation
79
- const isActiveTeapot = Metadata_1.default.get(constants_1.ASSIGN_TEAPOT_KEY, (0, object_helper_1.getClass)(this), 'isTeapotActive');
80
- const isActiveTeacup = Metadata_1.default.get(constants_1.ASSIGN_TEACUP_KEY, (0, object_helper_1.getClass)(this), 'isTeacupActive');
81
- const isActiveWebsockets = this.settings.get('startWebsocket');
82
- // Resolve Engines
83
- const httpEngine = localContainer.resolve(http_1.default);
84
- const availableEngines = [
85
- localContainer.resolve(index_2.default),
86
- ...isActiveWebsockets ? [localContainer.resolve(websocket_1.default)] : [],
87
- ...isActiveTeapot ? [localContainer.resolve(index_1.default)] : [],
88
- ...isActiveTeacup ? [localContainer.resolve(teacup_1.default)] : [],
89
- ];
90
- // Initialize Engines
91
- await Engine_1.default.exec(availableEngines, 'init');
92
- await httpEngine.init();
93
- await httpEngine.start();
94
- await Engine_1.default.exec(availableEngines, 'start');
95
- resolver({ application: this.server, server, secureServer });
96
- }
97
- catch (e) {
98
- return reject(e);
99
- }
100
- });
60
+ // Initialize Server
61
+ const [server, secureServer] = this.initializeHttp();
62
+ // Injectables
63
+ this.initializeContainer(server, secureServer);
64
+ // Initialize Engines
65
+ const availableEngines = [
66
+ http_1.default,
67
+ index_2.default,
68
+ websocket_1.default,
69
+ index_1.default,
70
+ teacup_1.default
71
+ ];
72
+ const registeredEngines = availableEngines.filter(Engine => Engine.canRegister(this, this.settings));
73
+ this.initializeEngines(registeredEngines);
74
+ // Resolve Engines
75
+ const readyEngines = registeredEngines.map(Engine => this.containerDI.resolve(Engine));
76
+ // Initialize Engines
77
+ await Engine_1.default.exec(readyEngines.reverse(), 'init');
78
+ await Engine_1.default.exec(readyEngines, 'start');
79
+ return ({ application: this.server, server, secureServer });
80
+ }
81
+ initializeEngines(registeredEngines) {
82
+ for (const Engine of registeredEngines) {
83
+ this.containerDI.bind(Engine).to(Engine);
84
+ }
85
+ }
86
+ initializeHttp() {
87
+ const privateKey = this.settings.get('privateKey');
88
+ const certificate = this.settings.get('certificate');
89
+ const server = http.createServer(this.server);
90
+ const secureServer = privateKey &&
91
+ certificate &&
92
+ https.createServer({
93
+ cert: fs.readFileSync(certificate).toString('utf-8'),
94
+ key: fs.readFileSync(privateKey).toString('utf-8')
95
+ });
96
+ return [server, secureServer];
97
+ }
98
+ initializeContainer(server, secureServer) {
99
+ this.containerDI.bind('server').toConstantValue(server);
100
+ this.containerDI.bind('secureServer').toConstantValue(secureServer !== null && secureServer !== void 0 ? secureServer : undefined);
101
+ this.containerDI.bind('context').toConstantValue(this);
102
+ this.containerDI.bind('settings').toConstantValue(this.settings);
101
103
  }
102
104
  }
103
105
  exports.default = Boot;
@@ -11,4 +11,5 @@ export default class ExpressiveTeaEngine {
11
11
  protected readonly serverSecure?: https.Server;
12
12
  constructor(ctx: any, server: any, serverSecure: any, settings: any);
13
13
  static exec(availableEngines: ExpressiveTeaEngine[], method: string): any;
14
+ static canRegister(ctx?: Boot, settings?: Settings): boolean;
14
15
  }
package/classes/Engine.js CHANGED
@@ -11,11 +11,12 @@ let ExpressiveTeaEngine = class ExpressiveTeaEngine {
11
11
  }
12
12
  static exec(availableEngines, method) {
13
13
  return Promise.all(availableEngines
14
- // tslint:disable-next-line:no-string-literal
15
14
  .filter(engine => typeof engine[method] === 'function')
16
- // tslint:disable-next-line:no-string-literal
17
15
  .map(engine => engine[method]()));
18
16
  }
17
+ static canRegister(ctx, settings) {
18
+ return false;
19
+ }
19
20
  };
20
21
  ExpressiveTeaEngine = tslib_1.__decorate([
21
22
  (0, inversify_1.injectable)(),
@@ -5,7 +5,7 @@ class LoadBalancer {
5
5
  * @offset should be used for unit testing and nothing else.
6
6
  */
7
7
  constructor(count, offset = 0) {
8
- this.bins = new Array(count);
8
+ this.bins = [];
9
9
  // Initializes the elements of the array to zero.
10
10
  for (let i = 0; i < this.bins.length; i++) {
11
11
  this.bins[i] = offset;
@@ -1,9 +1,9 @@
1
- import { RequestHandler } from 'express';
1
+ import { type RequestHandler } from 'express';
2
2
  export default class ProxyRoute {
3
3
  readonly registeredOn: string;
4
4
  private balancer;
5
- private servers;
6
- private clients;
5
+ private readonly servers;
6
+ private readonly clients;
7
7
  private lastServerSelected;
8
8
  constructor(registeredOn: string);
9
9
  hasClients(): boolean;
@@ -1,4 +1,4 @@
1
- import { ParameterDecorator } from '@expressive-tea/commons/types';
1
+ import { type ParameterDecorator } from '@expressive-tea/commons/types';
2
2
  /**
3
3
  * Is passing directly to the decorated argument described <a href="http://expressjs.com/en/4x/api.html#req">here</a>.
4
4
  * @decorator {ParameterDecorator} request - Assign express Request instance to parameter.
@@ -1,5 +1,5 @@
1
- import { Express, Router } from 'express';
2
- import { ExpressiveTeaModuleProps } from '@expressive-tea/commons/interfaces';
1
+ import { type Express, Router } from 'express';
2
+ import { type ExpressiveTeaModuleProps } from '@expressive-tea/commons/interfaces';
3
3
  /**
4
4
  * @typedef {Object} ExpressiveTeaModuleProps
5
5
  * @property {Object[]} controllers Controllers Assigned to Module
@@ -24,8 +24,9 @@ import { ExpressiveTeaModuleProps } from '@expressive-tea/commons/interfaces';
24
24
  * })
25
25
  * class Example {}
26
26
  */
27
- export declare function Module(options: ExpressiveTeaModuleProps): <T extends new (...args: any[]) => {}>(Module: T) => {
27
+ export declare function Module(options: ExpressiveTeaModuleProps): <T extends new (...args: any[]) => any>(Module: T) => {
28
28
  new (...args: any[]): {
29
+ [x: string]: any;
29
30
  readonly settings: ExpressiveTeaModuleProps;
30
31
  readonly router: Router;
31
32
  readonly controllers: any[];
@@ -32,10 +32,11 @@ function Module(options) {
32
32
  return (Module) => {
33
33
  return class ExpressiveTeaModule extends Module {
34
34
  constructor(...args) {
35
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
35
36
  super(...args);
36
37
  this.router = (0, express_1.Router)();
37
38
  this.settings = options;
38
- (0, lodash_1.each)(this.settings.providers, P => DependencyInjection_1.default.setProvider(P));
39
+ (0, lodash_1.each)(this.settings.providers, (P) => { DependencyInjection_1.default.setProvider(P); });
39
40
  this.controllers = (0, lodash_1.map)(this.settings.controllers, C => new C());
40
41
  }
41
42
  __register(server) {
@@ -1,5 +1,5 @@
1
- import { ExpressiveTeaProxyOptions, ExpressiveTeaProxyProperty, MethodDecorator } from '@expressive-tea/commons/types';
2
- import { Express, RequestHandler } from 'express';
1
+ import { type ExpressiveTeaProxyOptions, type ExpressiveTeaProxyProperty, type MethodDecorator } from '@expressive-tea/commons/types';
2
+ import { type Express, type RequestHandler } from 'express';
3
3
  export declare function ProxyContainer(source: string, targetUrl: string): <T extends new (...args: any[]) => any>(ProxyContainerClass: T) => {
4
4
  new (...args: any[]): {
5
5
  [x: string]: any;
@@ -12,6 +12,7 @@ function ProxyContainer(source, targetUrl) {
12
12
  return (ProxyContainerClass) => {
13
13
  class ExpressiveTeaProxy extends ProxyContainerClass {
14
14
  constructor(...args) {
15
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
15
16
  super(...args);
16
17
  this.source = source;
17
18
  this.target = targetUrl;
@@ -25,10 +26,11 @@ function ProxyContainer(source, targetUrl) {
25
26
  for (const value of Object.values(constants_1.PROXY_PROPERTIES)) {
26
27
  const key = Metadata_1.default.get(constants_1.PROXY_SETTING_KEY, this, value);
27
28
  if (!(0, lodash_1.isUndefined)(key)) {
28
- // @ts-ignore:next-line
29
+ // @ts-expect-error:next-line
29
30
  options[value] = this[key];
30
31
  }
31
32
  }
33
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
32
34
  this.proxyHandler = httpProxy(host ? host.value.bind(this) : this.target);
33
35
  }
34
36
  __register(server) {
@@ -50,6 +52,7 @@ function ProxyContainer(source, targetUrl) {
50
52
  exports.ProxyContainer = ProxyContainer;
51
53
  function ProxyOption(option) {
52
54
  return (target, propertyKey, descriptor) => {
55
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
53
56
  if (NON_ASYNC_METHODS.includes(option) && (0, object_helper_1.isAsyncFunction)(descriptor.value)) {
54
57
  throw new RequestExceptions_1.GenericRequestException(`${String(propertyKey)} must not be declared as Async Function.`);
55
58
  }
@@ -60,6 +63,7 @@ exports.ProxyOption = ProxyOption;
60
63
  function ProxyProperty(option, value) {
61
64
  return (target, propertyKey) => {
62
65
  Metadata_1.default.set(constants_1.PROXY_SETTING_KEY, propertyKey, target, option);
66
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
63
67
  let currentValue = target[propertyKey];
64
68
  Object.defineProperty(target, propertyKey, {
65
69
  get: () => value,
@@ -1,6 +1,6 @@
1
1
  import { Router } from 'express';
2
- import { ExpressiveTeaHandlerOptions } from '@expressive-tea/commons/interfaces';
3
- import { ClassDecorator, ExpressMiddlewareHandler, MethodDecorator } from '@expressive-tea/commons/types';
2
+ import { type ExpressiveTeaHandlerOptions } from '@expressive-tea/commons/interfaces';
3
+ import { type ClassDecorator, type ExpressMiddlewareHandler, type MethodDecorator } from '@expressive-tea/commons/types';
4
4
  /**
5
5
  * @module Decorators/Router
6
6
  */
@@ -22,7 +22,7 @@ export declare function Route(mountpoint?: string): <T extends new (...args: any
22
22
  [x: string]: any;
23
23
  readonly router: Router;
24
24
  readonly mountpoint: string;
25
- __mount(parent: Router): any;
25
+ __mount(parent: Router): this;
26
26
  __registerHandler(options: ExpressiveTeaHandlerOptions): ExpressMiddlewareHandler;
27
27
  };
28
28
  } & T;
@@ -178,7 +178,7 @@ export declare function Param(route?: string): (target: object, propertyKey: str
178
178
  *
179
179
  * @param {Function} middleware Register a middleware over router.
180
180
  */
181
- export declare function Middleware(middleware: any): ClassDecorator & MethodDecorator;
181
+ export declare function Middleware(middleware: (...args: any[]) => any): ClassDecorator & MethodDecorator;
182
182
  /**
183
183
  * Will generate a GET route to respond rendering a view template setting up before; the controller method <b>MUST</b>
184
184
  * return an object in order to fulfilled the local variables into the view.
@@ -27,29 +27,31 @@ function Route(mountpoint = '/') {
27
27
  return (RouterClass) => {
28
28
  return class ExpressiveTeaRoute extends RouterClass {
29
29
  constructor(...args) {
30
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
30
31
  super(...args);
31
32
  const handlers = Metadata_1.default.get(constants_1.ROUTER_HANDLERS_KEY, this) || [];
32
33
  this.router = (0, express_1.Router)();
33
34
  this.mountpoint = mountpoint;
34
35
  (0, lodash_1.each)(handlers, h => {
35
- const middlewares = h.handler.$middlewares || [];
36
+ var _a;
37
+ const middlewares = (_a = h.handler.$middlewares) !== null && _a !== void 0 ? _a : [];
36
38
  this.router[h.verb](h.route, ...middlewares, this.__registerHandler(h));
37
39
  });
38
40
  }
39
41
  __mount(parent) {
40
42
  const rootMiddlewares = Metadata_1.default.get(constants_1.ROUTER_MIDDLEWARES_KEY, this) || [];
43
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
41
44
  parent.use(this.mountpoint, ...rootMiddlewares, this.router);
42
45
  return this;
43
46
  }
44
47
  __registerHandler(options) {
45
- const self = this;
46
48
  const decoratedArguments = Metadata_1.default.get(constants_1.ARGUMENTS_KEY, options.target, options.propertyKey);
47
49
  const annotations = Metadata_1.default.get(constants_1.ROUTER_ANNOTATIONS_KEY, options.target, options.propertyKey);
48
50
  return server_1.executeRequest.bind({
49
51
  options,
50
52
  decoratedArguments,
51
53
  annotations,
52
- self
54
+ self: this
53
55
  });
54
56
  }
55
57
  };
@@ -254,7 +256,7 @@ exports.Middleware = Middleware;
254
256
  *
255
257
  */
256
258
  function View(viewName, route) {
257
- route = route || `/${viewName}`;
259
+ route = route !== null && route !== void 0 ? route : `/${viewName}`;
258
260
  return (target, propertyKey, descriptor) => {
259
261
  (0, decorators_1.addAnnotation)('view', target, propertyKey, viewName);
260
262
  (0, server_1.router)('get', route, target, descriptor.value, propertyKey);
@@ -1,6 +1,6 @@
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/constants';
3
+ import { type ExpressiveTeaPotSettings, type ExpressiveTeaServerProps, type ExpressiveTeaStaticFileServer, type ExpressiveTeaCupSettings } from '@expressive-tea/commons/interfaces';
4
4
  /**
5
5
  * Plug Class Decorator create a simple plugin to execute in one of the public stages defined on BOOT_STAGES, might
6
6
  * be useful to attach a simple Express Server configuration.
@@ -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): (target: any, property: string | symbol) => void;
91
91
  export declare function Teapot(teapotSettings: ExpressiveTeaPotSettings): (target: object) => void;
92
92
  export declare function Teacup(teacupSettings: ExpressiveTeaCupSettings): (target: object) => void;
@@ -4,10 +4,13 @@ import * as http from 'http';
4
4
  import * as https from 'https';
5
5
  import { BOOT_STAGES } from '@expressive-tea/commons/constants';
6
6
  import ExpressiveTeaEngine from '../../classes/Engine';
7
+ import Boot from '../../classes/Boot';
8
+ import Settings from '../../classes/Settings';
7
9
  export default class HTTPEngine extends ExpressiveTeaEngine {
8
10
  private listen;
9
11
  start(): Promise<(http.Server | https.Server)[]>;
10
12
  init(): Promise<void>;
11
13
  resolveStages(stages: BOOT_STAGES[], ...extraArgs: any[]): Promise<void[]>;
12
14
  resolveProxyContainers(): Promise<void>;
15
+ static canRegister(ctx?: Boot, settings?: Settings): boolean;
13
16
  }
@@ -8,9 +8,8 @@ const object_helper_1 = require("@expressive-tea/commons/helpers/object-helper")
8
8
  const Metadata_1 = require("@expressive-tea/commons/classes/Metadata");
9
9
  const Engine_1 = require("../../classes/Engine");
10
10
  let HTTPEngine = class HTTPEngine extends Engine_1.default {
11
- listen(server, port) {
11
+ async listen(server, port) {
12
12
  return new Promise((resolve, reject) => {
13
- console.log('Listening on port', port, server.listen);
14
13
  server.listen(port);
15
14
  server.on('error', error => {
16
15
  reject(error);
@@ -22,8 +21,9 @@ let HTTPEngine = class HTTPEngine extends Engine_1.default {
22
21
  });
23
22
  }
24
23
  async start() {
25
- console.log(`Starting Server Test`);
24
+ console.log('Starting Server Test');
26
25
  const listenerServers = [
26
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
27
27
  await this.listen(this.server, this.settings.get('port')),
28
28
  (this.serverSecure) ? await this.listen(this.serverSecure, this.settings.get('securePort')) : null
29
29
  ];
@@ -39,14 +39,18 @@ let HTTPEngine = class HTTPEngine extends Engine_1.default {
39
39
  await this.resolveStages([constants_1.BOOT_STAGES.AFTER_APPLICATION_MIDDLEWARES, constants_1.BOOT_STAGES.ON_HTTP_CREATION], this.server, this.serverSecure);
40
40
  }
41
41
  async resolveStages(stages, ...extraArgs) {
42
- return Promise.all(stages.map(s => (0, boot_helper_1.resolveStage)(s, this.context, this.context.getApplication(), ...extraArgs)));
42
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
43
+ return Promise.all(stages.map(async (s) => (0, boot_helper_1.resolveStage)(s, this.context, this.context.getApplication(), ...extraArgs)));
43
44
  }
44
45
  async resolveProxyContainers() {
45
46
  const ProxyContainers = Metadata_1.default.get(constants_1.ROUTER_PROXIES_KEY, (0, object_helper_1.getClass)(this.context)) || [];
46
47
  for (const Container of ProxyContainers) {
47
- (0, boot_helper_1.resolveProxy)(Container, this.context.getApplication());
48
+ await (0, boot_helper_1.resolveProxy)(Container, this.context.getApplication());
48
49
  }
49
50
  }
51
+ static canRegister(ctx, settings) {
52
+ return true;
53
+ }
50
54
  };
51
55
  HTTPEngine = tslib_1.__decorate([
52
56
  (0, inversify_1.injectable)()
@@ -1,6 +1,9 @@
1
1
  import ExpressiveTeaEngine from '../../classes/Engine';
2
+ import type Boot from '../../classes/Boot';
3
+ import type Settings from '../../classes/Settings';
2
4
  export default class SocketIOEngine extends ExpressiveTeaEngine {
3
5
  private io;
4
6
  private ioSecure;
5
7
  init(): Promise<void>;
8
+ static canRegister(ctx?: Boot, settings?: Settings): boolean;
6
9
  }
@@ -15,6 +15,9 @@ class SocketIOEngine extends Engine_1.default {
15
15
  Metadata_1.default.set(constants_1.SOCKET_IO_INSTANCE_KEY, this.io, this.context);
16
16
  Metadata_1.default.set(constants_1.SOCKET_IO_SECURE_INSTANCE_KEY, this.ioSecure, this.context);
17
17
  }
18
+ static canRegister(ctx, settings) {
19
+ return true;
20
+ }
18
21
  }
19
22
  exports.default = SocketIOEngine;
20
23
  ;
@@ -1,4 +1,6 @@
1
1
  import ExpressiveTeaEngine from '../../classes/Engine';
2
+ import Boot from '../../classes/Boot';
3
+ import Settings from '../../classes/Settings';
2
4
  export default class TeacupEngine extends ExpressiveTeaEngine {
3
5
  private teacupSettings;
4
6
  private publicKey;
@@ -11,4 +13,5 @@ export default class TeacupEngine extends ExpressiveTeaEngine {
11
13
  private handshaked;
12
14
  private accepted;
13
15
  start(): Promise<void>;
16
+ static canRegister(ctx?: Boot, settings?: Settings): boolean;
14
17
  }
@@ -2,8 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const chalk = require("chalk");
5
- const url = require("url");
6
- // tslint:disable-next-line:no-duplicate-imports
5
+ const url_1 = require("url");
7
6
  const socket_io_client_1 = require("socket.io-client");
8
7
  const inversify_1 = require("inversify");
9
8
  const Metadata_1 = require("@expressive-tea/commons/classes/Metadata");
@@ -62,7 +61,7 @@ All Communication are encrypted to ensure intruder can not connected, however, p
62
61
  }
63
62
  async start() {
64
63
  this.teacupSettings = Metadata_1.default.get(constants_1.ASSIGN_TEACUP_KEY, (0, object_helper_1.getClass)(this.context));
65
- const scheme = url.parse(this.teacupSettings.serverUrl);
64
+ const scheme = new url_1.URL(this.teacupSettings.serverUrl);
66
65
  const { publicKey, privateKey } = teapot_helper_1.default.generateKeys(this.teacupSettings.clientKey);
67
66
  const protocol = teapot_helper_1.default.httpSchema(scheme.protocol);
68
67
  this.publicKey = publicKey;
@@ -74,11 +73,16 @@ All Communication are encrypted to ensure intruder can not connected, however, p
74
73
  autoConnect: false
75
74
  });
76
75
  this.header();
76
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
77
77
  this.client.on('handshake', this.handshaked.bind(this));
78
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
78
79
  this.client.on('accepted', this.accepted.bind(this));
79
80
  this.client.on('error', console.log);
80
81
  this.client.connect();
81
82
  }
83
+ static canRegister(ctx, settings) {
84
+ return Metadata_1.default.get(constants_1.ASSIGN_TEACUP_KEY, (0, object_helper_1.getClass)(ctx), 'isTeacupActive');
85
+ }
82
86
  };
83
87
  TeacupEngine = tslib_1.__decorate([
84
88
  (0, inversify_1.injectable)()
@@ -1,7 +1,9 @@
1
1
  import ExpressiveTeaEngine from '../../classes/Engine';
2
+ import Boot from '../../classes/Boot';
3
+ import Settings from '../../classes/Settings';
2
4
  export default class TeapotEngine extends ExpressiveTeaEngine {
3
- private clients;
4
- private registeredRoute;
5
+ private readonly clients;
6
+ private readonly registeredRoute;
5
7
  private teapotSettings;
6
8
  private publicKey;
7
9
  private privateKey;
@@ -16,4 +18,5 @@ export default class TeapotEngine extends ExpressiveTeaEngine {
16
18
  private disconnected;
17
19
  init(): Promise<void>;
18
20
  start(): Promise<void>;
21
+ static canRegister(ctx?: Boot, settings?: Settings): boolean;
19
22
  }
@@ -10,6 +10,7 @@ const ProxyRoute_1 = require("../../classes/ProxyRoute");
10
10
  const Engine_1 = require("../../classes/Engine");
11
11
  const teapot_helper_1 = require("../../helpers/teapot-helper");
12
12
  const constants_2 = require("../constants/constants");
13
+ const object_helper_1 = require("@expressive-tea/commons/helpers/object-helper");
13
14
  let TeapotEngine = TeapotEngine_1 = class TeapotEngine extends Engine_1.default {
14
15
  constructor() {
15
16
  super(...arguments);
@@ -36,6 +37,7 @@ All Communication are encrypted to ensure intruder can not connected, however, p
36
37
  registerTeacup(teacup) {
37
38
  console.log(chalk `{cyan.bold [TEAPOT]} - {blue TEACUP} [{magenta.bold ${teacup.id}}]: {grey.bold Connected}`);
38
39
  teacup.emit('handshake', Buffer.from(this.publicKey), this.serverSignature, Boolean(this.serverSecure), this.clientVerification.bind(this, teacup));
40
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
39
41
  teacup.on('disconnect', this.disconnected.bind(this, teacup));
40
42
  }
41
43
  clientVerification(teacup, userPublicKey, userSignature) {
@@ -67,6 +69,7 @@ All Communication are encrypted to ensure intruder can not connected, however, p
67
69
  proxyRoute.registerServer(message.address, teacup.id);
68
70
  if (!isRegistered) {
69
71
  this.registeredRoute.set(message.mountTo, proxyRoute);
72
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
70
73
  this.context.getApplication().use(message.mountTo, teapot_helper_1.default.proxyResponse.bind(this, proxyRoute));
71
74
  }
72
75
  console.log(chalk `{cyan.bold [TEAPOT]} - {blue TEACUP} [{magenta.bold ${teacup.id}}] {blue.bold <${message.address}>} <--> {white.bold ${message.mountTo}}`);
@@ -110,8 +113,12 @@ All Communication are encrypted to ensure intruder can not connected, however, p
110
113
  async start() {
111
114
  this.socketServer = Metadata_1.default.get(constants_2.SOCKET_IO_INSTANCE_KEY, this.context).of('/teapot');
112
115
  TeapotEngine_1.header(this.teapotSettings);
116
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
113
117
  this.socketServer.on('connection', this.registerTeacup.bind(this));
114
118
  }
119
+ static canRegister(ctx, settings) {
120
+ return Metadata_1.default.get(constants_1.ASSIGN_TEAPOT_KEY, (0, object_helper_1.getClass)(ctx), 'isTeapotActive');
121
+ }
115
122
  };
116
123
  TeapotEngine = TeapotEngine_1 = tslib_1.__decorate([
117
124
  (0, inversify_1.injectable)()
@@ -1,6 +1,9 @@
1
1
  import ExpressiveTeaEngine from '../../classes/Engine';
2
+ import Boot from '../../classes/Boot';
3
+ import Settings from '../../classes/Settings';
2
4
  export default class WebsocketEngine extends ExpressiveTeaEngine {
3
5
  canStart: boolean;
4
6
  isDetached: boolean;
5
7
  init(): Promise<void>;
8
+ static canRegister(ctx?: Boot, settings?: Settings): boolean;
6
9
  }
@@ -24,6 +24,9 @@ let WebsocketEngine = class WebsocketEngine extends Engine_1.default {
24
24
  WebsocketService_1.default.getInstance().setHttpServer(this.serverSecure);
25
25
  }
26
26
  }
27
+ static canRegister(ctx, settings) {
28
+ return settings.get('startWebsocket');
29
+ }
27
30
  };
28
31
  WebsocketEngine = tslib_1.__decorate([
29
32
  (0, inversify_1.injectable)()
@@ -25,7 +25,7 @@
25
25
  export declare class GenericRequestException extends Error {
26
26
  statusCode: number;
27
27
  message: string;
28
- constructor(message: any, statusCode?: number);
28
+ constructor(message: string | never, statusCode?: number);
29
29
  }
30
30
  /**
31
31
  * Shortcut Exception for 400 HTTP Errors (Bad Request).
@@ -1,6 +1,6 @@
1
1
  import { BOOT_STAGES } from '@expressive-tea/commons/constants';
2
- import { Express } from 'express';
3
- import Boot from '../classes/Boot';
2
+ import { type Express } from 'express';
3
+ import type Boot from '../classes/Boot';
4
4
  export declare function resolveStage(stage: BOOT_STAGES, ctx: Boot, server: Express, ...extraArgs: unknown[]): Promise<void>;
5
5
  export declare function resolveDirectives(instance: typeof Boot | Boot, server: Express): Promise<void>;
6
6
  export declare function resolveStatic(instance: typeof Boot | Boot, server: Express): Promise<void>;
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- // tslint:disable:no-duplicate-imports
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.resolveProxy = exports.resolveStatic = exports.resolveDirectives = exports.resolveStage = void 0;
5
4
  const constants_1 = require("@expressive-tea/commons/constants");
@@ -24,7 +23,9 @@ exports.resolveStage = resolveStage;
24
23
  async function resolveDirectives(instance, server) {
25
24
  const registeredDirectives = Metadata_1.default.get(constants_1.REGISTERED_DIRECTIVES_KEY, (0, object_helper_1.getClass)(instance)) || [];
26
25
  registeredDirectives.forEach((options) => {
27
- server.set.call(server, options.name, ...options.settings);
26
+ // @ts-expect-error Settings can be any parameter
27
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
28
+ server.set(options.name, ...options.settings);
28
29
  });
29
30
  }
30
31
  exports.resolveDirectives = resolveDirectives;
@@ -1,9 +1,9 @@
1
- import { NextFunction, Request, Response } from 'express';
2
- import { ExpressiveTeaAnnotations, ExpressiveTeaArgumentOptions } from '@expressive-tea/commons/interfaces';
1
+ import { type NextFunction, type Request, type Response } from 'express';
2
+ import { type ExpressiveTeaAnnotations, type ExpressiveTeaArgumentOptions } from '@expressive-tea/commons/interfaces';
3
3
  export declare function autoResponse(request: Request, response: Response, annotations: ExpressiveTeaAnnotations[], responseResult?: any): void;
4
4
  export declare function executeRequest(request: Request, response: Response, next: NextFunction): Promise<void>;
5
5
  export declare function mapArguments(decoratedArguments: ExpressiveTeaArgumentOptions[], request: Request, response: Response, next: NextFunction, introspectedArgs?: string[]): any[];
6
6
  export declare function extractParameters(target: unknown, args?: string | string[], propertyName?: string): any;
7
7
  export declare function generateRoute(route: string, verb: string, ...settings: any): (target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => void;
8
- export declare function router(verb: string, route: string, target: any, handler: (...args: any[]) => void | any | Promise<any>, propertyKey: string | symbol, settings?: any): void;
8
+ export declare function router(verb: string, route: string, target: any, handler: (...args: any[]) => never | any | Promise<any>, propertyKey: string | symbol, settings?: any): void;
9
9
  export declare function fileSettings(): any;
package/helpers/server.js CHANGED
@@ -10,7 +10,8 @@ const fs = require("fs");
10
10
  function autoResponse(request, response, annotations, responseResult) {
11
11
  const view = (0, lodash_1.find)(annotations, { type: 'view' });
12
12
  if (view) {
13
- return response.render(view.arguments[0], responseResult);
13
+ response.render(view.arguments[0], responseResult);
14
+ return;
14
15
  }
15
16
  response.send((0, lodash_1.isNumber)(responseResult) ? responseResult.toString() : responseResult);
16
17
  }
@@ -29,7 +30,8 @@ async function executeRequest(request, response, next) {
29
30
  }
30
31
  catch (e) {
31
32
  if (e instanceof RequestExceptions_1.GenericRequestException) {
32
- return next(e);
33
+ next(e);
34
+ return;
33
35
  }
34
36
  next(new RequestExceptions_1.GenericRequestException(e.message || 'System Error'));
35
37
  }
@@ -53,7 +55,7 @@ function mapArguments(decoratedArguments, request, response, next, introspectedA
53
55
  case constants_1.ARGUMENT_TYPES.GET_PARAM:
54
56
  return extractParameters(request.params, argument.arguments, (0, lodash_1.get)(introspectedArgs, argument.index));
55
57
  default:
56
- return;
58
+ return undefined;
57
59
  }
58
60
  })
59
61
  .thru((args) => (0, lodash_1.size)(args) ? args : [request, response, next])
@@ -77,7 +79,7 @@ function extractParameters(target, args, propertyName) {
77
79
  }
78
80
  exports.extractParameters = extractParameters;
79
81
  function generateRoute(route, verb, ...settings) {
80
- return (target, propertyKey, descriptor) => router(verb, route, target, descriptor.value, propertyKey, settings);
82
+ return (target, propertyKey, descriptor) => { router(verb, route, target, descriptor.value, propertyKey, settings); };
81
83
  }
82
84
  exports.generateRoute = generateRoute;
83
85
  function router(verb, route, target, handler, propertyKey, settings) {
@@ -1,15 +1,13 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import { KeyPairSyncResult } from 'crypto';
4
- import { NextFunction, Request, Response } from 'express';
5
- import ProxyRoute from '../classes/ProxyRoute';
3
+ import { type KeyPairSyncResult } from 'crypto';
4
+ import { type NextFunction, type Request, type Response } from 'express';
5
+ import type ProxyRoute from '../classes/ProxyRoute';
6
6
  export interface EncryptedMessage {
7
7
  iv: string;
8
8
  message: string;
9
9
  }
10
- export interface TeaGatewayMessage {
11
- [property: string]: any;
12
- }
10
+ export type TeaGatewayMessage = Record<string, any>;
13
11
  export default class TeaGatewayHelper {
14
12
  static encrypt(data: TeaGatewayMessage, signature: Buffer): EncryptedMessage;
15
13
  static decrypt(data: EncryptedMessage, signature: Buffer): TeaGatewayMessage;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const crypto = require("crypto");
4
+ const crypto_1 = require("crypto");
4
5
  class TeaGatewayHelper {
5
6
  static encrypt(data, signature) {
6
7
  const iv = crypto.randomBytes(16);
@@ -28,8 +29,7 @@ class TeaGatewayHelper {
28
29
  }, signature);
29
30
  }
30
31
  static generateKeys(passphrase) {
31
- const { generateKeyPairSync } = require('crypto');
32
- return generateKeyPairSync('ed25519', {
32
+ return (0, crypto_1.generateKeyPairSync)('ed25519', {
33
33
  modulusLength: 2048,
34
34
  publicKeyEncoding: {
35
35
  type: 'spki',
@@ -45,9 +45,11 @@ class TeaGatewayHelper {
45
45
  }
46
46
  static proxyResponse(proxyRoute, req, res, next) {
47
47
  const router = proxyRoute.registerRoute();
48
- if (!proxyRoute.hasClients())
49
- return next();
50
- return router(req, res, next);
48
+ if (!proxyRoute.hasClients()) {
49
+ next();
50
+ return;
51
+ }
52
+ router(req, res, next);
51
53
  }
52
54
  static httpSchema(schema) {
53
55
  if (schema.includes('teapot'))
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import * as http from 'http';
4
- import * as https from 'https';
3
+ import type * as http from 'http';
4
+ import type * as https from 'https';
5
5
  export declare function initWebsocket(server: http.Server, secureServer: https.Server): Promise<void>;
@@ -1,4 +1,4 @@
1
- import { ExpressiveTeaHandlerOptions } from '@expressive-tea/commons/interfaces';
1
+ import { type ExpressiveTeaHandlerOptions } from '@expressive-tea/commons/interfaces';
2
2
  export interface ExpressiveTeaHandlerOptionsWithInstrospectedArgs extends ExpressiveTeaHandlerOptions {
3
3
  introspectedArgs: string[];
4
4
  }
@@ -1,9 +1,9 @@
1
1
  import { Container } from 'inversify';
2
2
  declare const container: Container;
3
3
  export declare const decorators: {
4
- lazyInject: (serviceIdentifier: string | symbol | import("inversify/lib/interfaces/interfaces").interfaces.Newable<any> | import("inversify/lib/interfaces/interfaces").interfaces.Abstract<any>) => (proto: any, key: string) => void;
5
- lazyInjectNamed: (serviceIdentifier: string | symbol | import("inversify/lib/interfaces/interfaces").interfaces.Newable<any> | import("inversify/lib/interfaces/interfaces").interfaces.Abstract<any>, named: string) => (proto: any, key: string) => void;
6
- lazyInjectTagged: (serviceIdentifier: string | symbol | import("inversify/lib/interfaces/interfaces").interfaces.Newable<any> | import("inversify/lib/interfaces/interfaces").interfaces.Abstract<any>, key: string, value: any) => (proto: any, propertyName: string) => void;
7
- lazyMultiInject: (serviceIdentifier: string | symbol | import("inversify/lib/interfaces/interfaces").interfaces.Newable<any> | import("inversify/lib/interfaces/interfaces").interfaces.Abstract<any>) => (proto: any, key: string) => void;
4
+ lazyInject: (serviceIdentifier: string | symbol | import("inversify").interfaces.Newable<any> | import("inversify").interfaces.Abstract<any>) => (proto: any, key: string) => void;
5
+ lazyInjectNamed: (serviceIdentifier: string | symbol | import("inversify").interfaces.Newable<any> | import("inversify").interfaces.Abstract<any>, named: string) => (proto: any, key: string) => void;
6
+ lazyInjectTagged: (serviceIdentifier: string | symbol | import("inversify").interfaces.Newable<any> | import("inversify").interfaces.Abstract<any>, key: string, value: any) => (proto: any, propertyName: string) => void;
7
+ lazyMultiInject: (serviceIdentifier: string | symbol | import("inversify").interfaces.Newable<any> | import("inversify").interfaces.Abstract<any>) => (proto: any, key: string) => void;
8
8
  };
9
9
  export default container;
package/package.json CHANGED
@@ -1,21 +1,23 @@
1
1
  {
2
2
  "name": "@zerooneit/expressive-tea",
3
- "version": "1.3.0-beta.5",
3
+ "version": "1.3.0-beta.6",
4
4
  "description": "A REST API over Express and Typescript",
5
5
  "main": "classes/Boot.js",
6
6
  "engines": {
7
- "node": ">=16.0.0"
7
+ "node": ">=18.0.0"
8
8
  },
9
9
  "scripts": {
10
- "test": "yarn run linter && jest --clearCache && jest --coverage --ci --detectOpenHandles --forceExit --silent",
11
- "test:dev": "yarn run linter && jest --clearCache && jest --detectOpenHandles --forceExit",
12
- "linter": "tslint -c tslint.json -p tsconfig.json",
10
+ "test": "npm run linter && jest --clearCache && jest --coverage --ci --detectOpenHandles --forceExit --silent",
11
+ "test:dev": "npm run linter && jest --clearCache && jest --detectOpenHandles --forceExit",
12
+ "format": "prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\"",
13
+ "linter": "eslint --ext .ts . --fix",
14
+ "linter:ci": "eslint --ext .ts",
13
15
  "build:dev": "tsc --project tsconfig.json --watch",
14
16
  "build": "tsc --project tsconfig.json",
15
17
  "clean:build": "trash '**/*.js' '**/*.d.ts' '**/*.js.map' '**/*.d.ts.map' '!node_modules/**/*' '!docs/**/*' '!coverage/**/*' '!gulpfile.js' '!tasks/*.js' '!jest.config.js' '!tools/**/*'",
16
- "publish:prepare": "yarn run clean:build && yarn run build",
17
- "postpublish": "yarn run clean:build",
18
- "prepublishOnly": "yarn test && yarn run publish:prepare"
18
+ "publish:prepare": "npm run clean:build && npm run build",
19
+ "postpublish": "npm run clean:build",
20
+ "prepublishOnly": "npm test && npm run publish:prepare"
19
21
  },
20
22
  "publishConfig": {
21
23
  "access": "public"
@@ -27,40 +29,47 @@
27
29
  "devDependencies": {
28
30
  "@expressive-tea/commons": "^1.0.1",
29
31
  "@expressive-tea/plugin": "1.0.3",
30
- "@types/express": "4.17.17",
31
- "@types/express-http-proxy": "1.6.3",
32
- "@types/express-serve-static-core": "4.17.34",
33
- "@types/jest": "29.5.1",
34
- "@types/lodash": "4.14.194",
35
- "@types/node": "20.1.0",
32
+ "@types/express": "4.17.21",
33
+ "@types/express-http-proxy": "1.6.6",
34
+ "@types/express-serve-static-core": "4.19.0",
35
+ "@types/jest": "29.5.12",
36
+ "@types/lodash": "4.17.0",
37
+ "@types/node": "20.12.7",
36
38
  "@types/reflect-metadata": "0.1.0",
37
39
  "@types/socket.io": "3.0.2",
38
40
  "@types/socket.io-client": "3.0.0",
39
- "@types/ws": "8.5.4",
41
+ "@types/ws": "8.5.10",
42
+ "@typescript-eslint/eslint-plugin": "7.7.0",
43
+ "@typescript-eslint/parser": "7.7.0",
44
+ "eslint": "8.57.0",
45
+ "eslint-config-love": "^47.0.0",
46
+ "eslint-config-prettier": "9.1.0",
47
+ "eslint-plugin-jsdoc": "^48.2.3",
48
+ "eslint-plugin-prefer-arrow": "^1.2.3",
40
49
  "http-terminator": "3.2.0",
41
- "jest": "29.5.0",
50
+ "jest": "29.7.0",
42
51
  "jest-express": "1.12.0",
43
52
  "jest-junit": "16.0.0",
44
- "reflect-metadata": "0.1.13",
45
- "rimraf": "5.0.0",
46
- "supertest": "6.3.3",
53
+ "reflect-metadata": "0.2.2",
54
+ "rimraf": "5.0.5",
55
+ "supertest": "6.3.4",
47
56
  "toast-jsdoc": "1.0.2",
48
57
  "trash-cli": "5.0.0",
49
- "ts-jest": "29.1.0",
50
- "ts-node": "10.9.1",
51
- "tslint": "6.1.3",
52
- "typescript": "5.0.4"
58
+ "ts-jest": "29.1.2",
59
+ "ts-node": "10.9.2",
60
+ "tslib": "^2.6.2",
61
+ "typescript": "5.4.5"
53
62
  },
54
63
  "dependencies": {
55
- "express": "4.18.2",
56
- "express-http-proxy": "1.6.3",
57
- "inversify": "6.0.1",
64
+ "express": "4.19.2",
65
+ "express-http-proxy": "2.0.0",
66
+ "inversify": "6.0.2",
58
67
  "inversify-inject-decorators": "3.1.0",
59
68
  "lodash": "4.17.21",
60
- "socket.io": "4.6.1",
61
- "socket.io-client": "4.6.1",
69
+ "socket.io": "4.7.5",
70
+ "socket.io-client": "4.7.5",
62
71
  "url-scheme": "1.0.5",
63
- "ws": "8.13.0"
72
+ "ws": "8.16.0"
64
73
  },
65
74
  "repository": {
66
75
  "type": "git",
@@ -103,13 +112,14 @@
103
112
  },
104
113
  "homepage": "https://github.com/Expressive-Tea/expresive-tea#readme",
105
114
  "optionalDependencies": {
106
- "bufferutil": "4.0.7",
115
+ "bufferutil": "4.0.8",
107
116
  "utf-8-validate": "^6.0.0"
108
117
  },
109
118
  "resolutions": {
110
119
  "set-value": "4.1.0",
111
120
  "glob-parent": "6.0.2",
112
- "engine.io": "6.4.2"
121
+ "engine.io": "6.4.2",
122
+ "@typescript-eslint/eslint-plugin": "7.7.0"
113
123
  },
114
- "packageManager": "yarn@3.5.1"
124
+ "packageManager": "yarn@4.1.1"
115
125
  }
@@ -1,4 +1,6 @@
1
- import { Container } from 'inversify';
1
+ import { Container, interfaces } from 'inversify';
2
+ import ServiceIdentifier = interfaces.ServiceIdentifier;
3
+ import Newable = interfaces.Newable;
2
4
  /**
3
5
  * @module Services
4
6
  */
@@ -26,7 +28,7 @@ declare class DependencyInjection {
26
28
  * @param {string | symbol |never } [providerName="ClassName"] - Provide the provider identification.
27
29
  * @summary Add Provider to Dependency Injection Providers
28
30
  */
29
- static setProvider(ProviderFactory: any, providerName?: string | symbol): void;
31
+ static setProvider(ProviderFactory: Newable<any>, providerName?: ServiceIdentifier<string | symbol>): void;
30
32
  }
31
33
  /**
32
34
  * @module Decorators/DependencyInjection
@@ -27,8 +27,8 @@ class DependencyInjection {
27
27
  * @summary Add Provider to Dependency Injection Providers
28
28
  */
29
29
  static setProvider(ProviderFactory, providerName) {
30
- if (!rootContainer.isBound(providerName || ProviderFactory.name)) {
31
- rootContainer.bind(providerName || ProviderFactory.name).to(ProviderFactory);
30
+ if (!rootContainer.isBound(providerName !== null && providerName !== void 0 ? providerName : ProviderFactory.name)) {
31
+ rootContainer.bind(providerName !== null && providerName !== void 0 ? providerName : ProviderFactory.name).to(ProviderFactory);
32
32
  }
33
33
  }
34
34
  }
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import WebSocket from 'ws';
4
- import * as http from 'http';
3
+ import type WebSocket from 'ws';
4
+ import type * as http from 'http';
5
5
  import * as https from 'https';
6
6
  export default class WebsocketService {
7
7
  static instance: WebsocketService;
@@ -0,0 +1,24 @@
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
+ }
@@ -0,0 +1,12 @@
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
+