@breautek/storm 9.7.5 → 9.8.1

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 (116) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/docs/assets/hierarchy.js +1 -1
  3. package/docs/assets/search.js +1 -1
  4. package/docs/classes/Application.html +92 -62
  5. package/docs/classes/ConfigLoader.html +4 -4
  6. package/docs/classes/Database.html +14 -14
  7. package/docs/classes/DatabaseCastObject.html +5 -5
  8. package/docs/classes/DatabaseConnection.html +26 -26
  9. package/docs/classes/DatabaseQueryError.html +16 -16
  10. package/docs/classes/DeadLockError.html +16 -16
  11. package/docs/classes/DiskSpaceError.html +15 -15
  12. package/docs/classes/DropTemporaryTableQuery.html +11 -11
  13. package/docs/classes/DuplicateEntryError.html +15 -15
  14. package/docs/classes/EntityNotFoundError.html +15 -15
  15. package/docs/classes/ExpiredTokenError.html +15 -15
  16. package/docs/classes/ForbiddenError.html +15 -15
  17. package/docs/classes/GetMySQLVersion.html +11 -11
  18. package/docs/classes/Handler.html +16 -16
  19. package/docs/classes/IllegalStateError.html +15 -15
  20. package/docs/classes/InternalError.html +15 -15
  21. package/docs/classes/InvalidCredentialsError.html +15 -15
  22. package/docs/classes/InvalidValueError.html +15 -15
  23. package/docs/classes/LineString.html +6 -6
  24. package/docs/classes/LockWaitTimeoutError.html +16 -16
  25. package/docs/classes/ManagedDatabaseConnection.html +25 -25
  26. package/docs/classes/MetricStore.html +7 -7
  27. package/docs/classes/Middleware.html +5 -5
  28. package/docs/classes/MissingConfigError.html +15 -15
  29. package/docs/classes/MissingParameterError.html +15 -15
  30. package/docs/classes/MySQLConnection.html +29 -29
  31. package/docs/classes/MySQLDatabase.html +15 -15
  32. package/docs/classes/NotImplementedError.html +15 -15
  33. package/docs/classes/Point.html +6 -6
  34. package/docs/classes/Polygon.html +6 -6
  35. package/docs/classes/Query.html +11 -11
  36. package/docs/classes/RawError.html +15 -15
  37. package/docs/classes/RawQuery.html +11 -11
  38. package/docs/classes/Request.html +26 -26
  39. package/docs/classes/Response.html +12 -12
  40. package/docs/classes/ResponseData.html +9 -9
  41. package/docs/classes/ServiceProvider.html +16 -16
  42. package/docs/classes/ServiceResponse.html +6 -6
  43. package/docs/classes/SetSessionVariableQuery.html +11 -11
  44. package/docs/classes/StormError.html +15 -15
  45. package/docs/classes/TemporaryTableQuery.html +11 -11
  46. package/docs/classes/TimeoutError.html +15 -15
  47. package/docs/classes/Token.html +3 -3
  48. package/docs/classes/TokenManager.html +6 -6
  49. package/docs/classes/Transaction.html +8 -8
  50. package/docs/classes/UnauthorizedAccessError.html +15 -15
  51. package/docs/enums/ErrorCode.html +10 -10
  52. package/docs/enums/ExitCode.html +3 -3
  53. package/docs/enums/HTTPMethod.html +5 -5
  54. package/docs/enums/IsolationLevel.html +5 -5
  55. package/docs/enums/JWTError.html +3 -3
  56. package/docs/enums/StatusCode.html +49 -49
  57. package/docs/enums/TransactionAccessLevel.html +3 -3
  58. package/docs/functions/getInstance.html +1 -1
  59. package/docs/hierarchy.html +39 -39
  60. package/docs/interfaces/IAdditionalErrorDetails.html +1 -1
  61. package/docs/interfaces/ICloudwatchConfig.html +4 -4
  62. package/docs/interfaces/ICloudwatchCredentials.html +3 -3
  63. package/docs/interfaces/ICloudwatchStreamConfig.html +3 -3
  64. package/docs/interfaces/IConfig.html +13 -13
  65. package/docs/interfaces/IDatabaseConfig.html +7 -7
  66. package/docs/interfaces/IDatabaseConnection.html +20 -20
  67. package/docs/interfaces/IDatabasePosition.html +3 -3
  68. package/docs/interfaces/IErrorResponse.html +6 -6
  69. package/docs/interfaces/IFormData.html +3 -3
  70. package/docs/interfaces/IGetMySQLVersionResult.html +5 -5
  71. package/docs/interfaces/IGetMySQLVersionRow.html +2 -2
  72. package/docs/interfaces/IHistogramConfig.html +6 -6
  73. package/docs/interfaces/IInsertQueryResult.html +4 -4
  74. package/docs/interfaces/IJWTVerifyOptions.html +2 -2
  75. package/docs/interfaces/IMetricConfig.html +5 -5
  76. package/docs/interfaces/IMetricCounter.html +3 -3
  77. package/docs/interfaces/IMetricGauge.html +7 -7
  78. package/docs/interfaces/IMetricHistogram.html +4 -4
  79. package/docs/interfaces/IOKPacket.html +9 -9
  80. package/docs/interfaces/IParameterMap.html +1 -1
  81. package/docs/interfaces/IQueryable.html +7 -7
  82. package/docs/interfaces/IRequestResponse.html +3 -3
  83. package/docs/interfaces/ISetSessionVariableQueryInput.html +3 -3
  84. package/docs/interfaces/IStormCLIArgs.html +8 -8
  85. package/docs/interfaces/ITemporaryTableQueryInput.html +3 -3
  86. package/docs/interfaces/IUpdateQueryResult.html +3 -3
  87. package/docs/interfaces/formidable.FileJSON.html +1 -1
  88. package/docs/interfaces/formidable.Part.html +18 -18
  89. package/docs/types/IDeleteQueryResult.html +1 -1
  90. package/docs/types/IStoredProcedureResult.html +1 -1
  91. package/docs/types/TCoordinate.html +1 -1
  92. package/docs/types/TExpiresIn.html +1 -1
  93. package/docs/types/TSerializableResponse.html +1 -1
  94. package/docs/types/TSupportedResponsePrimitives.html +1 -1
  95. package/docs/types/TSupportedResponseTypes.html +1 -1
  96. package/lib/Application.d.ts +9 -1
  97. package/lib/Application.js +11 -1
  98. package/lib/Application.js.map +1 -1
  99. package/lib/HandlerAttacher.d.ts +10 -0
  100. package/lib/HandlerAttacher.js +31 -0
  101. package/lib/HandlerAttacher.js.map +1 -0
  102. package/lib/IHandlerAttachBridge.d.ts +4 -0
  103. package/lib/IHandlerAttachBridge.js +3 -0
  104. package/lib/IHandlerAttachBridge.js.map +1 -0
  105. package/lib/RawHandlerAttacher.d.ts +11 -0
  106. package/lib/RawHandlerAttacher.js +37 -0
  107. package/lib/RawHandlerAttacher.js.map +1 -0
  108. package/lib/Response.js +12 -1
  109. package/lib/Response.js.map +1 -1
  110. package/package.json +9 -10
  111. package/pnpm-workspace.yaml +5 -0
  112. package/src/Application.ts +16 -2
  113. package/src/HandlerAttacher.ts +37 -0
  114. package/src/IHandlerAttachBridge.ts +6 -0
  115. package/src/RawHandlerAttacher.ts +44 -0
  116. package/src/Response.ts +14 -1
