Created
December 24, 2018 18:49
-
-
Save bharat-tiwari/47e88ac8872414d644ca5c6fb3d5e271 to your computer and use it in GitHub Desktop.
NoteWordy API - lambda for delete word
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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