File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change 1
- import type { MiddlewareObj } from '@middy/core'
1
+ import type { MiddlewareObj , Request } from '@middy/core'
2
2
import type {
3
3
APIGatewayProxyEventV2 ,
4
4
APIGatewayProxyStructuredResultV2 ,
5
5
} from 'aws-lambda'
6
6
7
7
export const addVersionHeader = (
8
8
version : string ,
9
- ) : MiddlewareObj <
10
- APIGatewayProxyEventV2 ,
11
- APIGatewayProxyStructuredResultV2
12
- > => ( {
13
- after : async ( req ) => {
9
+ ) : MiddlewareObj < APIGatewayProxyEventV2 , APIGatewayProxyStructuredResultV2 > => {
10
+ const setVersionHeader = async ( req : Request ) => {
14
11
if ( req . response === null ) return
15
12
req . response = {
16
13
...req . response ,
@@ -19,5 +16,10 @@ export const addVersionHeader = (
19
16
'x-backend-version' : version ,
20
17
} ,
21
18
}
22
- } ,
23
- } )
19
+ }
20
+
21
+ return {
22
+ after : setVersionHeader ,
23
+ onError : setVersionHeader ,
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments