@breautek/storm 8.5.0 → 9.0.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.
Files changed (173) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/docs/assets/hierarchy.js +1 -1
  3. package/docs/assets/navigation.js +1 -1
  4. package/docs/assets/search.js +1 -1
  5. package/docs/assets/style.css +2 -9
  6. package/docs/classes/Application.html +37 -38
  7. package/docs/classes/ConfigLoader.html +3 -3
  8. package/docs/classes/Database.html +2 -2
  9. package/docs/classes/DatabaseCastObject.html +2 -2
  10. package/docs/classes/DatabaseConnection.html +24 -21
  11. package/docs/classes/DatabaseQueryError.html +30 -9
  12. package/docs/classes/DeadLockError.html +30 -9
  13. package/docs/classes/DiskSpaceError.html +29 -8
  14. package/docs/classes/DropTemporaryTableQuery.html +11 -8
  15. package/docs/classes/DuplicateEntryError.html +29 -8
  16. package/docs/classes/EntityNotFoundError.html +29 -8
  17. package/docs/classes/ExpiredTokenError.html +29 -8
  18. package/docs/classes/Handler.html +4 -4
  19. package/docs/classes/InternalError.html +29 -8
  20. package/docs/classes/InvalidCredentialsError.html +29 -8
  21. package/docs/classes/InvalidValueError.html +29 -8
  22. package/docs/classes/LineString.html +2 -2
  23. package/docs/classes/LockWaitTimeoutError.html +30 -9
  24. package/docs/classes/ManagedDatabaseConnection.html +11 -5
  25. package/docs/classes/Middleware.html +5 -4
  26. package/docs/classes/MissingConfigError.html +29 -8
  27. package/docs/classes/MissingParameterError.html +29 -8
  28. package/docs/classes/MySQLConnection.html +28 -23
  29. package/docs/classes/MySQLDatabase.html +2 -2
  30. package/docs/classes/NotImplementedError.html +29 -8
  31. package/docs/classes/Point.html +2 -2
  32. package/docs/classes/Polygon.html +2 -2
  33. package/docs/classes/Query.html +11 -8
  34. package/docs/classes/RawError.html +29 -8
  35. package/docs/classes/RawQuery.html +11 -8
  36. package/docs/classes/Request.html +2 -2
  37. package/docs/classes/Response.html +2 -2
  38. package/docs/classes/ResponseData.html +2 -2
  39. package/docs/classes/ServiceProvider.html +2 -2
  40. package/docs/classes/ServiceResponse.html +2 -2
  41. package/docs/classes/SetSessionVariableQuery.html +11 -8
  42. package/docs/classes/StormError.html +29 -8
  43. package/docs/classes/TemporaryTableQuery.html +11 -8
  44. package/docs/classes/TimeoutError.html +29 -8
  45. package/docs/classes/Token.html +2 -2
  46. package/docs/classes/TokenManager.html +2 -2
  47. package/docs/classes/Transaction.html +2 -2
  48. package/docs/classes/UnauthorizedAccessError.html +29 -8
  49. package/docs/enums/ErrorCode.html +2 -2
  50. package/docs/enums/ExitCode.html +2 -2
  51. package/docs/enums/HTTPMethod.html +2 -2
  52. package/docs/enums/IsolationLevel.html +2 -2
  53. package/docs/enums/JWTError.html +2 -2
  54. package/docs/enums/StatusCode.html +2 -2
  55. package/docs/enums/TransactionAccessLevel.html +4 -0
  56. package/docs/functions/getInstance.html +1 -1
  57. package/docs/hierarchy.html +1 -1
  58. package/docs/index.html +1 -1
  59. package/docs/interfaces/IAdditionalErrorDetails.html +1 -1
  60. package/docs/interfaces/ICloudwatchConfig.html +2 -2
  61. package/docs/interfaces/ICloudwatchCredentials.html +2 -2
  62. package/docs/interfaces/ICloudwatchStreamConfig.html +2 -2
  63. package/docs/interfaces/IConfig.html +2 -2
  64. package/docs/interfaces/IDatabaseConfig.html +2 -2
  65. package/docs/interfaces/IDatabaseConnection.html +11 -5
  66. package/docs/interfaces/IDatabasePosition.html +2 -2
  67. package/docs/interfaces/IErrorResponse.html +2 -2
  68. package/docs/interfaces/IFormData.html +2 -2
  69. package/docs/interfaces/IInsertQueryResult.html +2 -2
  70. package/docs/interfaces/IJWTVerifyOptions.html +2 -2
  71. package/docs/interfaces/IOKPacket.html +2 -2
  72. package/docs/interfaces/IParameterMap.html +1 -1
  73. package/docs/interfaces/IQueryable.html +2 -2
  74. package/docs/interfaces/IRequestResponse.html +2 -2
  75. package/docs/interfaces/ISetSessionVariableQueryInput.html +2 -2
  76. package/docs/interfaces/IStormCLIArgs.html +2 -2
  77. package/docs/interfaces/ITemporaryTableQueryInput.html +2 -2
  78. package/docs/interfaces/IUpdateQueryResult.html +2 -2
  79. package/docs/interfaces/formidable.FileJSON.html +1 -1
  80. package/docs/interfaces/formidable.Part.html +16 -16
  81. package/docs/types/IDeleteQueryResult.html +1 -1
  82. package/docs/types/IStoredProcedureResult.html +1 -1
  83. package/docs/types/TCoordinate.html +1 -1
  84. package/lib/Application.d.ts +2 -3
  85. package/lib/Application.js +22 -9
  86. package/lib/Application.js.map +1 -1
  87. package/lib/DatabaseConnection.d.ts +3 -0
  88. package/lib/DatabaseConnection.js.map +1 -1
  89. package/lib/Handler.d.ts +25 -28
  90. package/lib/Handler.js +18 -4
  91. package/lib/Handler.js.map +1 -1
  92. package/lib/IDatabaseConnection.d.ts +8 -1
  93. package/lib/IRequestResponse.d.ts +2 -2
  94. package/lib/IRequestResponse.js +1 -1
  95. package/lib/ManagedDatabaseConnection.d.ts +5 -1
  96. package/lib/ManagedDatabaseConnection.js +11 -2
  97. package/lib/ManagedDatabaseConnection.js.map +1 -1
  98. package/lib/Middleware.d.ts +8 -2
  99. package/lib/Middleware.js +9 -1
  100. package/lib/Middleware.js.map +1 -1
  101. package/lib/MySQLConnection.d.ts +14 -1
  102. package/lib/MySQLConnection.js +37 -6
  103. package/lib/MySQLConnection.js.map +1 -1
  104. package/lib/MySQLDatabase.js +8 -10
  105. package/lib/MySQLDatabase.js.map +1 -1
  106. package/lib/Query.d.ts +2 -0
  107. package/lib/Query.js +2 -0
  108. package/lib/Query.js.map +1 -1
  109. package/lib/Response.d.ts +8 -5
  110. package/lib/Response.js +4 -3
  111. package/lib/Response.js.map +1 -1
  112. package/lib/ServiceProvider.d.ts +6 -6
  113. package/lib/ServiceProvider.js +8 -5
  114. package/lib/ServiceProvider.js.map +1 -1
  115. package/lib/TokenManager.d.ts +2 -1
  116. package/lib/TokenManager.js.map +1 -1
  117. package/lib/Transaction.d.ts +3 -1
  118. package/lib/Transaction.js +4 -2
  119. package/lib/Transaction.js.map +1 -1
  120. package/lib/TransactionAccessLevel.d.ts +7 -0
  121. package/lib/{IHandler.js → TransactionAccessLevel.js} +11 -2
  122. package/lib/TransactionAccessLevel.js.map +1 -0
  123. package/lib/api.d.ts +2 -5
  124. package/lib/api.js +4 -6
  125. package/lib/api.js.map +1 -1
  126. package/lib/private/ConnectionReplicationWaiter.js +1 -1
  127. package/lib/private/ConnectionReplicationWaiter.js.map +1 -1
  128. package/lib/private/GetProcessList.d.ts +15 -0
  129. package/lib/private/GetProcessList.js +11 -0
  130. package/lib/private/GetProcessList.js.map +1 -0
  131. package/lib/private/StartTransactionQuery.d.ts +8 -1
  132. package/lib/private/StartTransactionQuery.js +11 -2
  133. package/lib/private/StartTransactionQuery.js.map +1 -1
  134. package/package.json +17 -16
  135. package/src/Application.ts +23 -10
  136. package/src/DatabaseConnection.ts +6 -0
  137. package/src/Handler.ts +41 -46
  138. package/src/IDatabaseConnection.ts +9 -1
  139. package/src/IRequestResponse.ts +3 -3
  140. package/src/ManagedDatabaseConnection.ts +15 -2
  141. package/src/Middleware.ts +14 -2
  142. package/src/MySQLConnection.ts +43 -9
  143. package/src/MySQLDatabase.ts +8 -10
  144. package/src/Query.ts +2 -0
  145. package/src/Response.ts +20 -7
  146. package/src/ServiceProvider.ts +17 -13
  147. package/src/TokenManager.ts +2 -1
  148. package/src/Transaction.ts +5 -2
  149. package/src/{IServiceHeaders.ts → TransactionAccessLevel.ts} +7 -3
  150. package/src/api.ts +2 -5
  151. package/src/private/ConnectionReplicationWaiter.ts +1 -1
  152. package/src/private/GetProcessList.ts +20 -0
  153. package/src/private/StartTransactionQuery.ts +22 -4
  154. package/docs/classes/BackendAuthenticationMiddleware.html +0 -8
  155. package/docs/classes/CORSMiddleware.html +0 -14
  156. package/docs/interfaces/IHandler.html +0 -2
  157. package/docs/interfaces/IServiceHeaders.html +0 -1
  158. package/docs/types/IHandlerError.html +0 -5
  159. package/docs/types/IHandlerResponse.html +0 -11
  160. package/lib/BackendAuthenticationMiddleware.d.ts +0 -18
  161. package/lib/BackendAuthenticationMiddleware.js +0 -67
  162. package/lib/BackendAuthenticationMiddleware.js.map +0 -1
  163. package/lib/CORSMiddleware.d.ts +0 -28
  164. package/lib/CORSMiddleware.js +0 -81
  165. package/lib/CORSMiddleware.js.map +0 -1
  166. package/lib/IHandler.d.ts +0 -5
  167. package/lib/IHandler.js.map +0 -1
  168. package/lib/IServiceHeaders.d.ts +0 -3
  169. package/lib/IServiceHeaders.js +0 -18
  170. package/lib/IServiceHeaders.js.map +0 -1
  171. package/src/BackendAuthenticationMiddleware.ts +0 -75
  172. package/src/CORSMiddleware.ts +0 -90
  173. package/src/IHandler.ts +0 -22
