aws-delivlib
Version:
A fabulous library for defining continuous pipelines for building, testing and releasing code libraries.
30 lines (29 loc) • 1.1 kB
JavaScript
import { parseRequest } from "./api-gateway-v2-parse-request";
import { sendResponse } from "./api-gateway-v2-send-response";
import { handleRequest } from "../handle-request";
import { onUnhandledRequestDefault } from "../on-unhandled-request-default";
import { OAuthApp } from "../../index";
async function onUnhandledRequestDefaultAWSAPIGatewayV2(event) {
const request = parseRequest(event);
const response = onUnhandledRequestDefault(request);
return sendResponse(response);
}
function createAWSLambdaAPIGatewayV2Handler(app, {
pathPrefix,
onUnhandledRequest
} = {}) {
if (onUnhandledRequest) {
app.octokit.log.warn(
"[@octokit/oauth-app] `onUnhandledRequest` is deprecated and will be removed from the next major version."
);
}
onUnhandledRequest ??= onUnhandledRequestDefaultAWSAPIGatewayV2;
return async function(event) {
const request = parseRequest(event);
const response = await handleRequest(app, { pathPrefix }, request);
return response ? sendResponse(response) : onUnhandledRequest(event);
};
}
export {
createAWSLambdaAPIGatewayV2Handler
};