Last active
February 8, 2020 19:12
-
-
Save arianacosta/3c24af91d6ab85a37ec81f89b1f76790 to your computer and use it in GitHub Desktop.
Lambda that receives a UserDto and returns a GreetingDto
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 { UserDto } from './UserDto'; | |
import { GreetingDto } from './GreetingDto'; | |
export const handler = async (event: any): Promise<GreetingDto> => { | |
const userDto = UserDto.from(event); | |
// safely access user properties | |
const greeting = userDto.isFormal ? | |
`Dear ${userDto.firstName} ${userDto.lastName}, welcome back.` : | |
`Hey ${userDto.firstName} ${userDto.lastName}! Long time no see.`; | |
return new GreetingDto(greeting); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment