@breautek/storm 6.0.5 → 6.1.0-beta.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 (148) hide show
  1. package/.eslintrc.js +1 -1
  2. package/CHANGELOG.md +14 -0
  3. package/docs/assets/main.js +4 -3
  4. package/docs/assets/navigation.js +1 -0
  5. package/docs/assets/search.js +1 -1
  6. package/docs/assets/style.css +26 -10
  7. package/docs/classes/Application.html +118 -1153
  8. package/docs/classes/BackendAuthenticationMiddleware.html +5 -175
  9. package/docs/classes/CORSMiddleware.html +8 -240
  10. package/docs/classes/ConfigLoader.html +5 -149
  11. package/docs/classes/Database.html +3 -313
  12. package/docs/classes/DatabaseCastObject.html +3 -184
  13. package/docs/classes/DatabaseConnection.html +48 -539
  14. package/docs/classes/DatabaseQueryError.html +9 -345
  15. package/docs/classes/DeadLockError.html +10 -346
  16. package/docs/classes/DiskSpaceError.html +9 -335
  17. package/docs/classes/DropTemporaryTableQuery.html +9 -266
  18. package/docs/classes/DuplicateEntryError.html +9 -339
  19. package/docs/classes/EntityNotFoundError.html +9 -335
  20. package/docs/classes/ExpiredTokenError.html +9 -335
  21. package/docs/classes/Handler.html +3 -367
  22. package/docs/classes/InternalError.html +9 -335
  23. package/docs/classes/InvalidCredentialsError.html +9 -335
  24. package/docs/classes/InvalidValueError.html +9 -346
  25. package/docs/classes/LineString.html +3 -193
  26. package/docs/classes/LockWaitTimeoutError.html +10 -346
  27. package/docs/classes/ManagedDatabaseConnection.html +3 -376
  28. package/docs/classes/Middleware.html +3 -184
  29. package/docs/classes/MissingConfigError.html +9 -335
  30. package/docs/classes/MissingParameterError.html +9 -335
  31. package/docs/classes/MySQLConnection.html +48 -534
  32. package/docs/classes/MySQLDatabase.html +3 -325
  33. package/docs/classes/NotImplementedError.html +9 -335
  34. package/docs/classes/Point.html +3 -195
  35. package/docs/classes/Polygon.html +3 -193
  36. package/docs/classes/Query.html +9 -293
  37. package/docs/classes/RawError.html +10 -346
  38. package/docs/classes/RawQuery.html +9 -286
  39. package/docs/classes/Request.html +3 -342
  40. package/docs/classes/Response.html +3 -303
  41. package/docs/classes/ResponseData.html +3 -233
  42. package/docs/classes/ServiceProvider.html +3 -355
  43. package/docs/classes/ServiceResponse.html +3 -193
  44. package/docs/classes/SetSessionVariableQuery.html +9 -266
  45. package/docs/classes/StormError.html +9 -350
  46. package/docs/classes/TemporaryTableQuery.html +9 -271
  47. package/docs/classes/Token.html +3 -164
  48. package/docs/classes/TokenManager.html +3 -214
  49. package/docs/classes/Transaction.html +4 -241
  50. package/docs/classes/UnauthorizedAccessError.html +9 -335
  51. package/docs/enums/ErrorCode.html +10 -193
  52. package/docs/enums/ExitCode.html +3 -144
  53. package/docs/enums/HTTPMethod.html +5 -158
  54. package/docs/enums/IsolationLevel.html +5 -158
  55. package/docs/enums/JWTError.html +3 -144
  56. package/docs/enums/StatusCode.html +49 -466
  57. package/docs/functions/formidable-1.html +1 -126
  58. package/docs/functions/getInstance.html +2 -124
  59. package/docs/index.html +11 -142
  60. package/docs/interfaces/IAdditionalErrorDetails.html +1 -123
  61. package/docs/interfaces/IAuthTokenData.html +2 -153
  62. package/docs/interfaces/ICloudwatchConfig.html +2 -153
  63. package/docs/interfaces/ICloudwatchCredentials.html +2 -147
  64. package/docs/interfaces/ICloudwatchStreamConfig.html +2 -147
  65. package/docs/interfaces/IConfig.html +2 -201
  66. package/docs/interfaces/IDatabaseConfig.html +2 -176
  67. package/docs/interfaces/IDatabaseConnection.html +2 -302
  68. package/docs/interfaces/IErrorResponse.html +2 -165
  69. package/docs/interfaces/IFormData.html +2 -147
  70. package/docs/interfaces/IHandler.html +2 -154
  71. package/docs/interfaces/IInsertQueryResult.html +2 -153
  72. package/docs/interfaces/IJWTVerifyOptions.html +2 -141
  73. package/docs/interfaces/IParameterMap.html +1 -123
  74. package/docs/interfaces/IQueryable.html +2 -212
  75. package/docs/interfaces/IRequestResponse.html +2 -154
  76. package/docs/interfaces/IServiceHeaders.html +1 -123
  77. package/docs/interfaces/ISetSessionVariableQueryInput.html +2 -147
  78. package/docs/interfaces/ITemporaryTableQueryInput.html +2 -147
  79. package/docs/interfaces/IUpdateQueryResult.html +2 -147
  80. package/docs/interfaces/formidable.EmitData.html +2 -179
  81. package/docs/interfaces/formidable.EventData.html +2 -197
  82. package/docs/interfaces/formidable.Fields.html +1 -143
  83. package/docs/interfaces/formidable.File.html +11 -238
  84. package/docs/interfaces/formidable.FileJSON.html +8 -235
  85. package/docs/interfaces/formidable.Files.html +1 -143
  86. package/docs/interfaces/formidable.Options.html +24 -290
  87. package/docs/interfaces/formidable.Part.html +45 -627
  88. package/docs/modules/formidable.html +10 -154
  89. package/docs/types/IDeleteQueryResult.html +1 -117
  90. package/docs/types/IHandlerError.html +2 -120
  91. package/docs/types/IHandlerResponse.html +2 -120
  92. package/docs/types/TCoordinate.html +1 -117
  93. package/docs/types/formidable.BufferEncoding.html +1 -137
  94. package/docs/types/formidable.DefaultOptions.html +1 -142
  95. package/docs/types/formidable.EnabledPlugins.html +1 -137
  96. package/docs/types/formidable.EventNames.html +1 -137
  97. package/docs/types/formidable.MappedParsers.html +1 -137
  98. package/docs/types/formidable.Plugin.html +1 -137
  99. package/docs/types/formidable.PluginFunction.html +1 -152
  100. package/docs/types/formidable.Plugins.html +1 -137
  101. package/jest.config.js +1 -1
  102. package/lib/Application.d.ts +30 -3
  103. package/lib/Application.js +51 -9
  104. package/lib/Application.js.map +1 -1
  105. package/lib/ApplicationEvent.js +1 -1
  106. package/lib/ApplicationEvent.js.map +1 -1
  107. package/lib/CORSMiddleware.d.ts +3 -3
  108. package/lib/CORSMiddleware.js.map +1 -1
  109. package/lib/ConfigLoader.d.ts +16 -8
  110. package/lib/ConfigLoader.js +59 -32
  111. package/lib/ConfigLoader.js.map +1 -1
  112. package/lib/ErrorCode.js +1 -1
  113. package/lib/ErrorCode.js.map +1 -1
  114. package/lib/ExitCode.js +1 -1
  115. package/lib/ExitCode.js.map +1 -1
  116. package/lib/HTTPMethod.js +1 -1
  117. package/lib/HTTPMethod.js.map +1 -1
  118. package/lib/Handler.d.ts +1 -1
  119. package/lib/IConfig.d.ts +2 -2
  120. package/lib/InvalidConfigError.d.ts +2 -2
  121. package/lib/InvalidConfigError.js.map +1 -1
  122. package/lib/IsolationLevel.js +1 -1
  123. package/lib/IsolationLevel.js.map +1 -1
  124. package/lib/JWTError.js +1 -1
  125. package/lib/JWTError.js.map +1 -1
  126. package/lib/LineString.d.ts +1 -1
  127. package/lib/LineString.js.map +1 -1
  128. package/lib/MySQLConnection.js +1 -2
  129. package/lib/MySQLConnection.js.map +1 -1
  130. package/lib/Polygon.d.ts +1 -1
  131. package/lib/Polygon.js.map +1 -1
  132. package/lib/Request.js.map +1 -1
  133. package/lib/StatusCode.js +1 -1
  134. package/lib/StatusCode.js.map +1 -1
  135. package/package.json +24 -23
  136. package/src/Application.ts +96 -14
  137. package/src/CORSMiddleware.ts +5 -5
  138. package/src/ConfigLoader.ts +81 -40
  139. package/src/DatabaseConnection.ts +1 -1
  140. package/src/Handler.ts +2 -2
  141. package/src/IConfig.ts +2 -2
  142. package/src/InvalidConfigError.ts +2 -2
  143. package/src/LineString.ts +2 -2
  144. package/src/MySQLConnection.ts +1 -2
  145. package/src/Polygon.ts +3 -3
  146. package/src/Request.ts +1 -1
  147. package/tsconfig.json +1 -2
  148. package/tsconfig-tests.json +0 -15
