serverless-simple-middleware 0.0.66 → 0.0.68

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.
@@ -12,6 +12,11 @@ export declare class ConnectionProxy {
12
12
  commit: () => Promise<void>;
13
13
  rollback: () => Promise<void>;
14
14
  clearConnection: () => void;
15
+ /**
16
+ * Destroy the connection socket immediately. No further events or callbacks will be triggered.
17
+ * This should be used only for special use cases!
18
+ */
19
+ destroyConnection: () => void;
15
20
  onPluginCreated: () => Promise<void>;
16
21
  private prepareConnection;
17
22
  private changeDatabase;
@@ -83,6 +83,17 @@ class ConnectionProxy {
83
83
  logger.verbose('Connection is end');
84
84
  }
85
85
  };
86
+ /**
87
+ * Destroy the connection socket immediately. No further events or callbacks will be triggered.
88
+ * This should be used only for special use cases!
89
+ */
90
+ destroyConnection = () => {
91
+ if (this.connection) {
92
+ this.connection.destroy();
93
+ this.connection = undefined;
94
+ logger.verbose('Connection is destroyed');
95
+ }
96
+ };
86
97
  onPluginCreated = async () => this.tryToInitializeSchema(true);
87
98
  prepareConnection = () => {
88
99
  if (this.connection) {
@@ -4,5 +4,10 @@ export declare class SQLClient<T = unknown> extends Kysely<T> {
4
4
  private pool;
5
5
  constructor(config: ConnectionOptions);
6
6
  clearConnection: () => Promise<void>;
7
+ /**
8
+ * Destroy the connection socket immediately. No further events or callbacks will be triggered.
9
+ * This should be used only for special use cases!
10
+ */
11
+ destroyConnection: () => void;
7
12
  }
8
13
  export { expressionBuilder, sql, type DeleteQueryBuilder, type DeleteResult, type Expression, type ExpressionBuilder, type InferResult, type Insertable, type InsertQueryBuilder, type InsertResult, type NotNull, type RawBuilder, type Selectable, type SelectQueryBuilder, type SqlBool, type Transaction, type Updateable, type UpdateQueryBuilder, type UpdateResult, } from 'kysely';
@@ -35,6 +35,12 @@ class LazyConnectionPool {
35
35
  callback(null);
36
36
  }
37
37
  };
38
+ destroy = () => {
39
+ if (this.connection) {
40
+ this.connection.destroy();
41
+ this.connection = null;
42
+ }
43
+ };
38
44
  _addRelease = (connection) => Object.assign(connection, {
39
45
  release: () => { },
40
46
  });
@@ -58,6 +64,13 @@ class SQLClient extends kysely_1.Kysely {
58
64
  clearConnection = () => new Promise((resolve) => {
59
65
  this.pool.end(() => resolve());
60
66
  });
67
+ /**
68
+ * Destroy the connection socket immediately. No further events or callbacks will be triggered.
69
+ * This should be used only for special use cases!
70
+ */
71
+ destroyConnection = () => {
72
+ this.pool.destroy();
73
+ };
61
74
  }
62
75
  exports.SQLClient = SQLClient;
63
76
  var kysely_2 = require("kysely");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "serverless-simple-middleware",
3
3
  "description": "Simple middleware to translate the interface of lambda's handler to request => response",
4
- "version": "0.0.66",
4
+ "version": "0.0.68",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "author": "VoyagerX",
@@ -102,6 +102,18 @@ export class ConnectionProxy {
102
102
  }
103
103
  };
104
104
 
105
+ /**
106
+ * Destroy the connection socket immediately. No further events or callbacks will be triggered.
107
+ * This should be used only for special use cases!
108
+ */
109
+ public destroyConnection = () => {
110
+ if (this.connection) {
111
+ this.connection.destroy();
112
+ this.connection = undefined;
113
+ logger.verbose('Connection is destroyed');
114
+ }
115
+ };
116
+
105
117
  public onPluginCreated = async () => this.tryToInitializeSchema(true);
106
118
 
107
119
  private prepareConnection = () => {
@@ -50,6 +50,13 @@ class LazyConnectionPool implements MysqlPool {
50
50
  }
51
51
  };
52
52
 
53
+ public destroy = (): void => {
54
+ if (this.connection) {
55
+ this.connection.destroy();
56
+ this.connection = null;
57
+ }
58
+ };
59
+
53
60
  private _addRelease = (connection: Connection): LazyMysqlPoolConnection =>
54
61
  Object.assign(connection, {
55
62
  release: () => {},
@@ -78,6 +85,14 @@ export class SQLClient<T = unknown> extends Kysely<T> {
78
85
  new Promise<void>((resolve) => {
79
86
  this.pool.end(() => resolve());
80
87
  });
88
+
89
+ /**
90
+ * Destroy the connection socket immediately. No further events or callbacks will be triggered.
91
+ * This should be used only for special use cases!
92
+ */
93
+ public destroyConnection = (): void => {
94
+ this.pool.destroy();
95
+ };
81
96
  }
82
97
 
83
98
  export {