package/lib/Response.js CHANGED
@@ -74,12 +74,23 @@ class Response {
74
74
  this.$response.send(data);
75
75
  }
76
76
  }
77
- // public send(data?: TResponse | TErrorResponse | StormError | IErrorResponse | Buffer): void {
78
77
  send(data) {
79
78
  this.$send(data);
80
79
  this.$app.getLogger().info(TAG, `API ${this.$requestURL} (${this.getStatus()}) responded in ${new Date().getTime() - this.$created.getTime()}ms`);
81
80
  }
82
81
  pipe(stream) {
82
+ stream.on('error', (error) => {
83
+ this.$app.getLogger().error(TAG, error);
84
+ stream.unpipe(this.$response);
85
+ if (this.isHeadersSent()) {
86
+ // Response is already committed. An abnormal termination is
87
+ // the only way left to signal failure to the client.
88
+ this.$response.destroy(error);
89
+ }
90
+ else {
91
+ this.error(error);
92
+ }
93
+ });
83
94
  stream.on('end', () => {
84
95
  stream.unpipe(this.$response);
85
96
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Response.js","sourceRoot":"","sources":["../src/Response.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;EAcE;;;AAEF,6CAAwC;AACxC,iDAA4C;AAC5C,6CAAwD;AAExD,mDAAgD;AAChD,mCAAgC;AAGhC,MAAM,GAAG,GAAW,UAAU,CAAC;AAiD/B,MAAa,QAAQ;IAMjB,YAAmB,GAAgB,EAAE,QAA0B,EAAE,UAAkB;QAC/E,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,IAAI,EAAE,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAClC,CAAC;IAEM,SAAS,CAAC,MAAkB;QAC/B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,SAAS;QACZ,OAAO,IAAI,CA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YAAiC;QAC/C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACrC,CAAC;IAEM,aAAa;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;IACtC,CAAC;IAEM,KAAK,CAAC,KAAwE;QACjF,IAAI,KAAK,EAAE,CAAC;YACR,IAAI,KAAK,YAAY,uBAAU,EAAE,CAAC;gBAC9B,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;iBACI,IAAI,KAAK,YAAY,2BAAY,EAAE,CAAC;gBACrC,IAAI,OAAO,GAAwB,KAAK,CAAC,UAAU,EAAE,CAAC;gBACtD,KAAK,IAAI,MAAM,IAAI,OAAO,EAAE,CAAC;oBACzB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBACzC,CAAC;gBAED,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;iBACI,CAAC;gBACF,IAAI,CAAC,IAAI,CAAC,IAAI,6BAAa,CAAC,KAAK,CAAC,CAAC,CAAC;YACxC,CAAC;QACL,CAAC;aACI,CAAC;YACF,IAAI,CAAC,IAAI,CAAC,IAAI,6BAAa,CAAC,KAAK,CAAC,CAAC,CAAC;QACxC,CAAC;IACL,CAAC;CACJ;AAvID,4BAuIC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@breautek/storm",
3
- "version": "9.7.5",
3
+ "version": "9.8.1",
4
4
  "description": "Object-Oriented REST API framework",
5
5
  "main": "lib/api.js",
6
6
  "types": "lib/api.d.ts",
@@ -17,7 +17,6 @@
17
17
  "unit": "jest",
18
18
  "test": "npm run-script lint && jest",
19
19
  "coverage": "codecov",
20
- "clean": "rm -r ./lib && rm -r ./docs",
21
20
  "prepublishOnly": "npm run-script build-lib",
22
21
  "changelog": "auto-changelog --output CHANGELOG.md -p --release-summary --ignore-commit-pattern chore",
23
22
  "preversion": "npm test",
@@ -56,7 +55,7 @@
56
55
  "form-data": "4.0.6",
57
56
  "formidable": "3.5.4",
58
57
  "jsonwebtoken": "9.0.3",
59
- "mysql2": "3.23.2",
58
+ "mysql2": "3.24.2",
60
59
  "prom-client": "15.1.3",
61
60
  "sql-formatter": "15.8.2",
62
61
  "tslib": "2.8.1"
@@ -67,21 +66,21 @@
67
66
  },
68
67
  "devDependencies": {
69
68
  "@arashi/interfaces": "1.2.1",
70
- "@arashi/logger": "4.1.5",
71
- "@jest/types": "30.4.1",
72
- "@totalpave/eslint-plugin": "7.1.1",
69
+ "@arashi/logger": "4.1.7",
70
+ "@jest/types": "30.5.0",
71
+ "@totalpave/eslint-plugin": "7.1.2",
73
72
  "@types/body-parser": "1.19.6",
74
73
  "@types/jest": "30.0.0",
75
74
  "@types/jsonwebtoken": "9.0.10",
76
75
  "@types/mysql": "2.15.27",
77
- "@types/node": "26.1.2",
76
+ "@types/node": "26.4.0",
78
77
  "auto-changelog": "2.6.0",
79
- "jest": "30.4.2",
80
- "jest-jasmine2": "30.4.2",
78
+ "jest": "30.5.0",
79
+ "jest-jasmine2": "30.5.0",
81
80
  "ts-jest": "29.4.12",
82
81
  "ts-node": "10.9.2",
83
82
  "typedoc": "0.28.20",
84
- "typedoc-plugin-markdown": "4.12.0",
83
+ "typedoc-plugin-markdown": "4.13.0",
85
84
  "typescript": "5.9.3"
86
85
  }
87
86
  }
@@ -1,6 +1,11 @@
1
1
  allowBuilds:
2
+ '@parcel/watcher': true
2
3
  unrs-resolver: true
3
4
 
5
+ minimumReleaseAgeExclude:
6
+ - '@totalpave/eslint-plugin@7.1.2'
7
+ - '@types/node@26.3.0'
8
+
4
9
  onlyBuiltDependencies:
5
10
  - unrs-resolver
6
11
 
@@ -40,6 +40,9 @@ import { StormError } from './StormError';
40
40
  import { PrometheusServer } from './PrometheusServer';
41
41
  import { MetricStore } from './MetricStore';
42
42
  import * as OS from 'node:os';
43
+ import { IHandlerAttachBridge } from './IHandlerAttachBridge';
44
+ import { RawHandlerAttacher } from './RawHandlerAttacher';
45
+ import { HandlerAttacher } from './HandlerAttacher';
43
46
 
44
47
  export interface IStormCLIArgs {
45
48
  bind?: string;
@@ -193,6 +196,9 @@ export abstract class Application
193
196
  this.$getLogger().trace(TAG, 'Starting server...');
194
197
  this.$server = Express();
195
198
  this.$server.set('trust proxy', 'loopback');
199
+
200
+ await this._attachRawHandlers(new RawHandlerAttacher(this, this.$server));
201
+
196
202
  this.$server.use(BodyParser.json({
197
203
  type : 'application/json',
198
204
  limit : this.getRequestSizeLimit()
@@ -212,7 +218,7 @@ export abstract class Application
212
218
 
213
219
  this.$getLogger().trace(TAG, 'Attaching handlers...');
214
220
  await this.$attachHandlers();
215
- await this._attachHandlers();
221
+ await this._attachHandlers(new HandlerAttacher(this, this.$server));
216
222
 
217
223
  await this._onBeforeReadyAsync();
218
224
 
@@ -401,11 +407,17 @@ export abstract class Application
401
407
  *
402
408
  * @param path The URL API path. E.g. /api/myService/myCommand/
403
409
  * @param Handler
410
+ * @deprecated - Use {@link IHandlerAttachBridge} instead
404
411
  */
405
412
  public attachHandler(path: string, handler: Handler): void {
406
413
  this.attachHandlerInstance(path, handler);
407
414
  }
408
415
 
416
+ /**
417
+ * @deprecated - Use {@link IHandlerAttachBridge} instead
418
+ * @param path
419
+ * @param handler
420
+ */
409
421
  public attachHandlerInstance(path: string, handler: Handler): void {
410
422
  this.$server.get(path, (request: Express.Request, response: Express.Response) => {
411
423
  let r: Request = new Request(request);
@@ -455,7 +467,9 @@ export abstract class Application
455
467
  * Subclasses are expected to attach the API handlers for their service. This will be invoked during application startup.
456
468
  * @returns Promise<void>
457
469
  */
458
- protected abstract _attachHandlers(): Promise<void>;
470
+ protected abstract _attachHandlers(attacher: IHandlerAttachBridge): Promise<void>;
471
+
472
+ protected async _attachRawHandlers(attacher: IHandlerAttachBridge): Promise<void> {}
459
473
 
460
474
  /**
461
475
  * @deprecated Supply the configs via --config and --local-config arguments
@@ -0,0 +1,37 @@
1
+
2
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
3
+ import Express = require('express');
4
+ import {Application} from './Application';
5
+ import { Handler } from './Handler';
6
+ import { IHandlerAttachBridge } from './IHandlerAttachBridge';
7
+ import {Request} from './Request';
8
+ import {Response} from './Response';
9
+
10
+ export class HandlerAttacher implements IHandlerAttachBridge {
11
+ private $server: Express.Application;
12
+ private $app: Application;
13
+
14
+ public constructor(app: Application, server: Express.Application) {
15
+ this.$server = server;
16
+ this.$app = app;
17
+ }
18
+
19
+ public attach(path: string, handler: Handler): void {
20
+ this.$server.get(path, (request: Express.Request, response: Express.Response) => {
21
+ let r: Request = new Request(request);
22
+ void handler.get(r, new Response(this.$app, response, r.getURL()));
23
+ });
24
+ this.$server.post(path, (request: Express.Request, response: Express.Response) => {
25
+ let r: Request = new Request(request);
26
+ void handler.post(r, new Response(this.$app, response, r.getURL()));
27
+ });
28
+ this.$server.put(path, (request: Express.Request, response: Express.Response) => {
29
+ let r: Request = new Request(request);
30
+ void handler.put(r, new Response(this.$app, response, r.getURL()));
31
+ });
32
+ this.$server.delete(path, (request: Express.Request, response: Express.Response) => {
33
+ let r: Request = new Request(request);
34
+ void handler.delete(r, new Response(this.$app, response, r.getURL()));
35
+ });
36
+ }
37
+ }
@@ -0,0 +1,6 @@
1
+
2
+ import { Handler } from './Handler';
3
+
4
+ export interface IHandlerAttachBridge {
5
+ attach(path: string, handler: Handler): void;
6
+ }
@@ -0,0 +1,44 @@
1
+
2
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
3
+ import Express = require('express');
4
+ import {Application} from './Application';
5
+ import { Handler } from './Handler';
6
+ import { IHandlerAttachBridge } from './IHandlerAttachBridge';
7
+ import {Request} from './Request';
8
+ import {Response} from './Response';
9
+ import * as BodyParser from 'body-parser';
10
+
11
+ export class RawHandlerAttacher implements IHandlerAttachBridge {
12
+ private $server: Express.Application;
13
+ private $app: Application;
14
+ private $parser: ReturnType<typeof BodyParser.raw>;
15
+
16
+ public constructor(app: Application, server: Express.Application) {
17
+ this.$server = server;
18
+ this.$app = app;
19
+
20
+ this.$parser = BodyParser.raw({
21
+ type: '*/*',
22
+ limit: app.getRequestSizeLimit()
23
+ });
24
+ }
25
+
26
+ public attach(path: string, handler: Handler): void {
27
+ this.$server.get(path, this.$parser, (request: Express.Request, response: Express.Response) => {
28
+ let r: Request = new Request(request);
29
+ void handler.get(r, new Response(this.$app, response, r.getURL()));
30
+ });
31
+ this.$server.post(path, this.$parser, (request: Express.Request, response: Express.Response) => {
32
+ let r: Request = new Request(request);
33
+ void handler.post(r, new Response(this.$app, response, r.getURL()));
34
+ });
35
+ this.$server.put(path, this.$parser, (request: Express.Request, response: Express.Response) => {
36
+ let r: Request = new Request(request);
37
+ void handler.put(r, new Response(this.$app, response, r.getURL()));
38
+ });
39
+ this.$server.delete(path, this.$parser, (request: Express.Request, response: Express.Response) => {
40
+ let r: Request = new Request(request);
41
+ void handler.delete(r, new Response(this.$app, response, r.getURL()));
42
+ });
43
+ }
44
+ }
package/src/Response.ts CHANGED
@@ -135,13 +135,26 @@ export class Response<TResponse extends TSupportedResponseTypes> {
135
135
  }
136
136
  }
137
137
 
138
- // public send(data?: TResponse | TErrorResponse | StormError | IErrorResponse | Buffer): void {
139
138
  public send(data?: TResponse | ResponseData<TResponse> | ResponseData<StormError> | StormError | IErrorResponse): void {
140
139
  this.$send(data);
141
140
  this.$app.getLogger().info(TAG, `API ${this.$requestURL} (${this.getStatus()}) responded in ${new Date().getTime() - this.$created.getTime()}ms`);
142
141
  }
143
142
 
144
143
  public pipe(stream: NodeJS.ReadableStream): void {
144
+ stream.on('error', (error: Error) => {
145
+ this.$app.getLogger().error(TAG, error);
146
+ stream.unpipe(this.$response);
147
+
148
+ if (this.isHeadersSent()) {
149
+ // Response is already committed. An abnormal termination is
150
+ // the only way left to signal failure to the client.
151
+ this.$response.destroy(error);
152
+ }
153
+ else {
154
+ this.error(error);
155
+ }
156
+ });
157
+
145
158
  stream.on('end', () => {
146
159
  stream.unpipe(this.$response);
147
160
  });