-
Notifications
You must be signed in to change notification settings - Fork 0
/
deleteHighlight.js
42 lines (34 loc) · 1.04 KB
/
deleteHighlight.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
40
41
42
const AWS = require('aws-sdk');
const docClient = new AWS.DynamoDB.DocumentClient({region: "ap-southeast-2"});
exports.handler = (event, context, callback) => {
console.log("Processing...");
const params = {
Key: {webpageURL: event.url, highlightID: event.highlightID},
TableName: "highlights",
};
console.log(params.Key)
console.log(event)
const response = {
statusCode: 200,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': true,
},
body: JSON.stringify({
date: Date.now(),
webpageURL: event.url,
highlightID: context.awsRequestId,
highlightText: event.text,
webpageTitle: event.title,
webpageTopic: event.topic
}),
};
let self = this;
docClient.delete(params, (err, data) => {
if(err){
callback(err, null);
} else {
callback(null, "deleted");
}
})
};