@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.
- package/dist/ws/server/closeConnection.d.ts.map +1 -1
- package/dist/ws/server/closeConnection.js +3 -2
- package/dist/ws/server/closeConnection.js.map +1 -1
- package/dist/ws/server/getApiGatewayManagementApiClient.d.ts +3 -0
- package/dist/ws/server/getApiGatewayManagementApiClient.d.ts.map +1 -0
- package/dist/ws/server/getApiGatewayManagementApiClient.js +10 -0
- package/dist/ws/server/getApiGatewayManagementApiClient.js.map +1 -0
- package/dist/ws/server/sendResponse.d.ts.map +1 -1
- package/dist/ws/server/sendResponse.js +3 -2
- package/dist/ws/server/sendResponse.js.map +1 -1
- package/package.json +1 -1
|
@@ -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;
|
|
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 {
|
|
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
|
|
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,
|
|
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 @@
|
|
|
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;
|
|
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 {
|
|
1
|
+
import { PostToConnectionCommand } from '@aws-sdk/client-apigatewaymanagementapi';
|
|
2
|
+
import { getApiGatewayManagementApiClient } from './getApiGatewayManagementApiClient';
|
|
2
3
|
export const sendResponse = async ({ endpoint, connectionId, }, response) => {
|
|
3
|
-
await
|
|
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,
|
|
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"}
|