File tree 3 files changed +48
-0
lines changed
3 files changed +48
-0
lines changed File renamed without changes.
Original file line number Diff line number Diff line change
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
+ } ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " lambda-typescript-layer-example" ,
3
+ "version" : " 1.0.0" ,
4
+ "main" : " dist/index.js" ,
5
+ "scripts" : {
6
+ "prebuild" : " rm -rf dist" ,
7
+ "build" : " tsc index.ts --module nodenext --lib es2020 --outDir dist/" ,
8
+ "postbuild" : " cd dist && zip -r index.zip index.js" ,
9
+ "test" : " echo \" Error: no test specified\" && exit 1"
10
+ },
11
+ "author" : " " ,
12
+ "license" : " MIT-0" ,
13
+ "description" : " " ,
14
+ "devDependencies" : {
15
+ "@types/aws-lambda" : " ^8.10.145" ,
16
+ "@types/lodash" : " ^4.17.9" ,
17
+ "lodash" : " ^4.17.21" ,
18
+ "typescript" : " ^5.6.2"
19
+ }
20
+ }
You can’t perform that action at this time.
0 commit comments