@@ -29,6 +29,7 @@ import {Command} from 'commander';
29
29
  import * as Express from 'express';
30
30
  import * as BodyParser from 'body-parser';
31
31
  import * as http from 'http';
32
+ import * as Path from 'path';
32
33
  import { IAuthTokenData } from '@arashi/token';
33
34
  import {
34
35
  Logger,
@@ -37,6 +38,14 @@ import {
37
38
  } from '@arashi/logger';
38
39
  import { StormError } from './StormError';
39
40
 
41
+ export interface IStormCLIArgs {
42
+ bind?: string;
43
+ port?: number;
44
+ authentication_header?: string;
45
+ configFile?: string;
46
+ localConfigFile?: string;
47
+ }
48
+
40
49
  const TAG: string = 'Application';
41
50
 
42
51
  /**
@@ -52,7 +61,24 @@ export abstract class Application
52
61
  extends EventEmitter {
53
62
  private $logger: BaseLogger;
54
63
  private $name: string;
64
+
65
+ /**
66
+ * Path to the config directory.
67
+ * This is used as a fallback and it will be expected that
68
+ * bt-config.json and bt-local-config.json are found.
69
+ */
70
+ private $configDir: string;
71
+
72
+ /**
73
+ * Path to a bt-config.json file
74
+ */
55
75
  private $configPath: string;
76
+
77
+ /**
78
+ * Path to a bt-local-config.json file
79
+ */
80
+ private $localConfigPath: string;
81
+
56
82
  private $config: TConfig;
57
83
  private $tokenManager: TokenManager<TAuthToken>;
58
84
  private $server: Express.Application;
@@ -60,17 +86,21 @@ export abstract class Application
60
86
  private $socket: http.Server;
61
87
  private $program: Command;
62
88
 
89
+ private $usingDeprecatedConfigPath: boolean;
90
+
63
91
  /**
64
92
  *
65
93
  * @param name The application name
66
- * @param configPath The directory where bt-config.json and bt-local-config.json can be found. Defaults to current working directory.
94
+ * @param configPath @deprecated The directory where bt-config.json and bt-local-config.json can be found. Defaults to current working directory.
67
95
  */
68
- public constructor(name: string, configPath: string) {
96
+ public constructor(name: string, configPath?: string) {
69
97
  super();
70
98
 
71
99
  setInstance(this);
72
100
 
73
101
  this.$buildArgOptions();
102
+
103
+ this.$usingDeprecatedConfigPath = !!configPath;
74
104
 
75
105
  this.$program.parse(process.argv);
76
106
 
@@ -85,7 +115,7 @@ export abstract class Application
85
115
  }
86
116
  });
