@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.
Files changed (96) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/docs/assets/search.js +1 -1
  3. package/docs/classes/Application.html +47 -32
  4. package/docs/classes/BackendAuthenticationMiddleware.html +3 -3
  5. package/docs/classes/CORSMiddleware.html +7 -7
  6. package/docs/classes/ConfigLoader.html +2 -2
  7. package/docs/classes/Database.html +13 -13
  8. package/docs/classes/DatabaseCastObject.html +4 -4
  9. package/docs/classes/DatabaseConnection.html +20 -20
  10. package/docs/classes/DatabaseQueryError.html +11 -11
  11. package/docs/classes/DeadLockError.html +11 -11
  12. package/docs/classes/DiskSpaceError.html +11 -11
  13. package/docs/classes/DropTemporaryTableQuery.html +9 -9
  14. package/docs/classes/DuplicateEntryError.html +11 -11
  15. package/docs/classes/EntityNotFoundError.html +11 -11
  16. package/docs/classes/ExpiredTokenError.html +11 -11
  17. package/docs/classes/Handler.html +14 -14
  18. package/docs/classes/InternalError.html +11 -11
  19. package/docs/classes/InvalidCredentialsError.html +11 -11
  20. package/docs/classes/InvalidValueError.html +11 -11
  21. package/docs/classes/LineString.html +5 -5
  22. package/docs/classes/LockWaitTimeoutError.html +11 -11
  23. package/docs/classes/ManagedDatabaseConnection.html +20 -20
  24. package/docs/classes/Middleware.html +4 -4
  25. package/docs/classes/MissingConfigError.html +11 -11
  26. package/docs/classes/MissingParameterError.html +11 -11
  27. package/docs/classes/MySQLConnection.html +21 -21
  28. package/docs/classes/MySQLDatabase.html +14 -14
  29. package/docs/classes/NotImplementedError.html +11 -11
  30. package/docs/classes/Point.html +5 -5
  31. package/docs/classes/Polygon.html +5 -5
  32. package/docs/classes/Query.html +9 -9
  33. package/docs/classes/RawError.html +11 -11
  34. package/docs/classes/RawQuery.html +9 -9
  35. package/docs/classes/Request.html +19 -19
  36. package/docs/classes/Response.html +12 -12
  37. package/docs/classes/ResponseData.html +8 -8
  38. package/docs/classes/ServiceProvider.html +16 -16
  39. package/docs/classes/ServiceResponse.html +6 -6
  40. package/docs/classes/SetSessionVariableQuery.html +9 -9
  41. package/docs/classes/StormError.html +11 -11
  42. package/docs/classes/TemporaryTableQuery.html +9 -9
  43. package/docs/classes/Token.html +3 -3
  44. package/docs/classes/TokenManager.html +5 -5
  45. package/docs/classes/Transaction.html +7 -7
  46. package/docs/classes/UnauthorizedAccessError.html +11 -11
  47. package/docs/enums/ErrorCode.html +10 -10
  48. package/docs/enums/ExitCode.html +3 -3
  49. package/docs/enums/HTTPMethod.html +5 -5
  50. package/docs/enums/IsolationLevel.html +5 -5
  51. package/docs/enums/JWTError.html +3 -3
  52. package/docs/enums/StatusCode.html +49 -49
  53. package/docs/functions/getInstance.html +4 -1
  54. package/docs/interfaces/IAdditionalErrorDetails.html +1 -1
  55. package/docs/interfaces/ICloudwatchConfig.html +4 -4
  56. package/docs/interfaces/ICloudwatchCredentials.html +3 -3
  57. package/docs/interfaces/ICloudwatchStreamConfig.html +3 -3
  58. package/docs/interfaces/IConfig.html +9 -9
  59. package/docs/interfaces/IDatabaseConfig.html +7 -7
  60. package/docs/interfaces/IDatabaseConnection.html +15 -15
  61. package/docs/interfaces/IErrorResponse.html +6 -6
  62. package/docs/interfaces/IFormData.html +3 -3
  63. package/docs/interfaces/IHandler.html +2 -2
  64. package/docs/interfaces/IInsertQueryResult.html +4 -4
  65. package/docs/interfaces/IJWTVerifyOptions.html +2 -2
  66. package/docs/interfaces/IParameterMap.html +1 -1
  67. package/docs/interfaces/IQueryable.html +6 -6
  68. package/docs/interfaces/IRequestResponse.html +3 -3
  69. package/docs/interfaces/IServiceHeaders.html +1 -1
  70. package/docs/interfaces/ISetSessionVariableQueryInput.html +3 -3
  71. package/docs/interfaces/ITemporaryTableQueryInput.html +3 -3
  72. package/docs/interfaces/IUpdateQueryResult.html +3 -3
  73. package/docs/types/IDeleteQueryResult.html +1 -1
  74. package/docs/types/IHandlerError.html +1 -1
  75. package/docs/types/IHandlerResponse.html +1 -1
  76. package/docs/types/TCoordinate.html +1 -1
  77. package/lib/Application.d.ts +4 -3
  78. package/lib/Application.js +4 -1
  79. package/lib/Application.js.map +1 -1
  80. package/lib/ConfigLoader.js +23 -1
  81. package/lib/ConfigLoader.js.map +1 -1
  82. package/lib/Handler.js +0 -1
  83. package/lib/Handler.js.map +1 -1
  84. package/lib/MySQLConnection.js.map +1 -1
  85. package/lib/StormError.js.map +1 -1
  86. package/lib/instance.d.ts +8 -0
  87. package/lib/instance.js +8 -0
  88. package/lib/instance.js.map +1 -1
  89. package/package.json +9 -9
  90. package/src/Application.ts +12 -7
  91. package/src/BackendAuthenticationMiddleware.ts +2 -2
  92. package/src/ConfigLoader.ts +23 -1
  93. package/src/Handler.ts +2 -3
  94. package/src/MySQLConnection.ts +2 -2
  95. package/src/StormError.ts +2 -2
  96. package/src/instance.ts +8 -0
@@ -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: 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): Logger {
166
- let logger: Logger = new Logger(this.getName(), config.log?.level);
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: Logger, cwConfig: ICloudwatchConfig): void {
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(): Logger {
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(): Logger {
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 {Logger} from '@arashi/logger';
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: Logger;
33
+ private $logger: BaseLogger;
34
34
 
35
35
  public constructor() {
36
36
  this.$logger = getInstance().getLogger();
@@ -138,7 +138,29 @@ export class ConfigLoader {
138
138
  null
139
139
  ]
140
140
  },
141
- directory: { type: [ 'string', 'null' ] },
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 { Logger } from '@arashi/logger';
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: Logger = getInstance().getLogger();
96
+ let logger: BaseLogger = getInstance().getLogger();
98
97
 
99
98
  try {
100
99
  for (let i: number = 0; i < this.$middlewares.length; i++) {
@@ -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 { Logger } from '@arashi/logger';
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: Logger = getInstance().getLogger();
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 {Logger} from '@arashi/logger';
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: Logger = getInstance().getLogger();
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
  };