@@ -19,7 +19,6 @@ import {DatabaseQueryError} from './DatabaseQueryError';
19
19
  import {getInstance} from './instance';
20
20
  import * as MySQL from 'mysql';
21
21
  import {Readable} from 'stream';
22
- import {Query} from './Query';
23
22
  import { StartTransactionQuery } from './private/StartTransactionQuery';
24
23
  import { CommitQuery } from './private/CommitQuery';
25
24
  import { RollbackQuery } from './private/RollbackQuery';
@@ -37,6 +36,8 @@ import { GetSlavePositionQuery } from './private/GetSlavePositionQuery';
37
36
  import { GetMasterPositionQuery } from './private/GetMasterPositionQuery';
38
37
  import { IQueryable } from './IQueryable';
39
38
  import { queryFormatter } from './mysql/queryFormatter';
39
+ import { TransactionAccessLevel } from './TransactionAccessLevel';
40
+ import { GetProcessList, IGetProcessListOutput } from './private/GetProcessList';
40
41
 
41
42
  const DEFAULT_HIGH_WATERMARK: number = 512; // in number of result objects
42
43
  const TAG: string = 'MySQLConnection';
@@ -56,18 +57,19 @@ const SQL_FORMATTING_OPTIONS: SQLFormatter.FormatOptions = {
56
57
  functionCase: 'upper'
57
58
  };
