@breautek/storm 9.7.5 → 9.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Application.html +92 -62
- package/docs/classes/ConfigLoader.html +4 -4
- package/docs/classes/Database.html +14 -14
- package/docs/classes/DatabaseCastObject.html +5 -5
- package/docs/classes/DatabaseConnection.html +26 -26
- package/docs/classes/DatabaseQueryError.html +16 -16
- package/docs/classes/DeadLockError.html +16 -16
- package/docs/classes/DiskSpaceError.html +15 -15
- package/docs/classes/DropTemporaryTableQuery.html +11 -11
- package/docs/classes/DuplicateEntryError.html +15 -15
- package/docs/classes/EntityNotFoundError.html +15 -15
- package/docs/classes/ExpiredTokenError.html +15 -15
- package/docs/classes/ForbiddenError.html +15 -15
- package/docs/classes/GetMySQLVersion.html +11 -11
- package/docs/classes/Handler.html +16 -16
- package/docs/classes/IllegalStateError.html +15 -15
- package/docs/classes/InternalError.html +15 -15
- package/docs/classes/InvalidCredentialsError.html +15 -15
- package/docs/classes/InvalidValueError.html +15 -15
- package/docs/classes/LineString.html +6 -6
- package/docs/classes/LockWaitTimeoutError.html +16 -16
- package/docs/classes/ManagedDatabaseConnection.html +25 -25
- package/docs/classes/MetricStore.html +7 -7
- package/docs/classes/Middleware.html +5 -5
- package/docs/classes/MissingConfigError.html +15 -15
- package/docs/classes/MissingParameterError.html +15 -15
- package/docs/classes/MySQLConnection.html +29 -29
- package/docs/classes/MySQLDatabase.html +15 -15
- package/docs/classes/NotImplementedError.html +15 -15
- package/docs/classes/Point.html +6 -6
- package/docs/classes/Polygon.html +6 -6
- package/docs/classes/Query.html +11 -11
- package/docs/classes/RawError.html +15 -15
- package/docs/classes/RawQuery.html +11 -11
- package/docs/classes/Request.html +26 -26
- package/docs/classes/Response.html +12 -12
- package/docs/classes/ResponseData.html +9 -9
- package/docs/classes/ServiceProvider.html +16 -16
- package/docs/classes/ServiceResponse.html +6 -6
- package/docs/classes/SetSessionVariableQuery.html +11 -11
- package/docs/classes/StormError.html +15 -15
- package/docs/classes/TemporaryTableQuery.html +11 -11
- package/docs/classes/TimeoutError.html +15 -15
- package/docs/classes/Token.html +3 -3
- package/docs/classes/TokenManager.html +6 -6
- package/docs/classes/Transaction.html +8 -8
- package/docs/classes/UnauthorizedAccessError.html +15 -15
- package/docs/enums/ErrorCode.html +10 -10
- package/docs/enums/ExitCode.html +3 -3
- package/docs/enums/HTTPMethod.html +5 -5
- package/docs/enums/IsolationLevel.html +5 -5
- package/docs/enums/JWTError.html +3 -3
- package/docs/enums/StatusCode.html +49 -49
- package/docs/enums/TransactionAccessLevel.html +3 -3
- package/docs/functions/getInstance.html +1 -1
- package/docs/hierarchy.html +39 -39
- package/docs/interfaces/IAdditionalErrorDetails.html +1 -1
- package/docs/interfaces/ICloudwatchConfig.html +4 -4
- package/docs/interfaces/ICloudwatchCredentials.html +3 -3
- package/docs/interfaces/ICloudwatchStreamConfig.html +3 -3
- package/docs/interfaces/IConfig.html +13 -13
- package/docs/interfaces/IDatabaseConfig.html +7 -7
- package/docs/interfaces/IDatabaseConnection.html +20 -20
- package/docs/interfaces/IDatabasePosition.html +3 -3
- package/docs/interfaces/IErrorResponse.html +6 -6
- package/docs/interfaces/IFormData.html +3 -3
- package/docs/interfaces/IGetMySQLVersionResult.html +5 -5
- package/docs/interfaces/IGetMySQLVersionRow.html +2 -2
- package/docs/interfaces/IHistogramConfig.html +6 -6
- package/docs/interfaces/IInsertQueryResult.html +4 -4
- package/docs/interfaces/IJWTVerifyOptions.html +2 -2
- package/docs/interfaces/IMetricConfig.html +5 -5
- package/docs/interfaces/IMetricCounter.html +3 -3
- package/docs/interfaces/IMetricGauge.html +7 -7
- package/docs/interfaces/IMetricHistogram.html +4 -4
- package/docs/interfaces/IOKPacket.html +9 -9
- package/docs/interfaces/IParameterMap.html +1 -1
- package/docs/interfaces/IQueryable.html +7 -7
- package/docs/interfaces/IRequestResponse.html +3 -3
- package/docs/interfaces/ISetSessionVariableQueryInput.html +3 -3
- package/docs/interfaces/IStormCLIArgs.html +8 -8
- package/docs/interfaces/ITemporaryTableQueryInput.html +3 -3
- package/docs/interfaces/IUpdateQueryResult.html +3 -3
- package/docs/interfaces/formidable.FileJSON.html +1 -1
- package/docs/interfaces/formidable.Part.html +18 -18
- package/docs/types/IDeleteQueryResult.html +1 -1
- package/docs/types/IStoredProcedureResult.html +1 -1
- package/docs/types/TCoordinate.html +1 -1
- package/docs/types/TExpiresIn.html +1 -1
- package/docs/types/TSerializableResponse.html +1 -1
- package/docs/types/TSupportedResponsePrimitives.html +1 -1
- package/docs/types/TSupportedResponseTypes.html +1 -1
- package/lib/Application.d.ts +9 -1
- package/lib/Application.js +11 -1
- package/lib/Application.js.map +1 -1
- package/lib/HandlerAttacher.d.ts +10 -0
- package/lib/HandlerAttacher.js +31 -0
- package/lib/HandlerAttacher.js.map +1 -0
- package/lib/IHandlerAttachBridge.d.ts +4 -0
- package/lib/IHandlerAttachBridge.js +3 -0
- package/lib/IHandlerAttachBridge.js.map +1 -0
- package/lib/RawHandlerAttacher.d.ts +11 -0
- package/lib/RawHandlerAttacher.js +37 -0
- package/lib/RawHandlerAttacher.js.map +1 -0
- package/package.json +5 -6
- package/pnpm-workspace.yaml +4 -0
- package/src/Application.ts +16 -2
- package/src/HandlerAttacher.ts +37 -0
- package/src/IHandlerAttachBridge.ts +6 -0
- package/src/RawHandlerAttacher.ts +44 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@breautek/storm",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.8.0",
|
|
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.
|
|
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,14 +66,14 @@
|
|
|
67
66
|
},
|
|
68
67
|
"devDependencies": {
|
|
69
68
|
"@arashi/interfaces": "1.2.1",
|
|
70
|
-
"@arashi/logger": "4.1.
|
|
69
|
+
"@arashi/logger": "4.1.7",
|
|
71
70
|
"@jest/types": "30.4.1",
|
|
72
|
-
"@totalpave/eslint-plugin": "7.1.
|
|
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.
|
|
76
|
+
"@types/node": "26.3.0",
|
|
78
77
|
"auto-changelog": "2.6.0",
|
|
79
78
|
"jest": "30.4.2",
|
|
80
79
|
"jest-jasmine2": "30.4.2",
|
package/pnpm-workspace.yaml
CHANGED
package/src/Application.ts
CHANGED
|
@@ -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,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
|
+
}
|