87
117
 
88
- this.$configPath = configPath || process.cwd();
118
+ this.$configDir = configPath || process.cwd();
89
119
  }
90
120
 
91
121
  public async start(): Promise<void> {
@@ -94,6 +124,10 @@ export abstract class Application
94
124
  this.$logger.info(TAG, 'Application is booting...');
95
125
  this.$logger.info(TAG, 'Loading Configuration...');
96
126
 
127
+ if (this.$usingDeprecatedConfigPath) {
128
+ this.$getLogger().warn(TAG, `configPath constructor argument is deprecated. Use --config and --local_config instead.`);
129
+ }
130
+
97
131
  try {
98
132
  await this.$load();
99
133
  }
@@ -103,7 +137,7 @@ export abstract class Application
103
137
  }
104
138
 
105
139
  private async $load(): Promise<void> {
106
- this.$config = await this.loadConfig(this.$configPath);
140
+ this.$config = await this.$loadConfig();
107
141
  this.$logger = await this._initLogger(this.$config);
108
142
 
109
143
  this.$getLogger().trace(TAG, 'Configuration loaded.');
@@ -252,24 +286,31 @@ export abstract class Application
252
286
  return port;
253
287
  }
254
288
 
255
- // eslint-disable-next-line @typescript-eslint/naming-convention
256
- private $buildArgOptions() {
257
- this.$program = new Command();
289
+ protected _getVersion(): string {
290
+ console.warn(TAG, `_getVersion will be an abstract method in the next major release. Override this method and pass a version string.`);
291
+ return '0.0.0';
292
+ }
258
293
 
259
- // eslint-disable-next-line @typescript-eslint/no-var-requires
294
+ private $getVersionString(): string {
260
295
  let pkg: any = require('../package.json');
296
+ return `${this._getVersion()} (Storm ${pkg.version})`;
297
+ }
298
+
299
+ private $buildArgOptions() {
300
+ this.$program = new Command();
261
301
 
262
- this.$program.version(pkg.version, '-v, --version');
302
+ this.$program.version(this.$getVersionString(), '-v, --version');
263
303
  this.$program.allowUnknownOption(true);
264
304
  this.$program.allowExcessArguments(true);
265
305
  this.$program.option('--port <port>', 'The running port to consume');
266
306
  this.$program.option('--bind <ip>', 'The binding IP to listen on');
267
307
  this.$program.option('--authentication_header <header>', 'The header name of the authentication token');
308
+ this.$program.option('--config <path>', 'The path to the bt-config.json file');
309
+ this.$program.option('--local-config <path>', 'The path to the bt-local-config.json file.');
268
310
 
269
311
  this._buildArgOptions(this.$program);
270
312
  }
271
313
 
272
- // eslint-disable-next-line @typescript-eslint/no-empty-function
273
314
  protected _buildArgOptions(program: Command): void {}
274
315
 
275
316
  public getProgram(): Command {
@@ -346,6 +387,7 @@ export abstract class Application
346
387
  protected abstract _attachHandlers(): Promise<void>;
347
388
 
348
389
  /**
390
+ * @deprecated Supply the configs via --config and --local-config arguments
349
391
  *
350
392
  * @param path The directory path that contains bt-config.json and bt-local-config.json
351
393
  */
@@ -366,6 +408,38 @@ export abstract class Application
366
408
  });
