-
Notifications
You must be signed in to change notification settings - Fork 3
/
getConnections.js
39 lines (35 loc) · 1.04 KB
/
getConnections.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const AWS = require("aws-sdk");
const ddb = new AWS.DynamoDB.DocumentClient({
apiVersion: "2012-08-10",
region: "eu-west-1",
});
exports.handler = async (event) => {
let connectionData;
const { storeId, conversationId } = JSON.parse(event.body);
try {
const params = {
FilterExpression:
"conversationId = :conversationId AND storeId = :storeId AND negotiation = :negotiation AND connectionType = :connectionType",
ExpressionAttributeValues: {
":storeId": storeId,
":conversationId": conversationId,
":negotiation": "true",
":connectionType": "master",
},
ProjectionExpression:
"connectionId, userId, conversationId, storeId, deviceId, createdAt",
TableName: "yownit_websocket",
};
connectionData = await ddb.scan(params).promise();
} catch (e) {
console.log(e);
return { statusCode: 500, body: e.stack };
}
return {
statusCode: 200,
body: JSON.stringify(connectionData),
headers: {
"Access-Control-Allow-Origin": "*",
},
};
};