@mstuercke/api-utils 4.0.0 → 4.1.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.
@@ -1 +1 @@
1
- {"version":3,"file":"closeConnection.d.ts","sourceRoot":"","sources":["../../../src/ws/server/closeConnection.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,UAAU,CAAC;AAEzC,eAAO,MAAM,eAAe,+BAAoC,eAAe,kBAW9E,CAAC"}
1
+ {"version":3,"file":"closeConnection.d.ts","sourceRoot":"","sources":["../../../src/ws/server/closeConnection.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,UAAU,CAAC;AAGzC,eAAO,MAAM,eAAe,+BAAoC,eAAe,kBAW9E,CAAC"}
@@ -1,7 +1,8 @@
1
- import { ApiGatewayManagementApiClient, DeleteConnectionCommand } from '@aws-sdk/client-apigatewaymanagementapi';
1
+ import { DeleteConnectionCommand } from '@aws-sdk/client-apigatewaymanagementapi';
2
+ import { getApiGatewayManagementApiClient } from './getApiGatewayManagementApiClient';
2
3
  export const closeConnection = async ({ endpoint, connectionId }) => {
3
4
  try {
4
- await new ApiGatewayManagementApiClient({ endpoint }).send(new DeleteConnectionCommand({ ConnectionId: connectionId }));
5
+ await getApiGatewayManagementApiClient(endpoint).send(new DeleteConnectionCommand({ ConnectionId: connectionId }));
5
6
  }
6
7
  catch (err) {
7
8
  if (err && typeof err === 'object' && 'name' in err && err?.name === 'GoneException')
@@ -1 +1 @@
1
- {"version":3,"file":"closeConnection.js","sourceRoot":"","sources":["../../../src/ws/server/closeConnection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,6BAA6B,EAAE,uBAAuB,EAAC,MAAM,yCAAyC,CAAC;AAG/G,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,EAAC,QAAQ,EAAE,YAAY,EAAkB,EAAE,EAAE;IACjF,IAAI,CAAC;QACH,MAAM,IAAI,6BAA6B,CAAC,EAAC,QAAQ,EAAC,CAAC,CAAC,IAAI,CACpD,IAAI,uBAAuB,CAAC,EAAC,YAAY,EAAE,YAAY,EAAC,CAAC,CAC5D,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,IAAI,GAAG,IAAI,GAAG,EAAE,IAAI,KAAK,eAAe;YAClF,OAAO;QAET,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC,CAAC"}
1
+ {"version":3,"file":"closeConnection.js","sourceRoot":"","sources":["../../../src/ws/server/closeConnection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,yCAAyC,CAAC;AAEhF,OAAO,EAAC,gCAAgC,EAAC,MAAM,oCAAoC,CAAC;AAEpF,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,EAAC,QAAQ,EAAE,YAAY,EAAkB,EAAE,EAAE;IACjF,IAAI,CAAC;QACH,MAAM,gCAAgC,CAAC,QAAQ,CAAC,CAAC,IAAI,CACjD,IAAI,uBAAuB,CAAC,EAAC,YAAY,EAAE,YAAY,EAAC,CAAC,CAC5D,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,IAAI,GAAG,IAAI,GAAG,EAAE,IAAI,KAAK,eAAe;YAClF,OAAO;QAET,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { ApiGatewayManagementApiClient } from '@aws-sdk/client-apigatewaymanagementapi';
2
+ export declare const getApiGatewayManagementApiClient: (endpoint: string) => ApiGatewayManagementApiClient;
3
+ //# sourceMappingURL=getApiGatewayManagementApiClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getApiGatewayManagementApiClient.d.ts","sourceRoot":"","sources":["../../../src/ws/server/getApiGatewayManagementApiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,6BAA6B,EAAC,MAAM,yCAAyC,CAAC;AAGtF,eAAO,MAAM,gCAAgC,aAAc,MAAM,KAAG,6BAOnE,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { ApiGatewayManagementApiClient } from '@aws-sdk/client-apigatewaymanagementapi';
2
+ const clients = {};
3
+ export const getApiGatewayManagementApiClient = (endpoint) => {
4
+ if (clients[endpoint])
5
+ return clients[endpoint];
6
+ const client = new ApiGatewayManagementApiClient({ endpoint });
7
+ clients[endpoint] = client;
8
+ return client;
9
+ };
10
+ //# sourceMappingURL=getApiGatewayManagementApiClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getApiGatewayManagementApiClient.js","sourceRoot":"","sources":["../../../src/ws/server/getApiGatewayManagementApiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,6BAA6B,EAAC,MAAM,yCAAyC,CAAC;AAEtF,MAAM,OAAO,GAA0D,EAAE,CAAC;AAC1E,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,QAAgB,EAAiC,EAAE;IAClG,IAAI,OAAO,CAAC,QAAQ,CAAC;QACnB,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE3B,MAAM,MAAM,GAAG,IAAI,6BAA6B,CAAC,EAAC,QAAQ,EAAC,CAAC,CAAC;IAC7D,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC;IAC3B,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sendResponse.d.ts","sourceRoot":"","sources":["../../../src/ws/server/sendResponse.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAgB,MAAM,UAAU,CAAC;AAExD,eAAO,MAAM,YAAY,2DAKpB,eAAe,2BAAuB,QAAQ,IAAI,CAOtD,CAAC"}
1
+ {"version":3,"file":"sendResponse.d.ts","sourceRoot":"","sources":["../../../src/ws/server/sendResponse.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAgB,MAAM,UAAU,CAAC;AAGxD,eAAO,MAAM,YAAY,2DAKpB,eAAe,2BAAuB,QAAQ,IAAI,CAOtD,CAAC"}
@@ -1,6 +1,7 @@
1
- import { ApiGatewayManagementApiClient, PostToConnectionCommand } from '@aws-sdk/client-apigatewaymanagementapi';
1
+ import { PostToConnectionCommand } from '@aws-sdk/client-apigatewaymanagementapi';
2
+ import { getApiGatewayManagementApiClient } from './getApiGatewayManagementApiClient';
2
3
  export const sendResponse = async ({ endpoint, connectionId, }, response) => {
3
- await new ApiGatewayManagementApiClient({ endpoint }).send(new PostToConnectionCommand({
4
+ await getApiGatewayManagementApiClient(endpoint).send(new PostToConnectionCommand({
4
5
  ConnectionId: connectionId,
5
6
  Data: JSON.stringify(response),
6
7
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"sendResponse.js","sourceRoot":"","sources":["../../../src/ws/server/sendResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,6BAA6B,EAAE,uBAAuB,EAAC,MAAM,yCAAyC,CAAC;AAG/G,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAE/B,EACE,QAAQ,EACR,YAAY,GACI,EAAE,QAAkB,EAAiB,EAAE;IACzD,MAAM,IAAI,6BAA6B,CAAC,EAAC,QAAQ,EAAC,CAAC,CAAC,IAAI,CACpD,IAAI,uBAAuB,CAAC;QAC1B,YAAY,EAAE,YAAY;QAC1B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;KAC/B,CAAC,CACL,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"sendResponse.js","sourceRoot":"","sources":["../../../src/ws/server/sendResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,yCAAyC,CAAC;AAEhF,OAAO,EAAC,gCAAgC,EAAC,MAAM,oCAAoC,CAAC;AAEpF,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAE/B,EACE,QAAQ,EACR,YAAY,GACI,EAAE,QAAkB,EAAiB,EAAE;IACzD,MAAM,gCAAgC,CAAC,QAAQ,CAAC,CAAC,IAAI,CACjD,IAAI,uBAAuB,CAAC;QAC1B,YAAY,EAAE,YAAY;QAC1B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;KAC/B,CAAC,CACL,CAAC;AACJ,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mstuercke/api-utils",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist/**/*.js",