58
59
 
59
- let startTransactionQuery: Query = new StartTransactionQuery();
60
- let commitQuery: Query = new CommitQuery();
61
- let rollbackQuery: Query = new RollbackQuery();
60
+ let commitQuery: CommitQuery = new CommitQuery();
61
+ let rollbackQuery: RollbackQuery = new RollbackQuery();
62
62
 
63
63
  export class MySQLConnection extends DatabaseConnection<MySQL.PoolConnection> {
64
64
  private $transaction: boolean;
65
65
  private $opened: boolean;
66
+ private $hasReplicationEnabled: boolean;
66
67
  private $isMasterConnection: boolean;
67
68
 
68
69
  public constructor(connection: MySQL.PoolConnection, instantiationStack: string, isReadOnly: boolean = true) {
69
70
  super(connection, isReadOnly, instantiationStack);
70
71
 
72
+ this.$hasReplicationEnabled = false;
71
73
  this.$opened = true;
72
74
  this.$transaction = false;
73
75
  this.$isMasterConnection = null;
@@ -92,17 +94,47 @@ export class MySQLConnection extends DatabaseConnection<MySQL.PoolConnection> {
92
94
  */
93
95
  public async __internal_init(): Promise<void> {
94
96
  let result = await new GetSlavePositionQuery().execute(this);
95
- this.$isMasterConnection = result === null;
97
+ if (result !== null) {
98
+ this.$hasReplicationEnabled = true;
99
+ this.$isMasterConnection = false;
100
+ }
101
+ else {
102
+ this.$isMasterConnection = true;
103
+ let processList: IGetProcessListOutput[] = await new GetProcessList().execute(this);
104
+
105
+ for (let i: number = 0; i < processList.length; i++) {
106
+ let p: IGetProcessListOutput = processList[i];
107
+
108
+ if (p.Command === 'Binlog Dump') {
109
+ this.$hasReplicationEnabled = true;
110
+ break;
111
+ }
112
+ }
113
+ }
96
114
  }
97
115
 
98
116
  public override formatQuery(query: IQueryable<any>): string {
99
117
  return this.getAPI().config.queryFormat(query.getQuery(this), query.getParametersForQuery());
100
118
  }
101
119
 
120
+ /**
121
+ * Returns true if this server is the source.
122
+ * Will also return true if there is no replication detected.
123
+ */
102
124
  public isMaster(): boolean {
103
125
  return this.$isMasterConnection;
104
126
  }
105
127
 
128
+ /**
129
+ * Returns true if this server is part of a replication cluster.
130
+ */
131
+ public hasReplicationEnabled(): boolean {
132
+ return this.$hasReplicationEnabled;
133
+ }
134
+
135
+ /**
136
+ * Returns true if this server is a replication server.
137
+ */
106
138
  public isReplication(): boolean {
107
139
  return !this.isMaster();
108
140
  }
@@ -196,9 +228,9 @@ export class MySQLConnection extends DatabaseConnection<MySQL.PoolConnection> {
196
228
  return queryObject.stream(streamOptions);
197
229
  }
198
230
 
199
- public override async startTransaction(isolationLevel?: IsolationLevel): Promise<void> {
200
- if (this.isReadOnly()) {
201
- throw new Error('A readonly connection cannot start a transaction.')
231
+ public override async startTransaction(isolationLevel?: IsolationLevel, accessLevel: TransactionAccessLevel = TransactionAccessLevel.RW): Promise<void> {
232
+ if (this.isReadOnly() && accessLevel === TransactionAccessLevel.RW) {
233
+ throw new Error('A readonly connection cannot start a read/write transaction.')
202
234
  }
203
235
 
204
236
  if (this.isTransaction()) {
@@ -211,7 +243,9 @@ export class MySQLConnection extends DatabaseConnection<MySQL.PoolConnection> {
211
243
  if (isolationLevel) {
212
244
  await new SetIsolationLevelQuery(isolationLevel).execute(this);
213
245
  }
214
- await startTransactionQuery.execute(this);
246
+ await new StartTransactionQuery({
247
+ accessLevel: accessLevel
248
+ }).execute(this);
215
249
  }
216
250
  catch (ex) {
217
251
  this.$transaction = false;
@@ -89,21 +89,19 @@ export class MySQLDatabase extends Database<MySQL.PoolConfig, MySQL.PoolConnecti
89
89
  let conn: MySQLConnection = await this.$getConnectionFromPool(query, requireWriteAccess, instantationStack);
90
90
  await conn.__internal_init();
91
91
 
92
- if (conn.isReplication()) {
92
+ if (conn.hasReplicationEnabled() && conn.isReplication() && position && position.page && position.position) {
93
93
  // master connections will not wait on database positions
94
94
  // they are guarenteed to be at the tip.
95
95
  // readonly, or otherwise known as replication connections
96
96
  // may have replication lag. If we have a desired position target,
97
97
  // then await for the connection to catch up to that target.
98
- if (position && position.page && position.position) {
99
- let waiter: ConnectionReplicationWaiter = new ConnectionReplicationWaiter(conn);
100
- try {
101
- await waiter.wait(position);
102
- }
103
- catch (ex) {
104
- conn.close(true);
105
- throw ex;
106
- }
98
+ let waiter: ConnectionReplicationWaiter = new ConnectionReplicationWaiter(conn);
99
+ try {
100
+ await waiter.wait(position);
101
+ }
102
+ catch (ex) {
103
+ conn.close(true);
104
+ throw ex;
107
105
  }
108
106
  }
109
107
 
package/src/Query.ts CHANGED
@@ -76,6 +76,8 @@ export abstract class Query<TQueryParameters = any, TQueryResultSet = any, TQuer
76
76
  /**
77
77
  * Override to augment/manipulate the returned result set.
78
78
  *
79
+ * @deprecated - Streaming queries does not support post processing, creating a confusing API
80
+ *
79
81
  * @param connection The connection object used for this query execution. Useful if further queries are required.
80
82
  * @param resultset The original result set
81
83
  */
package/src/Response.ts CHANGED
@@ -19,23 +19,35 @@ import {ResponseData} from './ResponseData';
19
19
  import {StormError, IErrorResponse} from './StormError';
20
20
  import * as express from 'express';
21
21
  import { InternalError } from './InternalError';
22
- import { getInstance } from './instance';
23
22
  import { Stream } from 'stream';
23
+ import { Application } from './Application';
24
24
 
25
25
  const TAG: string = 'Response';
26
26
 
27
- export type SendableData = ResponseData | Error | IErrorResponse | Buffer | any;
27
+ export type SendableData =
28
+ ResponseData<SendableData> |
29
+ Error |
30
+ IErrorResponse |
31
+ Buffer |
32
+ string |
33
+ number |
34
+ void |
35
+ ReadableStream |
36
+ Stream.Readable
37
+ ;
28
38
 
29
39
  export interface IHeaderKeyValuePair {
30
40
  [key: string]: string;
31
41
  }
32
42
 
33
- export class Response<TResponse = SendableData, TErrorResponse = Error | IErrorResponse | string> {
43
+ export class Response<TResponse extends SendableData = SendableData, TErrorResponse extends SendableData = SendableData> {
44
+ private $app: Application;
34
45
  private $response: express.Response;
35
46
  private $created: Date;
36
47
  private $requestURL: string;
37
48
 
38
- public constructor(response: express.Response, requestURL: string) {
49
+ public constructor(app: Application, response: express.Response, requestURL: string) {
50
+ this.$app = app;
39
51
  this.$response = response;
40
52
  this.$created = new Date();
41
53
  this.$requestURL = requestURL;
@@ -54,7 +66,7 @@ export class Response<TResponse = SendableData, TErrorResponse = Error | IErrorR
54
66
  this.$response.redirect(url);
55
67
  }
56
68
 
57
- private $send(data?: TResponse | TErrorResponse | StormError | IErrorResponse | Buffer, statusOverride?: StatusCode): void {
69
+ private $send(data?: SendableData, statusOverride?: StatusCode): void {
58
70
  if (data === null || data === undefined) {
59
71
  this.setStatus(statusOverride || StatusCode.OK_NO_CONTENT);
60
72
  this.$response.send()
@@ -92,9 +104,10 @@ export class Response<TResponse = SendableData, TErrorResponse = Error | IErrorR
92
104
  }
93
105
  }
94
106
 
95
- public send(data?: TResponse | TErrorResponse | StormError | IErrorResponse | Buffer): void {
107
+ // public send(data?: TResponse | TErrorResponse | StormError | IErrorResponse | Buffer): void {
108
+ public send(data?: SendableData): void {
96
109
  this.$send(data);
97
- getInstance().getLogger().info(TAG, `API ${this.$requestURL} (${this.getStatus()}) responded in ${new Date().getTime() - this.$created.getTime()}ms`);
110
+ this.$app.getLogger().info(TAG, `API ${this.$requestURL} (${this.getStatus()}) responded in ${new Date().getTime() - this.$created.getTime()}ms`);
98
111
  }
99
112
 
100
113
  public pipe(stream: NodeJS.ReadableStream): void {
@@ -15,10 +15,10 @@
15
15
  */
16
16
 
17
17
  import {Application} from './Application';
18
- import {IServiceHeaders} from './IServiceHeaders';
19
18
  import {HTTPMethod} from './HTTPMethod';
20
19
  import {ServiceResponse} from './ServiceResponse';
21
20
  import * as http from 'http';
21
+ import { OutgoingHttpHeaders } from 'http2';
22
22
 
23
23
  const TAG: string = 'ServiceProvider';
24
24
  const NO_DATA: string = `|${0x0}|`;
@@ -78,8 +78,19 @@ export abstract class ServiceProvider {
78
78
  return `/api/${this._getBase()}/${this.getVersion()}/${url}${this.urlSuffix()}${queryString}`;
79
79
  }
80
80
 
81
- public request(method: HTTPMethod, url: string, accessToken: string, data: any, headers?: IServiceHeaders, additionalOptions?: any): Promise<ServiceResponse> {
81
+ public request(method: HTTPMethod, url: string, accessToken: string, data: any, headers?: OutgoingHttpHeaders, additionalOptions?: any): Promise<ServiceResponse> {
82
82
  return new Promise<ServiceResponse>((resolve, reject) => {
83
+ if (!headers) {
84
+ headers = {};
85
+ }
86
+
87
+ headers[this.$app.getConfig().authentication_header] = accessToken;
88
+ headers[this.$app.getConfig().backend_authentication_header] = this.$getSecret();
89
+
90
+ if (!headers['content-type']) {
91
+ headers['content-type'] = 'application/json';
92
+ }
93
+
83
94
  let httpOpts: http.RequestOptions = {
84
95
  port: this._getPort(),
85
96
  hostname: `${this._getDomain()}`,
@@ -88,13 +99,6 @@ export abstract class ServiceProvider {
88
99
  headers: headers || {}
89
100
  };
90
101
 
91
- httpOpts.headers[this.$app.getConfig().authentication_header] = accessToken;
92
- httpOpts.headers[this.$app.getConfig().backend_authentication_header] = this.$getSecret();
93
-
94
- if (!httpOpts.headers['Content-Type']) {
95
- httpOpts.headers['Content-Type'] = 'application/json';
96
- }
97
-
98
102
  this.$app.getLogger().trace(TAG, `ServiceProvider Request`);
99
103
  this.$app.getLogger().trace(TAG, `METHOD: ${httpOpts.method}`);
100
104
  this.$app.getLogger().trace(TAG, `HOSTNAME: ${httpOpts.hostname}`);
@@ -137,19 +141,19 @@ export abstract class ServiceProvider {
137
141
  request.end();
138
142
  }
139
143
 
140
- public get(url: string, accessToken: string, data?: any, headers?: IServiceHeaders, additionalOptions?: any): Promise<ServiceResponse> {
144
+ public get(url: string, accessToken: string, data?: any, headers?: OutgoingHttpHeaders, additionalOptions?: any): Promise<ServiceResponse> {
141
145
  return this.request(HTTPMethod.GET, this._createURL(url, data), accessToken, NO_DATA, headers, additionalOptions);
142
146
  }
143
147
 
144
- public post(url: string, accessToken: string, data?: any, headers?: IServiceHeaders, additionalOptions?: any): Promise<ServiceResponse> {
148
+ public post(url: string, accessToken: string, data?: any, headers?: OutgoingHttpHeaders, additionalOptions?: any): Promise<ServiceResponse> {
145
149
  return this.request(HTTPMethod.POST, this._createURL(url), accessToken, data, headers, additionalOptions);
146
150
  }
147
151
 
148
- public put(url: string, accessToken: string, data?: any, headers?: IServiceHeaders, additionalOptions?: any): Promise<ServiceResponse> {
152
+ public put(url: string, accessToken: string, data?: any, headers?: OutgoingHttpHeaders, additionalOptions?: any): Promise<ServiceResponse> {
149
153
  return this.request(HTTPMethod.PUT, this._createURL(url), accessToken, data, headers, additionalOptions);
150
154
  }
151
155
 
152
- public delete(url: string, accessToken: string, data?: any, headers?: IServiceHeaders, additionalOptions?: any): Promise<ServiceResponse> {
156
+ public delete(url: string, accessToken: string, data?: any, headers?: OutgoingHttpHeaders, additionalOptions?: any): Promise<ServiceResponse> {
153
157
  return this.request(HTTPMethod.DELETE, this._createURL(url), accessToken, data, headers, additionalOptions);
154
158
  }
155
159
  }
@@ -20,6 +20,7 @@ import {IJWTVerifyOptions} from './IJWTVerifyOptions';
20
20
  import {JWTVerifyOptionsParser} from './JWTVerifyOptionsParser';
21
21
  import {randomBytes} from 'crypto';
22
22
  import { IAuthTokenData } from './IAuthTokenData';
23
+ import { StringValue } from 'ms';
23
24
 
24
25
  // const TAG: string = 'TokenManager';
25
26
 
@@ -30,7 +31,7 @@ export class TokenManager<TAuthToken extends IAuthTokenData = IAuthTokenData> {
30
31
  this.$secret = secret;
31
32
  }
32
33
 
33
- public sign(payload: {[key: string]: any}, expiresIn: string | number): Promise<Token> {
34
+ public sign(payload: {[key: string]: any}, expiresIn: StringValue | number): Promise<Token> {
34
35
  return new Promise<Token>((resolve, reject) => {
35
36
  randomBytes(64, (err: Error, buffer: Buffer) => {
36
37
  if (err) {
@@ -22,6 +22,7 @@ import { InternalError } from './InternalError';
22
22
  import { DeadLockError } from './DeadLockError';
23
23
  import { InvalidValueError } from './InvalidValueError';
24
24
  import { LockWaitTimeoutError } from './LockWaitTimeoutError';
25
+ import { TransactionAccessLevel } from './TransactionAccessLevel';
25
26
 
26
27
  const TAG: string = 'Transaction';
27
28
 
@@ -43,8 +44,9 @@ export class Transaction implements IQueryable<void> {
43
44
  private $application: Application;
44
45
  private $isolationLevel: IsolationLevel;
45
46
  private $executor: ITransactionExecutor;
47
+ private $accessLevel: TransactionAccessLevel;
46
48
 
47
- public constructor(app: Application, executor: ITransactionExecutor, retryLimit: number = Infinity, isolationLevel: IsolationLevel = IsolationLevel.REPEATABLE_READ) {
49
+ public constructor(app: Application, executor: ITransactionExecutor, retryLimit: number = Infinity, isolationLevel: IsolationLevel = IsolationLevel.REPEATABLE_READ, accessLevel: TransactionAccessLevel = TransactionAccessLevel.RW) {
48
50
  this.$application = app;
49
51
  this.$executor = executor;
50
52
 
@@ -57,6 +59,7 @@ export class Transaction implements IQueryable<void> {
57
59
 
58
60
  this.$retryLimit = retryLimit;
59
61
  this.$isolationLevel = isolationLevel;
62
+ this.$accessLevel = accessLevel;
60
63
  }
61
64
 
62
65
  public async onPreQuery(connection: IDatabaseConnection): Promise<void> {}
@@ -81,7 +84,7 @@ export class Transaction implements IQueryable<void> {
81
84
  do {
82
85
  attemptCount++;
83
86
  this.$application.getLogger().info(TAG, `Starting transaction attempt ${attemptCount} of ${this.$retryLimit === Infinity ? 'Infinity' : this.$retryLimit.toString()}`);
84
- await connection.startTransaction(this.$isolationLevel);
87
+ await connection.startTransaction(this.$isolationLevel, this.$accessLevel);
85
88
  try {
86
89
  await this.$executor(connection);
87
90
  await connection.commit();
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2017-2021 Norman Breau
2
+ Copyright 2017-2025 Norman Breau
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,6 +14,10 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
- export interface IServiceHeaders {
18
- [key: string]: string;
17
+ /**
18
+ * @since 8.6.0
19
+ */
20
+ export enum TransactionAccessLevel {
21
+ RW,
22
+ RO
19
23
  }
package/src/api.ts CHANGED
@@ -42,6 +42,7 @@ export {IsolationLevel} from './IsolationLevel';
42
42
  export {Transaction} from './Transaction';
43
43
  export {IOKPacket} from './IOKPacket';
44
44
  export {IStoredProcedureResult} from './IStoredProcedureResult';
45
+ export {TransactionAccessLevel} from './TransactionAccessLevel';
45
46
 
46
47
  // Errors
47
48
  export {ErrorCode} from './ErrorCode';
@@ -74,17 +75,14 @@ export {Middleware} from './Middleware';
74
75
  export {Request, IParameterMap} from './Request';
75
76
  export {Response} from './Response';
76
77
  export {ResponseData} from './ResponseData';
77
- export {Handler, IHandlerError, IHandlerResponse} from './Handler';
78
- export {CORSMiddleware} from './CORSMiddleware';
78
+ export {Handler} from './Handler';
79
79
  export {ServiceProvider} from './ServiceProvider';
80
80
  export {HTTPMethod} from './HTTPMethod';
81
81
  export {ServiceResponse} from './ServiceResponse';
82
- export {BackendAuthenticationMiddleware} from './BackendAuthenticationMiddleware';
83
82
 
84
83
  // Interfaces
85
84
  export {IDatabaseConfig} from './IDatabaseConfig';
86
85
  export {IJWTVerifyOptions} from './IJWTVerifyOptions';
87
- export {IHandler} from './IHandler';
88
86
  export {IRequestResponse} from './IRequestResponse';
89
87
  export {
90
88
  IConfig,
@@ -94,7 +92,6 @@ export {
94
92
  } from './IConfig';
95
93
  export {IFormData} from './IFormData';
96
94
  export {IDatabaseConnection} from './IDatabaseConnection';
97
- export {IServiceHeaders} from './IServiceHeaders';
98
95
  export {IAuthTokenData} from './IAuthTokenData';
99
96
  export {IQueryable} from './IQueryable';
100
97
  export {IDatabasePosition} from './IDatabasePosition';
@@ -55,7 +55,7 @@ export class ConnectionReplicationWaiter {
55
55
  }
56
56
 
57
57
  public async wait(target: IDatabasePosition, timeout: number = ConnectionReplicationWaiter.DEFAULT_TIMEOUT): Promise<void> {
58
- if (!this.$conn.isReadOnly()) {
58
+ if (this.$conn.isMaster()) {
59
59
  return;
60
60
  }
61
61
 
@@ -0,0 +1,20 @@
1
+
2
+ import { IDatabaseConnection } from '../IDatabaseConnection';
3
+ import {Query} from '../Query';
4
+
5
+ export interface IGetProcessListOutput {
6
+ Id: number;
7
+ User: string;
8
+ Host: string;
9
+ db: string;
10
+ Command: string;
11
+ Time: number;
12
+ State: string;
13
+ Info: string;
14
+ }
15
+
16
+ export class GetProcessList extends Query<void, IGetProcessListOutput[]> {
17
+ protected override _getQuery(connection: IDatabaseConnection): string {
18
+ return 'SHOW PROCESSLIST';
19
+ }
20
+ }
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2017-2021 Norman Breau
2
+ Copyright 2017-2025 Norman Breau
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -15,9 +15,27 @@
15
15
  */
16
16
 
17
17
  import {Query} from '../Query';
18
+ import { TransactionAccessLevel } from '../TransactionAccessLevel';
18
19
 
19
- export class StartTransactionQuery extends Query<void, void> {
20
- protected _getQuery(): string {
21
- return 'START TRANSACTION';
20
+ /**
21
+ * @since 8.6.0
22
+ */
23
+ export interface IStartTransactionQueryInput {
24
+ accessLevel?: TransactionAccessLevel;
25
+ }
26
+
27
+ export class StartTransactionQuery extends Query<IStartTransactionQueryInput, void> {
28
+ protected override _getQuery(): string {
29
+ let params: IStartTransactionQueryInput = this.getParameters();
30
+
31
+ let accessString: string;
32
+ if (params?.accessLevel === TransactionAccessLevel.RO) {
33
+ accessString = 'READ ONLY';
34
+ }
35
+ else {
36
+ accessString = 'READ WRITE';
37
+ }
38
+
39
+ return `START TRANSACTION ${accessString}`;
22
40
  }
23
41
  }
@@ -1,8 +0,0 @@
1
- <!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>BackendAuthenticationMiddleware | @breautek/storm</title><meta name="description" content="Documentation for @breautek/storm"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script><script async src="../assets/hierarchy.js" id="tsd-hierarchy-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@breautek/storm</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="" aria-current="page">BackendAuthenticationMiddleware</a></li></ul><h1>Class BackendAuthenticationMiddleware</h1></div><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><p>A base authentication strategy that handles 90% of the authentication process.
2
- This will verify that the token hasn't been manipulated or tainted.
3
- The authenticate API must be implemented by subclasses to further validate the token data
4
- for their specific use cases.</p>
5
- </div><div class="tsd-comment tsd-typography"></div></section><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/breautek/storm/blob/d1f7b6e5c47e4e6ee4db0119405b3963f9309836/src/BackendAuthenticationMiddleware.ts#L32">src/BackendAuthenticationMiddleware.ts:32</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h5 class="tsd-index-heading uppercase">Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Constructors</h3><div class="tsd-index-list"><a href="#constructor" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Constructor"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a>
6
- </div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Methods</h3><div class="tsd-index-list"><a href="#execute" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>execute</span></a>
7
- </div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h2>Constructors</h2></summary><section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="constructor"><span>constructor</span><a href="#constructor" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="constructorbackendauthenticationmiddleware"><span class="tsd-signature-keyword">new</span> <span class="tsd-kind-constructor-signature">BackendAuthenticationMiddleware</span><span class="tsd-signature-symbol">()</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">BackendAuthenticationMiddleware</a><a href="#constructorbackendauthenticationmiddleware" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><h4 class="tsd-returns-title">Returns <a href="" class="tsd-signature-type tsd-kind-class">BackendAuthenticationMiddleware</a></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/breautek/storm/blob/d1f7b6e5c47e4e6ee4db0119405b3963f9309836/src/BackendAuthenticationMiddleware.ts#L35">src/BackendAuthenticationMiddleware.ts:35</a></li></ul></aside></div></li></ul></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Methods"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h2>Methods</h2></summary><section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="execute"><span>execute</span><a href="#execute" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="execute-1"><span class="tsd-kind-call-signature">execute</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">request</span><span class="tsd-signature-symbol">:</span> <a href="Request.html" class="tsd-signature-type tsd-kind-class">Request</a><span class="tsd-signature-symbol">,</span> <span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span><a href="#execute-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">request</span>: <a href="Request.html" class="tsd-signature-type tsd-kind-class">Request</a></span><div class="tsd-comment tsd-typography"></div></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">options</span>: <span class="tsd-signature-type">any</span></span><div class="tsd-comment tsd-typography"><p>Arbituary object containing any relevant information used for authentication.</p>
8
- </div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/breautek/storm/blob/d1f7b6e5c47e4e6ee4db0119405b3963f9309836/src/BackendAuthenticationMiddleware.ts#L45">src/BackendAuthenticationMiddleware.ts:45</a></li></ul></aside></div></li></ul></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Constructors</summary><div><a href="#constructor"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Constructor"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Methods"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Methods</summary><div><a href="#execute"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>execute</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../index.html">@breautek/storm</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>CORSMiddleware | @breautek/storm</title><meta name="description" content="Documentation for @breautek/storm"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script><script async src="../assets/hierarchy.js" id="tsd-hierarchy-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@breautek/storm</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="" aria-current="page">CORSMiddleware</a></li></ul><h1>Class CORSMiddleware</h1></div><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><p>CORSMiddleware is used to enable CORS on APIs.
2
- It will automatically add the necessary headers necessary to
3
- communicate with CORS enabled clients.</p>
4
- </div><div class="tsd-comment tsd-typography"></div></section><section class="tsd-panel tsd-hierarchy" data-refl="1723"><h4>Hierarchy (<a href="../hierarchy.html#CORSMiddleware">View Summary</a>)</h4><ul class="tsd-hierarchy"><li class="tsd-hierarchy-item"><a href="Middleware.html" class="tsd-signature-type tsd-kind-class">Middleware</a><ul class="tsd-hierarchy"><li class="tsd-hierarchy-item"><span class="tsd-hierarchy-target">CORSMiddleware</span></li></ul></li></ul></section><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/breautek/storm/blob/d1f7b6e5c47e4e6ee4db0119405b3963f9309836/src/CORSMiddleware.ts#L28">src/CORSMiddleware.ts:28</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h5 class="tsd-index-heading uppercase">Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Constructors</h3><div class="tsd-index-list"><a href="#constructor" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Constructor"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a>
5
- </div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Methods</h3><div class="tsd-index-list"><a href="#_execute" class="tsd-index-link tsd-is-protected"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>_<wbr/>execute</span></a>
6
- <a href="#execute" class="tsd-index-link tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>execute</span></a>
7
- <a href="#getdefaultallowedheaders" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>get<wbr/>Default<wbr/>Allowed<wbr/>Headers</span></a>
8
- <a href="#getdefaultallowedmethods" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>get<wbr/>Default<wbr/>Allowed<wbr/>Methods</span></a>
9
- <a href="#getdefaultallowedorigin" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>get<wbr/>Default<wbr/>Allowed<wbr/>Origin</span></a>
10
- </div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h2>Constructors</h2></summary><section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="constructor"><span>constructor</span><a href="#constructor" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="constructorcorsmiddleware"><span class="tsd-signature-keyword">new</span> <span class="tsd-kind-constructor-signature">CORSMiddleware</span><span class="tsd-signature-symbol">(</span><br/>    <span class="tsd-kind-parameter">allowedOrigin</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span><br/>    <span class="tsd-kind-parameter">allowedHeaders</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span><br/>    <span class="tsd-kind-parameter">allowedMethods</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">CORSMiddleware</a><a href="#constructorcorsmiddleware" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">allowedOrigin</span>: <span class="tsd-signature-type">string</span></span><div class="tsd-comment tsd-typography"><p>The allowed origin. By default it will use the request origin.</p>
11
- </div><div class="tsd-comment tsd-typography"></div></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">allowedHeaders</span>: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></span><div class="tsd-comment tsd-typography"><p>Array of allowed headers.</p>
12
- </div><div class="tsd-comment tsd-typography"></div></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">allowedMethods</span>: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></span><div class="tsd-comment tsd-typography"><p>Array of allowed HTTP methods.</p>
13
- </div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="" class="tsd-signature-type tsd-kind-class">CORSMiddleware</a></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><p>Overrides <a href="Middleware.html">Middleware</a>.<a href="Middleware.html#constructor">constructor</a></p><ul><li>Defined in <a href="https://github.com/breautek/storm/blob/d1f7b6e5c47e4e6ee4db0119405b3963f9309836/src/CORSMiddleware.ts#L39">src/CORSMiddleware.ts:39</a></li></ul></aside></div></li></ul></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Methods"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h2>Methods</h2></summary><section><section class="tsd-panel tsd-member tsd-is-protected"><h3 class="tsd-anchor-link" id="_execute"><code class="tsd-tag">Protected</code><span>_<wbr/>execute</span><a href="#_execute" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures tsd-is-protected"><li class=""><div class="tsd-signature tsd-anchor-link" id="_execute-1"><span class="tsd-kind-call-signature">_execute</span><span class="tsd-signature-symbol">(</span><br/>    <span class="tsd-kind-parameter">request</span><span class="tsd-signature-symbol">:</span> <a href="Request.html" class="tsd-signature-type tsd-kind-class">Request</a><span class="tsd-signature-symbol">,</span><br/>    <span class="tsd-kind-parameter">response</span><span class="tsd-signature-symbol">:</span> <a href="Response.html" class="tsd-signature-type tsd-kind-class">Response</a><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/IRequestResponse.html" class="tsd-signature-type tsd-kind-interface">IRequestResponse</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span><a href="#_execute-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">request</span>: <a href="Request.html" class="tsd-signature-type tsd-kind-class">Request</a></span></li><li><span><span class="tsd-kind-parameter">response</span>: <a href="Response.html" class="tsd-signature-type tsd-kind-class">Response</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/IRequestResponse.html" class="tsd-signature-type tsd-kind-interface">IRequestResponse</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span></h4><aside class="tsd-sources"><p>Overrides <a href="Middleware.html">Middleware</a>.<a href="Middleware.html#_execute">_execute</a></p><ul><li>Defined in <a href="https://github.com/breautek/storm/blob/d1f7b6e5c47e4e6ee4db0119405b3963f9309836/src/CORSMiddleware.ts#L75">src/CORSMiddleware.ts:75</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member tsd-is-inherited"><h3 class="tsd-anchor-link" id="execute"><span>execute</span><a href="#execute" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures tsd-is-inherited"><li class="tsd-is-inherited"><div class="tsd-signature tsd-anchor-link" id="execute-1"><span class="tsd-kind-call-signature">execute</span><span class="tsd-signature-symbol">(</span><br/>    <span class="tsd-kind-parameter">request</span><span class="tsd-signature-symbol">:</span> <a href="Request.html" class="tsd-signature-type tsd-kind-class">Request</a><span class="tsd-signature-symbol">,</span><br/>    <span class="tsd-kind-parameter">response</span><span class="tsd-signature-symbol">:</span> <a href="Response.html" class="tsd-signature-type tsd-kind-class">Response</a><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/IRequestResponse.html" class="tsd-signature-type tsd-kind-interface">IRequestResponse</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span><a href="#execute-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">request</span>: <a href="Request.html" class="tsd-signature-type tsd-kind-class">Request</a></span></li><li><span><span class="tsd-kind-parameter">response</span>: <a href="Response.html" class="tsd-signature-type tsd-kind-class">Response</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/IRequestResponse.html" class="tsd-signature-type tsd-kind-interface">IRequestResponse</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span></h4><aside class="tsd-sources"><p>Inherited from <a href="Middleware.html">Middleware</a>.<a href="Middleware.html#execute">execute</a></p><ul><li>Defined in <a href="https://github.com/breautek/storm/blob/d1f7b6e5c47e4e6ee4db0119405b3963f9309836/src/Middleware.ts#L26">src/Middleware.ts:26</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="getdefaultallowedheaders"><span>get<wbr/>Default<wbr/>Allowed<wbr/>Headers</span><a href="#getdefaultallowedheaders" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="getdefaultallowedheaders-1"><span class="tsd-kind-call-signature">getDefaultAllowedHeaders</span><span class="tsd-signature-symbol">()</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span><a href="#getdefaultallowedheaders-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/breautek/storm/blob/d1f7b6e5c47e4e6ee4db0119405b3963f9309836/src/CORSMiddleware.ts#L54">src/CORSMiddleware.ts:54</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="getdefaultallowedmethods"><span>get<wbr/>Default<wbr/>Allowed<wbr/>Methods</span><a href="#getdefaultallowedmethods" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="getdefaultallowedmethods-1"><span class="tsd-kind-call-signature">getDefaultAllowedMethods</span><span class="tsd-signature-symbol">()</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span><a href="#getdefaultallowedmethods-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/breautek/storm/blob/d1f7b6e5c47e4e6ee4db0119405b3963f9309836/src/CORSMiddleware.ts#L64">src/CORSMiddleware.ts:64</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="getdefaultallowedorigin"><span>get<wbr/>Default<wbr/>Allowed<wbr/>Origin</span><a href="#getdefaultallowedorigin" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="getdefaultallowedorigin-1"><span class="tsd-kind-call-signature">getDefaultAllowedOrigin</span><span class="tsd-signature-symbol">()</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><a href="#getdefaultallowedorigin-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Sets the allowed origin. By default,</p>
14
- </div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/breautek/storm/blob/d1f7b6e5c47e4e6ee4db0119405b3963f9309836/src/CORSMiddleware.ts#L50">src/CORSMiddleware.ts:50</a></li></ul></aside></div></li></ul></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Constructors</summary><div><a href="#constructor"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Constructor"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Methods"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Methods</summary><div><a href="#_execute" class="tsd-is-protected"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>_<wbr/>execute</span></a><a href="#execute" class="tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>execute</span></a><a href="#getdefaultallowedheaders"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>get<wbr/>Default<wbr/>Allowed<wbr/>Headers</span></a><a href="#getdefaultallowedmethods"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>get<wbr/>Default<wbr/>Allowed<wbr/>Methods</span></a><a href="#getdefaultallowedorigin"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>get<wbr/>Default<wbr/>Allowed<wbr/>Origin</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../index.html">@breautek/storm</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>