diff --git a/src/handlers/CreateEntity/function.ts b/src/handlers/CreateEntity/function.ts index 94f4075..fbb68cc 100644 --- a/src/handlers/CreateEntity/function.ts +++ b/src/handlers/CreateEntity/function.ts @@ -68,7 +68,19 @@ export async function handler (event: APIGatewayProxyEvent, _: Context): Promise LOGGER.info('Received event', { event }) const entity: Entity = JSON.parse(event.body || '{}') // Already validated body at Gateway - const output = await putEntity(entity) + + let statusCode: number + let body: string + let output: PutItemCommandOutput + try { + output = await putEntity(entity) + statusCode = 201 + body = JSON.stringify({'request_id': output.$metadata.requestId}) + } catch (error) { + statusCode = 500 + body = JSON.stringify({error: (error).message}) + } + return { statusCode: 201,