Skip to content

Commit ae661fb

Browse files
committed
Initial commit for TypeScript layer example
1 parent 227a6c0 commit ae661fb

File tree

1 file changed

+28
-0
lines changed
  • sample-apps/layer-typescript/function

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Handler } from 'aws-lambda';
2+
import * as _ from 'lodash';
3+
4+
type User = {
5+
user: string;
6+
active: boolean;
7+
}
8+
9+
type UserResult = {
10+
statusCode: number;
11+
body: string;
12+
}
13+
14+
const users: User[] = [
15+
{ 'user': 'Carlos', 'active': true },
16+
{ 'user': 'Gil-dong', 'active': false },
17+
{ 'user': 'Pat', 'active': false }
18+
];
19+
20+
export const handler: Handler<any, UserResult> = async (): Promise<UserResult> => {
21+
22+
let out = _.findLastIndex(users, (user: User) => { return user.user == 'Pat'; });
23+
const response = {
24+
statusCode: 200,
25+
body: JSON.stringify(out + ", " + users[out].user),
26+
};
27+
return response;
28+
};

0 commit comments

Comments
 (0)