@@ -2,13 +2,18 @@ import {
22 APIGatewayProxyEventV2 , APIGatewayProxyStructuredResultV2 ,
33 APIGatewayProxyEventQueryStringParameters , APIGatewayProxyEventPathParameters
44} from 'aws-lambda'
5+
6+ import createDebug from 'debug'
7+
58import type { AxiosRequestConfig , AxiosResponse } from 'axios'
69import type { Runner , Operation , UnknownContext } from 'openapi-client-axios'
710import { invokeLambda } from './lambda-invoker'
811import { params } from 'bath/params'
912import { safeParseJson } from './util'
1013import { v4 as uuidv4 } from 'uuid'
1114
15+ const debug = createDebug ( 'openapi-lambda-adapter' )
16+
1217export 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
98107export 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