367
409
  }
368
410
 
411
+ private async $loadConfig(): Promise<TConfig> {
412
+ let loader: ConfigLoader<TConfig> = new ConfigLoader<TConfig>(this);
413
+ return await loader.load(this.$getConfigFilePath(), this.$getLocalConfigFilePath());
414
+ }
415
+
416
+ private $getLocalConfigFilePath(): string {
417
+ if (!this.$localConfigPath) {
418
+ let filePath: string = this.getCmdLineArgs().localConfigFile;
419
+ if (!filePath) {
420
+ filePath = Path.resolve(this.$configDir, 'bt-local-config.json');
421
+ }
422
+
423
+ this.$localConfigPath = Path.resolve(filePath);
424
+ }
425
+
426
+ return this.$localConfigPath;
427
+ }
428
+
429
+ private $getConfigFilePath(): string {
430
+ if (!this.$configPath) {
431
+ let filePath: string = this.getCmdLineArgs().configFile;
432
+
433
+ if (!filePath) {
434
+ filePath = Path.resolve(this.$configDir, 'bt-config.json');
435
+ }
436
+
437
+ this.$configPath = Path.resolve(filePath);
438
+ }
439
+
440
+ return this.$configPath;
441
+ }
442
+
369
443
  /**
370
444
  * @returns the application name
371
445
  */
