File tree 6 files changed +40
-29
lines changed
6 files changed +40
-29
lines changed Original file line number Diff line number Diff line change 14
14
"jest" : " ^24.9.0" ,
15
15
"lambda-local" : " ^1.6.3" ,
16
16
"node-fetch" : " ^2.6.1" ,
17
- "prettier" : " ^1.18.2 " ,
17
+ "prettier" : " 2.1.1 " ,
18
18
"ts-jest" : " ^24.1.0" ,
19
19
"typescript" : " ^3.6.4"
20
20
},
25
25
"build" : " tsc" ,
26
26
"lint" : " eslint --ext=.ts src" ,
27
27
"test" : " jest" ,
28
- "test:lambda" : " yarn build && lambda-local -l ./dist/index.js -e ./dist/mock-events/default -h stuffGet "
28
+ "test:lambda" : " yarn build && lambda-local -l ./dist/index.js -e ./dist/mock-events/default -h randomGet "
29
29
},
30
30
"version" : " 1.0.0"
31
31
}
Original file line number Diff line number Diff line change 1
- export { handler as stuffGet } from './stuff -get'
1
+ export { handler as randomGet } from './random -get'
Original file line number Diff line number Diff line change 1
1
import fetch from 'node-fetch'
2
- import { handler } from './stuff -get'
2
+ import { handler } from './random -get'
3
3
4
4
const mockedFetch : jest . Mock = fetch as any
5
5
6
6
jest . mock ( 'node-fetch' )
7
7
8
- describe ( 'stuff -get handler' , ( ) => {
8
+ describe ( 'random -get handler' , ( ) => {
9
9
const mockPayload = { test : 'hello?' }
10
10
beforeEach ( ( ) => {
11
11
mockedFetch . mockReturnValueOnce ( {
Original file line number Diff line number Diff line change
1
+ import fetch from 'node-fetch'
2
+ import { Response } from './types'
3
+
4
+ interface RandomResponse extends Response {
5
+ body : RandomDog
6
+ }
7
+
8
+ interface ErrorResponse extends Response {
9
+ message : string
10
+ }
11
+
12
+ interface RandomDog {
13
+ message : string
14
+ status : string
15
+ }
16
+
17
+ export async function handler ( ) : Promise < RandomResponse | ErrorResponse > {
18
+ try {
19
+ const res = await fetch ( 'https://dog.ceo/api/breeds/image/random' )
20
+ const payload : RandomDog = await res . json ( )
21
+ return {
22
+ statusCode : 200 ,
23
+ body : payload ,
24
+ }
25
+ } catch ( err : unknown ) {
26
+ return {
27
+ statusCode : 500 ,
28
+ message : 'Something went wrong' ,
29
+ }
30
+ }
31
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -3393,10 +3393,10 @@ prettier-linter-helpers@^1.0.0:
3393
3393
dependencies :
3394
3394
fast-diff "^1.1.2"
3395
3395
3396
- prettier@^1.18.2 :
3397
- version "1.18.2 "
3398
- resolved "https://registry.yarnpkg. com/ prettier/-/prettier-1.18.2. tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea "
3399
- integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw ==
3396
+ prettier@2.1.1 :
3397
+ version "2.1.1 "
3398
+ resolved "https://extend-159581800400.d.codeartifact.us-east-1.amazonaws. com:443/npm/extend-npm/ prettier/-/prettier-2.1.1. tgz#d9485dd5e499daa6cb547023b87a6cf51bee37d6 "
3399
+ integrity sha512-9bY+5ZWCfqj3ghYBLxApy2zf6m+NJo5GzmLTpr9FsApsfjriNnS2dahWReHMi7qNPhhHl9SYHJs2cHZLgexNIw ==
3400
3400
3401
3401
pretty-format@^24.9.0 :
3402
3402
version "24.9.0"
You can’t perform that action at this time.
0 commit comments