Created
May 22, 2020 17:11
-
-
Save robertofrontado/b3b7ff83bc7327b24d5aa53bdde9de81 to your computer and use it in GitHub Desktop.
serverless-todo-createtodo-with-service
This file contains hidden or 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 'source-map-support/register' | |
import { APIGatewayProxyHandler, APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda' | |
import TodoService from '../../services/todoService' | |
export const handler: APIGatewayProxyHandler = async (event: APIGatewayProxyEvent): Promise<APIGatewayProxyResult> => { | |
const { name } = JSON.parse(event.body) | |
const todoService = new TodoService() | |
const todo = await todoService.createTodo(name) | |
return { | |
statusCode: 201, | |
body: JSON.stringify({ | |
item: todo | |
}) | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment