@mcma/aws-api-gateway
Advanced tools
Comparing version 0.16.1 to 0.16.2
import { ConfigVariables, LoggerProvider } from "@mcma/core"; | ||
import { McmaApiRouteCollection } from "@mcma/api"; | ||
import { McmaApiRouteCollection, McmaApiMiddleware } from "@mcma/api"; | ||
import { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyResultV2, Context } from "aws-lambda"; | ||
export interface ApiGatewayApiControllerConfig { | ||
routes: McmaApiRouteCollection; | ||
loggerProvider?: LoggerProvider; | ||
configVariables?: ConfigVariables; | ||
middleware?: McmaApiMiddleware[]; | ||
includeStageInPath?: boolean; | ||
} | ||
export declare class ApiGatewayApiController { | ||
private loggerProvider?; | ||
private configVariables; | ||
private mcmaApiController; | ||
private apiController; | ||
private config; | ||
constructor(config: ApiGatewayApiControllerConfig); | ||
constructor(routes: McmaApiRouteCollection, loggerProvider?: LoggerProvider, configVariables?: ConfigVariables); | ||
@@ -9,0 +16,0 @@ handleRequest(event: APIGatewayProxyEventV2, context: Context): Promise<APIGatewayProxyResultV2>; |
@@ -10,9 +10,19 @@ "use strict"; | ||
class ApiGatewayApiController { | ||
loggerProvider; | ||
configVariables; | ||
mcmaApiController; | ||
constructor(routes, loggerProvider, configVariables = core_1.ConfigVariables.getInstance()) { | ||
this.loggerProvider = loggerProvider; | ||
this.configVariables = configVariables; | ||
this.mcmaApiController = new api_1.McmaApiController(routes); | ||
apiController; | ||
config; | ||
constructor(routesOrConfig, loggerProvider, configVariables) { | ||
if (routesOrConfig instanceof api_1.McmaApiRouteCollection) { | ||
this.config = { | ||
routes: routesOrConfig, | ||
loggerProvider: loggerProvider, | ||
configVariables: configVariables, | ||
}; | ||
} | ||
else { | ||
this.config = routesOrConfig; | ||
} | ||
if (!this.config.configVariables) { | ||
this.config.configVariables = core_1.ConfigVariables.getInstance(); | ||
} | ||
this.apiController = new api_1.McmaApiController(this.config.routes, this.config.middleware); | ||
} | ||
@@ -23,7 +33,7 @@ async handleRequest(event, context) { | ||
httpMethod = event.httpMethod; | ||
path = event.path; | ||
path = this.config.includeStageInPath ? event.requestContext.path : event.path; | ||
} | ||
else { | ||
httpMethod = event.requestContext.http.method; | ||
path = event.requestContext.http.path.substring(event.requestContext.stage.length + 1); | ||
path = this.config.includeStageInPath ? event.requestContext.http.path : event.requestContext.http.path.substring(event.requestContext.stage.length + 1); | ||
} | ||
@@ -38,4 +48,4 @@ const requestContext = new api_1.McmaApiRequestContext(new api_1.McmaApiRequest({ | ||
body: event.body | ||
}), this.loggerProvider, this.configVariables); | ||
await this.mcmaApiController.handleRequest(requestContext); | ||
}), this.config.loggerProvider, this.config.configVariables); | ||
await this.apiController.handleRequest(requestContext); | ||
let body = requestContext.response.body; | ||
@@ -42,0 +52,0 @@ let isBase64Encoded = false; |
{ | ||
"name": "@mcma/aws-api-gateway", | ||
"version": "0.16.1", | ||
"version": "0.16.2", | ||
"description": "Node module with code for using AWS's API Gateway as an entry point to an MCMA API handler.", | ||
@@ -37,12 +37,12 @@ "engines": { | ||
"peerDependencies": { | ||
"@mcma/core": "0.16.1", | ||
"@mcma/api": "0.16.1", | ||
"@mcma/core": "0.16.2", | ||
"@mcma/api": "0.16.2", | ||
"@types/aws-lambda": "^8.10.114" | ||
}, | ||
"devDependencies": { | ||
"@mcma/api": "0.16.1", | ||
"@mcma/client": "0.16.1", | ||
"@mcma/core": "0.16.1", | ||
"@mcma/data": "0.16.1", | ||
"@mcma/worker-invoker": "0.16.1", | ||
"@mcma/api": "0.16.2", | ||
"@mcma/client": "0.16.2", | ||
"@mcma/core": "0.16.2", | ||
"@mcma/data": "0.16.2", | ||
"@mcma/worker-invoker": "0.16.2", | ||
"@types/aws-lambda": "^8.10.114", | ||
@@ -49,0 +49,0 @@ "@types/node": "^18.15.10", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6648
119