Skip to content

Commit 0c152b1

Browse files
authored
Merge branch 'main' into fix/stringify-headers
2 parents 27fedc3 + 0aecd63 commit 0c152b1

File tree

3 files changed

+48
-7
lines changed

3 files changed

+48
-7
lines changed

package-lock.json

Lines changed: 34 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
],
3636
"dependencies": {
3737
"bath": "^3.0.1",
38+
"debug": "^4.3.4",
3839
"uuid": "^9.0.0"
3940
},
4041
"peerDependencies": {
@@ -43,6 +44,7 @@
4344
"devDependencies": {
4445
"@jest/types": "^29.0.3",
4546
"@types/aws-lambda": "^8.10.104",
47+
"@types/debug": "^4.1.7",
4648
"@types/jest": "^27.4.0",
4749
"@types/json-schema": "^7.0.6",
4850
"@types/node": "^18.7.18",

src/openapi-lambda-adapters.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ import {
22
APIGatewayProxyEventV2, APIGatewayProxyStructuredResultV2,
33
APIGatewayProxyEventQueryStringParameters, APIGatewayProxyEventPathParameters
44
} from 'aws-lambda'
5+
6+
import createDebug from 'debug'
7+
58
import type { AxiosRequestConfig, AxiosResponse } from 'axios'
69
import type { Runner, Operation, UnknownContext } from 'openapi-client-axios'
710
import { invokeLambda } from './lambda-invoker'
811
import { params } from 'bath/params'
912
import { safeParseJson } from './util'
1013
import { v4 as uuidv4 } from 'uuid'
1114

15+
const debug = createDebug('openapi-lambda-adapter')
16+
1217
export const getLambdaRunner = (functionName: string): Runner => {
1318
return {
1419
runRequest: lambdaRunner,
@@ -58,7 +63,7 @@ export const convertAxiosToApiGw = (config: AxiosRequestConfig, operation: Opera
5863
headers[key] = val.toString()
5964
}
6065

61-
return {
66+
const lambdaPayload = {
6267
version: '2.0',
6368
routeKey: '$default',
6469
rawPath: config.url,
@@ -93,9 +98,15 @@ export const convertAxiosToApiGw = (config: AxiosRequestConfig, operation: Opera
9398
isBase64Encoded: false,
9499
httpMethod: config.method
95100
} as APIGatewayProxyEventV2
101+
102+
debug('lambdaRequest %o', lambdaPayload)
103+
104+
return lambdaPayload
96105
}
97106

98107
export const convertApiGwToAxios = (resp: APIGatewayProxyStructuredResultV2, axiosConfig: AxiosRequestConfig) => {
108+
debug('lambdaResponse %o', resp)
109+
99110
const axiosResp = {
100111
config: axiosConfig,
101112
status: resp.statusCode,

0 commit comments

Comments
 (0)