Skip to content

Instantly share code, notes, and snippets.

@arianacosta
Last active February 8, 2020 19:12
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 arianacosta/3c24af91d6ab85a37ec81f89b1f76790 to your computer and use it in GitHub Desktop.
Save arianacosta/3c24af91d6ab85a37ec81f89b1f76790 to your computer and use it in GitHub Desktop.
Lambda that receives a UserDto and returns a GreetingDto
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