@@ -423,16 +497,16 @@ export abstract class Application
423
497
  /**
424
498
  * @returns command line arguments
425
499
  */
426
- public getCmdLineArgs(): TConfig {
500
+ public getCmdLineArgs(): IStormCLIArgs {
427
501
  let program: Command = this.$program;
428
- let o: any = {};
429
-
430
- let opts: any = program.opts();
502
+ let o: IStormCLIArgs = {};
431
503
 
432
504
  if (!program) {
433
505
  return o;
434
506
  }
435
507
 
508
+ let opts: any = program.opts();
509
+
436
510
  if (opts.bind !== undefined) {
437
511
  o.bind = opts.bind;
438
512
  }
@@ -445,6 +519,14 @@ export abstract class Application
445
519
  o.authentication_header = opts.authentication_header;
446
520
  }
447
521
 
522
+ if (opts.config !== undefined) {
523
+ o.configFile = opts.config;
524
+ }
525
+
526
+ if (opts.localConfig !== undefined) {
527
+ o.localConfigFile = opts.localConfig;
528
+ }
529
+
448
530
  return o;
449
531
  }
450
532
 
@@ -27,8 +27,8 @@ import {getInstance} from './instance';
27
27
  */
28
28
  export class CORSMiddleware extends Middleware {
29
29
  private $allowedOrigin: string;
30
- private $allowedHeaders: Array<string>;
31
- private $allowedMethods: Array<string>;
30
+ private $allowedHeaders: string[];
31
+ private $allowedMethods: string[];
32
32
 
33
33
  /**
34
34
  * @constructor
@@ -36,7 +36,7 @@ export class CORSMiddleware extends Middleware {
36
36
  * @param allowedHeaders Array of allowed headers.
37
37
  * @param allowedMethods Array of allowed HTTP methods.
38
38
  */
39
- public constructor(allowedOrigin?: string, allowedHeaders?: Array<string>, allowedMethods?: Array<string>) {
39
+ public constructor(allowedOrigin?: string, allowedHeaders?: string[], allowedMethods?: string[]) {
40
40
  super();
41
41
 
42
42
  this.$allowedOrigin = (!allowedOrigin) ? this.getDefaultAllowedOrigin() : allowedOrigin;
@@ -51,7 +51,7 @@ export class CORSMiddleware extends Middleware {
51
51
  return null;
52
52
  }
53
53
 
54
- public getDefaultAllowedHeaders(): Array<string> {
54
+ public getDefaultAllowedHeaders(): string[] {
55
55
  return [
56
56
  'Accept',
57
57
  getInstance().getConfig().authentication_header,
@@ -61,7 +61,7 @@ export class CORSMiddleware extends Middleware {
61
61
  ];
62
62
  }
63
63
 
64
- public getDefaultAllowedMethods(): Array<string> {
64
+ public getDefaultAllowedMethods(): string[] {
65
65
  return [
66
66
  'GET',
67
67
  'POST',
@@ -17,9 +17,9 @@
17
17
  */
18
18
 
19
19
  import {getInstance} from './instance';
20
- import {Logger} from '@arashi/logger';
20
+ import {BaseLogger} from '@arashi/logger';
21
21
  import * as Path from 'path';
22
- import {Application} from './Application';
22
+ import {Application, IStormCLIArgs} from './Application';
23
23
  import {IConfig} from './IConfig';
24
24
  import Ajv from 'ajv';
25
25
  import * as MergeChange from '@breautek/merge-change';
@@ -28,18 +28,24 @@ import { MissingConfigError } from './MissingConfigError';
28
28
 
29
29
  const TAG: string = 'ConfigLoader';
30
30
 
31
- export class ConfigLoader {
32
- private constructor() {}
31
+ export class ConfigLoader<TConfig extends IConfig = IConfig> {
32
+ private $logger: BaseLogger;
33
+ private $app: Application;
33
34
 
34
- public static async load(path: string): Promise<IConfig> {
35
- let logger: Logger = ConfigLoader.$getLogger();
35
+ public constructor(app: Application) {
36
+ this.$app = app;
37
+ this.$logger = app.getLogger();
38
+ }
39
+
40
+ public async load(configFile: string, localConfigFile: string): Promise<TConfig> {
41
+ let logger: BaseLogger = this.$logger;
36
42
 
37
43
  logger.trace(TAG, 'Configuration loaded.');
38
44
 
39
- let config: IConfig = {};
45
+ let config: Partial<TConfig> = {};
40
46
 
41
- let cPath: string = Path.resolve(path, 'bt-config.json');
42
- let lPath: string = Path.resolve(path, 'bt-local-config.json');
47
+ let cPath: string = configFile;
48
+ let lPath: string = localConfigFile;
43
49
 
44
50
  let c: IConfig;
45
51
  let l: IConfig;
@@ -59,7 +65,7 @@ export class ConfigLoader {
59
65
  }
60
66
 
61
67
  logger.trace(TAG, 'Reading command line arguments...');
62
- config = MergeChange.merge(config, ConfigLoader.$getCmdLineArgs());
68
+ config = MergeChange.merge(config, this.$getCmdLineArgs());
63
69
 
64
70
  if (config.log.level === null) {
65
71
  config.log.level = defaults.log.level;
@@ -68,31 +74,81 @@ export class ConfigLoader {
68
74
  logger.trace(TAG, 'Configurations merged.');
69
75
  logger.trace(TAG, config);
70
76
 
71
- await ConfigLoader.$validateSchema(config);
77
+ await this.$validateSchema(config);
72
78
 
73
- return config;
79
+ return <TConfig>config;
74
80
  }
75
81
 
76
- private static $getLocalConfig(path: string): IConfig {
82
+ /**
83
+ * @deprecated Instantiate ConfigLoader with the proper params
84
+ * @param path
85
+ * @returns
86
+ */
87
+ public static async load(path: string): Promise<IConfig> {
88
+ let loader: ConfigLoader = new ConfigLoader<IConfig>(getInstance());
89
+ return await loader.load(Path.resolve(path, 'bt-config.json'), Path.resolve('bt-local-config.json'));
90
+
91
+ // let logger: Logger = ConfigLoader.$getLogger();
92
+
93
+ // logger.trace(TAG, 'Configuration loaded.');
94
+
95
+ // let config: IConfig = {};
96
+
97
+ // let cPath: string = Path.resolve(path, 'bt-config.json');
98
+ // let lPath: string = Path.resolve(path, 'bt-local-config.json');
99
+
100
+ // let c: IConfig;
101
+ // let l: IConfig;
102
+ // let defaults: IConfig = this.$getDefaults();
103
+
104
+ // logger.trace(TAG, `Main Config Path:\t ${cPath}`);
105
+ // logger.trace(TAG, `Local Config Path:\t ${lPath}`);
106
+
107
+ // c = this.$getMainConfig(cPath);
108
+ // l = this.$getLocalConfig(lPath);
109
+
110
+ // if (l) {
111
+ // config = MergeChange.merge(defaults, c, l);
112
+ // }
113
+ // else {
114
+ // config = MergeChange.merge(defaults, c);
115
+ // }
116
+
117
+ // logger.trace(TAG, 'Reading command line arguments...');
118
+ // config = MergeChange.merge(config, ConfigLoader.$getCmdLineArgs());
119
+
120
+ // if (config.log.level === null) {
121
+ // config.log.level = defaults.log.level;
122
+ // }
123
+
124
+ // logger.trace(TAG, 'Configurations merged.');
125
+ // logger.trace(TAG, config);
126
+
127
+ // await ConfigLoader.$validateSchema(config);
128
+
129
+ // return config;
130
+ }
131
+
132
+ private $getLocalConfig(path: string): IConfig {
77
133
  let config: IConfig = null;
78
- this.$getLogger().trace(TAG, 'Loading optional local config.');
134
+ this.$logger.trace(TAG, 'Loading optional local config.');
79
135
  try {
80
136
  config = require(path);
81
- this.$getLogger().trace(TAG, 'Local config loaded.');
137
+ this.$logger.trace(TAG, 'Local config loaded.');
82
138
  }
83
139
  catch (ex) {
84
- this.$getLogger().trace(TAG, 'Local config could not be loaded.');
85
- this.$getLogger().trace(TAG, ex);
140
+ this.$logger.trace(TAG, 'Local config could not be loaded.');
141
+ this.$logger.trace(TAG, ex);
86
142
  }
87
143
  return config;
88
144
  }
89
145
 
90
- private static $getMainConfig(path: string): IConfig {
91
- this.$getLogger().trace(TAG, 'Loading main confing...');
146
+ private $getMainConfig(path: string): IConfig {
147
+ this.$logger.trace(TAG, 'Loading main confing...');
92
148
  let c: IConfig = null;
93
149
  try {
94
150
  c = require(path);
95
- this.$getLogger().trace(TAG, 'Main config loaded.');
151
+ this.$logger.trace(TAG, 'Main config loaded.');
96
152
  }
97
153
  catch (ex) {
98
154
  throw new MissingConfigError(path);
@@ -101,12 +157,12 @@ export class ConfigLoader {
101
157
  return c;
102
158
  }
103
159
 
104
- private static $getDefaults(): IConfig {
105
- this.$getLogger().trace(TAG, 'Loading configuration defaults.');
160
+ private $getDefaults(): IConfig {
161
+ this.$logger.trace(TAG, 'Loading configuration defaults.');
106
162
  return require(Path.resolve(__dirname, '../bt-config-defaults.json'));
107
163
  }
108
164
 
109
- private static async $validateSchema(config: IConfig): Promise<void> {
165
+ private async $validateSchema(config: IConfig): Promise<void> {
110
166
  let ajv: Ajv = new Ajv({
111
167
  allErrors: true
112
168
  });
@@ -215,22 +271,7 @@ export class ConfigLoader {
215
271
  }
216
272
  }
217
273
 
218
- private static $getCmdLineArgs(): any {
219
- let app: Application = getInstance();
220
- if (!app) {
221
- return {};
222
- }
223
-
224
- return app.getCmdLineArgs();
225
- }
226
-
227
- private static $getLogger(): Logger {
228
- let logger: Logger;
229
-
230
- if (!logger) {
231
- logger = new Logger('ConfigLoader');
232
- }
233
-
234
- return logger;
274
+ private $getCmdLineArgs(): IStormCLIArgs {
275
+ return this.$app.getCmdLineArgs();
235
276
  }
236
277
  }
@@ -37,7 +37,7 @@ export abstract class DatabaseConnection<TAPI> implements IDatabaseConnection {
37
37
  private $api: any;
38
38
  private $readOnly: boolean;
39
39
  private $timeout: number;
40
- private $lingerTimer: NodeJS.Timer;
40
+ private $lingerTimer: NodeJS.Timeout;
41
41
  private $instantiationStack: string;
42
42
  private $open: boolean;
43
43
 
package/src/Handler.ts CHANGED
@@ -66,7 +66,7 @@ export class Handler<
66
66
  > {
67
67
 
68
68
  private $app: TApplication;
69
- private $middlewares: Array<Middleware>;
69
+ private $middlewares: Middleware[];
70
70
 
71
71
  constructor(app: TApplication) {
72
72
  this.$app = app;
@@ -77,7 +77,7 @@ export class Handler<
77
77
  return this.$app;
78
78
  }
79
79
 
80
- protected _initMiddlewares(): Array<Middleware> {
80
+ protected _initMiddlewares(): Middleware[] {
81
81
  return [];
82
82
  }
83
83
 
package/src/IConfig.ts CHANGED
@@ -46,7 +46,7 @@ export interface IConfig {
46
46
  // Logging
47
47
  log?: {
48
48
  level?: LogLevel;
49
- filters?: Array<string>;
49
+ filters?: string[];
50
50
  cloudwatch?: ICloudwatchConfig;
51
51
  },
52
52
 
@@ -54,7 +54,7 @@ export interface IConfig {
54
54
  database?: {
55
55
  query_timeout?: number;
56
56
  main?: IDatabaseConfig<"MASTER">;
57
- replicationNodes?: Array<IDatabaseConfig>;
57
+ replicationNodes?: IDatabaseConfig[];
58
58
  };
59
59
 
60
60
 
@@ -23,11 +23,11 @@ import { ExitCode } from './ExitCode';
23
23
 
24
24
  interface IInvalidConfigErrorDetails<TConfig extends IConfig> {
25
25
  config: TConfig;
26
- errors: Array<ErrorObject>;
26
+ errors: ErrorObject[];
27
27
  }
28
28
 
29
29
  export class InvalidConfigError<TConfig extends IConfig> extends StormError<IInvalidConfigErrorDetails<TConfig>> {
30
- public constructor(config: TConfig, errors: Array<ErrorObject>) {
30
+ public constructor(config: TConfig, errors: ErrorObject[]) {
31
31
  super({
32
32
  config,
33
33
  errors
package/src/LineString.ts CHANGED
@@ -18,9 +18,9 @@ import {DatabaseCastObject} from './DatabaseCastObject';
18
18
  import {TCoordinate} from './TCoordinate';
19
19
 
20
20
  export class LineString extends DatabaseCastObject {
21
- private $coords: Array<TCoordinate>;
21
+ private $coords: TCoordinate[];
22
22
 
23
- public constructor(coordinates?: Array<TCoordinate>) {
23
+ public constructor(coordinates?: TCoordinate[]) {
24
24
  super();
25
25
 
26
26
  this.$coords = coordinates || [];
@@ -38,14 +38,13 @@ const TAG: string = 'MySQLConnection';
38
38
  const SQL_FORMATTING_OPTIONS: SQLFormatter.FormatOptions = {
39
39
  tabWidth: 4,
40
40
  keywordCase: 'upper',
41
+ identifierCase: 'preserve',
41
42
  useTabs: false,
42
43
  indentStyle: 'standard',
43
44
  logicalOperatorNewline: 'after',
44
- commaPosition: 'before',
45
45
  linesBetweenQueries: 1,
46
46
  denseOperators: false,
47
47
  newlineBeforeSemicolon: false,
48
- tabulateAlias: true,
49
48
  expressionWidth: 4
50
49
  };
51
50
 
package/src/Polygon.ts CHANGED
@@ -18,9 +18,9 @@ import {DatabaseCastObject} from './DatabaseCastObject';
18
18
  import {TCoordinate} from './TCoordinate';
19
19
 
20
20
  export class Polygon extends DatabaseCastObject {
21
- private $rings: Array<Array<TCoordinate>>;
21
+ private $rings: TCoordinate[][];
22
22
 
23
- public constructor(coordinates?: Array<Array<TCoordinate>>) {
23
+ public constructor(coordinates?: TCoordinate[][]) {
24
24
  super();
25
25
 
26
26
  this.$rings = coordinates || [];
@@ -30,7 +30,7 @@ export class Polygon extends DatabaseCastObject {
30
30
  let str: string = 'POLYGON(';
31
31
 
32
32
  for (let i: number = 0; i < this.$rings.length; i++) {
33
- let ring: Array<TCoordinate> = this.$rings[i];
33
+ let ring: TCoordinate[] = this.$rings[i];
34
34
  let strRing: string = '(';
35
35
 
36
36
  for (let y: number = 0; y < ring.length; y++) {
package/src/Request.ts CHANGED
@@ -72,7 +72,7 @@ export class Request<TBody = any, TAuthToken extends IAuthTokenData = IAuthToken
72
72
  }
73
73
 
74
74
  public getHeader(name: string): string {
75
- let value: string | Array<string> = this.$request.headers[name.toLowerCase()];
75
+ let value: string | string[] = this.$request.headers[name.toLowerCase()];
76
76
  if (typeof value === 'string') {
77
77
  return value;
78
78
  }
package/tsconfig.json CHANGED
@@ -10,8 +10,7 @@
10
10
  "noImplicitThis": true,
11
11
  "alwaysStrict": true,
12
12
  "noImplicitReturns": true,
13
- "moduleResolution": "node",
14
- "incremental": true
13
+ "moduleResolution": "node"
15
14
  },
16
15
  "exclude": [
17
16
  "./spec",
@@ -1,15 +0,0 @@
1
- {
2
- "extends" : "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "./spec",
5
- "declaration": false,
6
- "sourceMap": true
7
- },
8
- "include": [
9
- "**/*.ts"
10
- ],
11
- "exclude": [
12
- "lib",
13
- "node_modules"
14
- ]
15
- }