Skip to content

Instantly share code, notes, and snippets.

@bharat-tiwari
Created December 24, 2018 18:49
Show Gist options
  • Save bharat-tiwari/47e88ac8872414d644ca5c6fb3d5e271 to your computer and use it in GitHub Desktop.
Save bharat-tiwari/47e88ac8872414d644ca5c6fb3d5e271 to your computer and use it in GitHub Desktop.
NoteWordy API - lambda for delete word
import { APP_CONSTANTS } from '../../config/app_constants';
import getResponse from '../../utils/responseUtils';
import * as AWS from "aws-sdk";
const dynamoDb = new AWS.DynamoDB.DocumentClient({
'region': 'us-east-1'
});
export async function main(event, context, callback) {
const params = {
TableName: APP_CONSTANTS.WORDS_TABLE,
Key: {
userId: event.requestContext.identity.cognitoIdentityId,
wordId: event.pathParameters.id
}
};
try {
const data = await dynamoDb.delete(params).promise();
const response = getResponse(200, {status: true} );
callback(null, response);
} catch (error) {
const errResponse = getResponse(500, {status: false, body: JSON.stringify(error)});
callback(null, errResponse);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment