Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertofrontado/0212618efd81d60f49748d9dfa44069f to your computer and use it in GitHub Desktop.
Save robertofrontado/0212618efd81d60f49748d9dfa44069f to your computer and use it in GitHub Desktop.
serverless-todo-updatetodo-with-service
import 'source-map-support/register'
import { APIGatewayProxyHandler, APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda'
import TodoService from '../../services/todoService'
import { TodoItem } from '../../models/TodoItem'
export const handler: APIGatewayProxyHandler = async (event: APIGatewayProxyEvent): Promise<APIGatewayProxyResult> => {
const id = event.pathParameters.id
const todoService = new TodoService()
const todo: Partial<TodoItem> = { ...JSON.parse(event.body), id }
const todoUpdated = await todoService.updateTodo(todo)
return {
statusCode: 200,
body: JSON.stringify({
item: todoUpdated
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment