@breautek/storm 6.0.1 → 6.0.3
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 +13 -0
- package/docs/assets/search.js +1 -1
- package/docs/classes/Application.html +47 -32
- package/docs/classes/BackendAuthenticationMiddleware.html +3 -3
- package/docs/classes/CORSMiddleware.html +7 -7
- package/docs/classes/ConfigLoader.html +2 -2
- package/docs/classes/Database.html +13 -13
- package/docs/classes/DatabaseCastObject.html +4 -4
- package/docs/classes/DatabaseConnection.html +20 -20
- package/docs/classes/DatabaseQueryError.html +11 -11
- package/docs/classes/DeadLockError.html +11 -11
- package/docs/classes/DiskSpaceError.html +11 -11
- package/docs/classes/DropTemporaryTableQuery.html +9 -9
- package/docs/classes/DuplicateEntryError.html +11 -11
- package/docs/classes/EntityNotFoundError.html +11 -11
- package/docs/classes/ExpiredTokenError.html +11 -11
- package/docs/classes/Handler.html +14 -14
- package/docs/classes/InternalError.html +11 -11
- package/docs/classes/InvalidCredentialsError.html +11 -11
- package/docs/classes/InvalidValueError.html +11 -11
- package/docs/classes/LineString.html +5 -5
- package/docs/classes/LockWaitTimeoutError.html +11 -11
- package/docs/classes/ManagedDatabaseConnection.html +20 -20
- package/docs/classes/Middleware.html +4 -4
- package/docs/classes/MissingConfigError.html +11 -11
- package/docs/classes/MissingParameterError.html +11 -11
- package/docs/classes/MySQLConnection.html +21 -21
- package/docs/classes/MySQLDatabase.html +14 -14
- package/docs/classes/NotImplementedError.html +11 -11
- package/docs/classes/Point.html +5 -5
- package/docs/classes/Polygon.html +5 -5
- package/docs/classes/Query.html +9 -9
- package/docs/classes/RawError.html +11 -11
- package/docs/classes/RawQuery.html +9 -9
- package/docs/classes/Request.html +19 -19
- package/docs/classes/Response.html +12 -12
- package/docs/classes/ResponseData.html +8 -8
- package/docs/classes/ServiceProvider.html +16 -16
- package/docs/classes/ServiceResponse.html +6 -6
- package/docs/classes/SetSessionVariableQuery.html +9 -9
- package/docs/classes/StormError.html +11 -11
- package/docs/classes/TemporaryTableQuery.html +9 -9
- package/docs/classes/Token.html +3 -3
- package/docs/classes/TokenManager.html +5 -5
- package/docs/classes/Transaction.html +7 -7
- package/docs/classes/UnauthorizedAccessError.html +11 -11
- 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/functions/getInstance.html +4 -1
- 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 +9 -9
- package/docs/interfaces/IDatabaseConfig.html +7 -7
- package/docs/interfaces/IDatabaseConnection.html +15 -15
- package/docs/interfaces/IErrorResponse.html +6 -6
- package/docs/interfaces/IFormData.html +3 -3
- package/docs/interfaces/IHandler.html +2 -2
- package/docs/interfaces/IInsertQueryResult.html +4 -4
- package/docs/interfaces/IJWTVerifyOptions.html +2 -2
- package/docs/interfaces/IParameterMap.html +1 -1
- package/docs/interfaces/IQueryable.html +6 -6
- package/docs/interfaces/IRequestResponse.html +3 -3
- package/docs/interfaces/IServiceHeaders.html +1 -1
- package/docs/interfaces/ISetSessionVariableQueryInput.html +3 -3
- package/docs/interfaces/ITemporaryTableQueryInput.html +3 -3
- package/docs/interfaces/IUpdateQueryResult.html +3 -3
- package/docs/types/IDeleteQueryResult.html +1 -1
- package/docs/types/IHandlerError.html +1 -1
- package/docs/types/IHandlerResponse.html +1 -1
- package/docs/types/TCoordinate.html +1 -1
- package/lib/Application.d.ts +4 -3
- package/lib/Application.js +4 -1
- package/lib/Application.js.map +1 -1
- package/lib/ConfigLoader.js +23 -1
- package/lib/ConfigLoader.js.map +1 -1
- package/lib/Handler.js +0 -1
- package/lib/Handler.js.map +1 -1
- package/lib/MySQLConnection.js.map +1 -1
- package/lib/StormError.js.map +1 -1
- package/lib/instance.d.ts +8 -0
- package/lib/instance.js +8 -0
- package/lib/instance.js.map +1 -1
- package/package.json +9 -9
- package/src/Application.ts +12 -7
- package/src/BackendAuthenticationMiddleware.ts +2 -2
- package/src/ConfigLoader.ts +23 -1
- package/src/Handler.ts +2 -3
- package/src/MySQLConnection.ts +2 -2
- package/src/StormError.ts +2 -2
- package/src/instance.ts +8 -0
package/src/Application.ts
CHANGED
|
@@ -32,7 +32,8 @@ import * as http from 'http';
|
|
|
32
32
|
import { IAuthTokenData } from '@arashi/token';
|
|
33
33
|
import {
|
|
34
34
|
Logger,
|
|
35
|
-
CloudWatchStream
|
|
35
|
+
CloudWatchStream,
|
|
36
|
+
BaseLogger
|
|
36
37
|
} from '@arashi/logger';
|
|
37
38
|
import { StormError } from './StormError';
|
|
38
39
|
|
|
@@ -49,7 +50,7 @@ export abstract class Application
|
|
|
49
50
|
TDBConnectionAPI = any
|
|
50
51
|
>
|
|
51
52
|
extends EventEmitter {
|
|
52
|
-
private $logger:
|
|
53
|
+
private $logger: BaseLogger;
|
|
53
54
|
private $name: string;
|
|
54
55
|
private $configPath: string;
|
|
55
56
|
private $config: TConfig;
|
|
@@ -161,9 +162,13 @@ export abstract class Application
|
|
|
161
162
|
protected _initialize(config: TConfig): Promise<void> {
|
|
162
163
|
return Promise.resolve();
|
|
163
164
|
}
|
|
165
|
+
|
|
166
|
+
protected _createLogger(config: TConfig): BaseLogger {
|
|
167
|
+
return new Logger(this.getName(), config.log?.level);
|
|
168
|
+
}
|
|
164
169
|
|
|
165
|
-
protected _initLogger(config: TConfig):
|
|
166
|
-
let logger:
|
|
170
|
+
protected _initLogger(config: TConfig): BaseLogger {
|
|
171
|
+
let logger: BaseLogger = this._createLogger(config);
|
|
167
172
|
|
|
168
173
|
if (config?.log?.cloudwatch) {
|
|
169
174
|
let cwConfig: ICloudwatchConfig = config.log.cloudwatch;
|
|
@@ -179,7 +184,7 @@ export abstract class Application
|
|
|
179
184
|
return logger;
|
|
180
185
|
}
|
|
181
186
|
|
|
182
|
-
private $connectCW(logger:
|
|
187
|
+
private $connectCW(logger: BaseLogger, cwConfig: ICloudwatchConfig): void {
|
|
183
188
|
logger.pipe(new CloudWatchStream({
|
|
184
189
|
region: cwConfig.region,
|
|
185
190
|
credentials: {
|
|
@@ -226,7 +231,7 @@ export abstract class Application
|
|
|
226
231
|
return null;
|
|
227
232
|
}
|
|
228
233
|
|
|
229
|
-
public getLogger():
|
|
234
|
+
public getLogger(): BaseLogger {
|
|
230
235
|
return this.$logger;
|
|
231
236
|
}
|
|
232
237
|
|
|
@@ -362,7 +367,7 @@ export abstract class Application
|
|
|
362
367
|
return this.$name;
|
|
363
368
|
}
|
|
364
369
|
|
|
365
|
-
private $getLogger():
|
|
370
|
+
private $getLogger(): BaseLogger {
|
|
366
371
|
return this.$logger;
|
|
367
372
|
}
|
|
368
373
|
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import {StatusCode} from './StatusCode';
|
|
18
18
|
import {Request} from './Request';
|
|
19
19
|
import {ResponseData} from './ResponseData';
|
|
20
|
-
import {
|
|
20
|
+
import {BaseLogger} from '@arashi/logger';
|
|
21
21
|
import {getInstance} from './instance';
|
|
22
22
|
import {IConfig} from './IConfig';
|
|
23
23
|
|
|
@@ -30,7 +30,7 @@ const TAG: string = 'BackendAuthenticationMiddleware';
|
|
|
30
30
|
* for their specific use cases.
|
|
31
31
|
*/
|
|
32
32
|
export class BackendAuthenticationMiddleware {
|
|
33
|
-
private $logger:
|
|
33
|
+
private $logger: BaseLogger;
|
|
34
34
|
|
|
35
35
|
public constructor() {
|
|
36
36
|
this.$logger = getInstance().getLogger();
|
package/src/ConfigLoader.ts
CHANGED
|
@@ -138,7 +138,29 @@ export class ConfigLoader {
|
|
|
138
138
|
null
|
|
139
139
|
]
|
|
140
140
|
},
|
|
141
|
-
|
|
141
|
+
cloudwatch: {
|
|
142
|
+
type: [ 'object', 'null' ],
|
|
143
|
+
additionalProperties: false,
|
|
144
|
+
properties: {
|
|
145
|
+
region: { type: 'string' },
|
|
146
|
+
credentials: {
|
|
147
|
+
type: 'object',
|
|
148
|
+
additionalProperties: false,
|
|
149
|
+
properties: {
|
|
150
|
+
accessKeyId: { type: 'string' },
|
|
151
|
+
secretAccessKey: { type: 'string' }
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
stream: {
|
|
155
|
+
type: 'object',
|
|
156
|
+
additionalProperties: false,
|
|
157
|
+
properties: {
|
|
158
|
+
group: { type: 'string' },
|
|
159
|
+
name: { type: 'string' }
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
},
|
|
142
164
|
filters: {
|
|
143
165
|
type: [ 'array', 'null' ],
|
|
144
166
|
items: { type: 'string' }
|
package/src/Handler.ts
CHANGED
|
@@ -23,12 +23,11 @@ import {StormError} from './StormError';
|
|
|
23
23
|
import {IConfig} from './IConfig';
|
|
24
24
|
import { InternalError } from './InternalError';
|
|
25
25
|
import { IRequestResponse } from './IRequestResponse';
|
|
26
|
-
import {
|
|
26
|
+
import { BaseLogger } from '@arashi/logger';
|
|
27
27
|
import { ResponseData } from './ResponseData';
|
|
28
28
|
import { ReadStream } from 'fs';
|
|
29
29
|
import { NotImplementedError } from './NotImplementedError';
|
|
30
30
|
import { HTTPMethod } from './HTTPMethod';
|
|
31
|
-
// import { Stream } from 'stream';
|
|
32
31
|
|
|
33
32
|
const TAG: string = 'Handler';
|
|
34
33
|
|
|
@@ -94,7 +93,7 @@ export class Handler<
|
|
|
94
93
|
response
|
|
95
94
|
};
|
|
96
95
|
|
|
97
|
-
let logger:
|
|
96
|
+
let logger: BaseLogger = getInstance().getLogger();
|
|
98
97
|
|
|
99
98
|
try {
|
|
100
99
|
for (let i: number = 0; i < this.$middlewares.length; i++) {
|
package/src/MySQLConnection.ts
CHANGED
|
@@ -24,7 +24,7 @@ import { StartTransactionQuery } from './private/StartTransactionQuery';
|
|
|
24
24
|
import { CommitQuery } from './private/CommitQuery';
|
|
25
25
|
import { RollbackQuery } from './private/RollbackQuery';
|
|
26
26
|
import * as SQLFormatter from 'sql-formatter';
|
|
27
|
-
import {
|
|
27
|
+
import { BaseLogger } from '@arashi/logger';
|
|
28
28
|
import {LogLevel} from '@arashi/interfaces';
|
|
29
29
|
import { StormError } from './StormError';
|
|
30
30
|
import { DeadLockError } from './DeadLockError';
|
|
@@ -86,7 +86,7 @@ export class MySQLConnection extends DatabaseConnection<MySQL.PoolConnection> {
|
|
|
86
86
|
|
|
87
87
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
88
88
|
protected _query(query: string, params?: any): Promise<any> {
|
|
89
|
-
let logger:
|
|
89
|
+
let logger: BaseLogger = getInstance().getLogger();
|
|
90
90
|
return new Promise((resolve, reject) => {
|
|
91
91
|
let queryObject: MySQL.Query = this.getAPI().query({
|
|
92
92
|
sql: query,
|
package/src/StormError.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import {getInstance} from './instance';
|
|
18
|
-
import {
|
|
18
|
+
import {BaseLogger} from '@arashi/logger';
|
|
19
19
|
import {StatusCode} from './StatusCode';
|
|
20
20
|
import { ExitCode } from './ExitCode';
|
|
21
21
|
|
|
@@ -46,7 +46,7 @@ export abstract class StormError<TErrorDetails = any> extends Error {
|
|
|
46
46
|
|
|
47
47
|
this.$details = details;
|
|
48
48
|
|
|
49
|
-
let logger:
|
|
49
|
+
let logger: BaseLogger = getInstance().getLogger();
|
|
50
50
|
logger.error(TAG, `${this.getMessage()}... See details below:`);
|
|
51
51
|
logger.info(TAG, this.getPrivateDetails());
|
|
52
52
|
}
|
package/src/instance.ts
CHANGED
|
@@ -18,6 +18,10 @@ import {Application} from './Application';
|
|
|
18
18
|
|
|
19
19
|
let instance: Application;
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated No replacement.
|
|
23
|
+
* @param app
|
|
24
|
+
*/
|
|
21
25
|
let setInstance = (app: Application): void => {
|
|
22
26
|
if (instance) {
|
|
23
27
|
instance.getLogger().warn('ApplicationInstance', 'Storm application already initialized');
|
|
@@ -25,6 +29,10 @@ let setInstance = (app: Application): void => {
|
|
|
25
29
|
instance = app;
|
|
26
30
|
};
|
|
27
31
|
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Pass down Application via constructors/factory methods, when applicable.
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
28
36
|
let getInstance = (): Application => {
|
|
29
37
|
return instance;
|
|
30
38
|
};
|