-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAPI-Gateway.js
More file actions
30 lines (27 loc) · 831 Bytes
/
API-Gateway.js
File metadata and controls
30 lines (27 loc) · 831 Bytes
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
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'ap-southeast-1'});
// Create the DynamoDB service object
var ddb = new AWS.DynamoDB({apiVersion: '2012-08-10'});
// Create the Document Client interface for DynamoDB
var ddbDocumentClient = new AWS.DynamoDB.DocumentClient();
// Set table name
var tableName = "cypress-psoc";
// Scan for all items in database
async function scanForResultsDdbDc(){
try {
var params = {
TableName: tableName
};
var result = await ddbDocumentClient.scan(params).promise()
return JSON.stringify(result);
} catch (error) {
console.error(error);
return error;
}
}
// handler
exports.handler = function (event, context, callback) {
return await scanForResultsDdbDc();
}