lambda-request-handler
Advanced tools
Comparing version 0.5.1-alpha1 to 0.5.1
@@ -1,4 +0,4 @@ | ||
import { InProcessRequestOptions } from 'in-process-request'; | ||
import { APIGatewayEvent, LambdaContext } from './types'; | ||
declare const eventToRequestOptions: (event: APIGatewayEvent, ctx?: LambdaContext | undefined) => InProcessRequestOptions; | ||
import { type InjectOptions } from "light-my-request"; | ||
import { APIGatewayEvent, LambdaContext } from "./types"; | ||
declare const eventToRequestOptions: (event: APIGatewayEvent, ctx?: LambdaContext) => InjectOptions; | ||
export default eventToRequestOptions; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const url = __importStar(require("url")); | ||
const getValuesFromStringAndMultiString = (stringMap, multiStringMap, lcKeys = true) => { | ||
const retVal = {}; | ||
const singleMap = stringMap || {}; | ||
Object.keys(singleMap).forEach(k => { | ||
Object.keys(singleMap).forEach((k) => { | ||
retVal[lcKeys ? k.toLowerCase() : k] = singleMap[k]; | ||
}); | ||
const multiMap = multiStringMap || {}; | ||
Object.keys(multiMap).forEach(k => { | ||
Object.keys(multiMap).forEach((k) => { | ||
// get the last value | ||
@@ -43,22 +23,22 @@ retVal[lcKeys ? k.toLowerCase() : k] = multiMap[k][multiMap[k].length - 1]; | ||
if (Array.isArray(event.cookies)) { | ||
headers['cookie'] = event.cookies.join('; '); | ||
headers["cookie"] = event.cookies.join("; "); | ||
} | ||
if (ctx) { | ||
headers['x-aws-lambda-request-id'] = ctx.awsRequestId; | ||
headers["x-aws-lambda-request-id"] = ctx.awsRequestId; | ||
} | ||
if ((_a = event.requestContext) === null || _a === void 0 ? void 0 : _a.elb) { | ||
//load balancer request - it has the client ip in x-forwarded-for header | ||
if (typeof headers['x-forwarded-for'] === 'string') { | ||
const ips = headers['x-forwarded-for'].split(',').map(ip => ip.trim()); | ||
if (typeof headers["x-forwarded-for"] === "string") { | ||
const ips = headers["x-forwarded-for"].split(",").map((ip) => ip.trim()); | ||
remoteAddress = ips.splice(-1, 1)[0]; | ||
headers['x-forwarded-for'] = ips.join(', '); | ||
ssl = headers['x-forwarded-proto'] === 'https'; | ||
headers["x-forwarded-for"] = ips.join(", "); | ||
ssl = headers["x-forwarded-proto"] === "https"; | ||
if (ips.length === 0) { | ||
delete headers['x-forwarded-for']; | ||
delete headers['x-forwarded-port']; | ||
delete headers['x-forwarded-proto']; | ||
delete headers["x-forwarded-for"]; | ||
delete headers["x-forwarded-port"]; | ||
delete headers["x-forwarded-proto"]; | ||
} | ||
} | ||
//elb doesn't uri decode query string params | ||
Object.keys(queryStringParams).forEach(k => { | ||
Object.keys(queryStringParams).forEach((k) => { | ||
queryStringParams[k] = decodeURIComponent(queryStringParams[k]); | ||
@@ -70,6 +50,7 @@ }); | ||
ssl = true; | ||
const remoteAddressList = ((_c = (_b = event.requestContext) === null || _b === void 0 ? void 0 : _b.identity) === null || _c === void 0 ? void 0 : _c.sourceIp) || ((_e = (_d = event.requestContext) === null || _d === void 0 ? void 0 : _d.http) === null || _e === void 0 ? void 0 : _e.sourceIp); | ||
const remoteAddressList = ((_c = (_b = event.requestContext) === null || _b === void 0 ? void 0 : _b.identity) === null || _c === void 0 ? void 0 : _c.sourceIp) || | ||
((_e = (_d = event.requestContext) === null || _d === void 0 ? void 0 : _d.http) === null || _e === void 0 ? void 0 : _e.sourceIp); | ||
if (remoteAddressList) { | ||
// HTTP API includes the full x-forwarder for chain here and the remote ip is the last element | ||
const items = remoteAddressList.split(',').map(s => s.trim()); | ||
const items = remoteAddressList.split(",").map((s) => s.trim()); | ||
remoteAddress = items[items.length - 1]; | ||
@@ -80,3 +61,3 @@ } | ||
let path = event.path; | ||
if (typeof ((_f = event.requestContext) === null || _f === void 0 ? void 0 : _f.http) === 'object') { | ||
if (typeof ((_f = event.requestContext) === null || _f === void 0 ? void 0 : _f.http) === "object") { | ||
method = event.requestContext.http.method; | ||
@@ -86,10 +67,13 @@ path = event.requestContext.http.path; | ||
return { | ||
method, | ||
path: url.format({ pathname: path, query: queryStringParams }), | ||
method: (method || "get"), | ||
path: { | ||
pathname: path, | ||
query: queryStringParams, | ||
protocol: ssl ? "https" : "http", | ||
}, | ||
headers: headers, | ||
body: Buffer.from(event.body || '', event.isBase64Encoded ? 'base64' : 'utf8'), | ||
ssl, | ||
remoteAddress | ||
payload: Buffer.from(event.body || "", event.isBase64Encoded ? "base64" : "utf8"), | ||
remoteAddress, | ||
}; | ||
}; | ||
exports.default = eventToRequestOptions; |
@@ -1,4 +0,4 @@ | ||
import { OutgoingHttpHeaders } from 'http'; | ||
import { LambdaResponseHeaders } from './types'; | ||
import { OutgoingHttpHeaders } from "http"; | ||
import { LambdaResponseHeaders } from "./types"; | ||
declare const fixResponseHeaders: (headers: OutgoingHttpHeaders, supportMultiHeaders: boolean, supportCookies: boolean) => LambdaResponseHeaders; | ||
export default fixResponseHeaders; |
@@ -11,7 +11,7 @@ "use strict"; | ||
let cookies = undefined; | ||
Object.keys(headers).forEach(k => { | ||
Object.keys(headers).forEach((k) => { | ||
if (Array.isArray(headers[k])) { | ||
const values = headers[k]; | ||
multiValueHeaders[k] = values; | ||
if (k === 'set-cookie') { | ||
if (k === "set-cookie") { | ||
if (supportCookies) { | ||
@@ -27,3 +27,3 @@ cookies = values; | ||
else { | ||
singleValueHeaders[k] = values.join(','); | ||
singleValueHeaders[k] = values.join(","); | ||
} | ||
@@ -37,12 +37,12 @@ } | ||
}); | ||
if (singleValueHeaders['transfer-encoding'] === 'chunked') { | ||
delete singleValueHeaders['transfer-encoding']; | ||
if (singleValueHeaders["transfer-encoding"] === "chunked") { | ||
delete singleValueHeaders["transfer-encoding"]; | ||
} | ||
if (multiValueHeaders['transfer-encoding']) { | ||
const filtered = multiValueHeaders['transfer-encoding'].filter(v => v !== 'chunked'); | ||
if (multiValueHeaders["transfer-encoding"]) { | ||
const filtered = multiValueHeaders["transfer-encoding"].filter((v) => v !== "chunked"); | ||
if (filtered.length > 0) { | ||
multiValueHeaders['transfer-encoding'] = filtered; | ||
multiValueHeaders["transfer-encoding"] = filtered; | ||
} | ||
else { | ||
delete multiValueHeaders['transfer-encoding']; | ||
delete multiValueHeaders["transfer-encoding"]; | ||
} | ||
@@ -49,0 +49,0 @@ } |
/// <reference types="node" /> | ||
import { RequestListener } from 'http'; | ||
import * as apigw from './types'; | ||
import { RequestListener } from "http"; | ||
import * as apigw from "./types"; | ||
declare namespace handler { | ||
@@ -17,4 +17,4 @@ type APIGatewayEvent = apigw.APIGatewayEvent; | ||
nestHandler: (nestApp: any) => Promise<any>; | ||
fastifyHandler: (fastifyBuilder: (options: object) => any) => (options: object) => Promise<RequestListener>; | ||
fastifyHandler: (fastifyBuilder: (options: object) => any) => (options: object) => Promise<RequestListener<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>>; | ||
}; | ||
export = handler; |
@@ -17,5 +17,6 @@ "use strict"; | ||
const response_1 = require("./response"); | ||
; | ||
const light_my_request_1 = require("light-my-request"); | ||
const eventHasMultiValueHeaders = (event) => { | ||
return event.multiValueHeaders !== null && typeof event.multiValueHeaders === 'object'; | ||
return (event.multiValueHeaders !== null && | ||
typeof event.multiValueHeaders === "object"); | ||
}; | ||
@@ -26,16 +27,15 @@ const eventSupportsCookies = (event) => { | ||
const handlerBuilder = (appFn) => { | ||
let appHandler; | ||
let dispatch; | ||
return (event, ctx) => __awaiter(void 0, void 0, void 0, function* () { | ||
if (!appHandler) { | ||
const resolvedApp = yield appFn(); | ||
appHandler = in_process_request_1.default(resolvedApp); | ||
if (!dispatch) { | ||
dispatch = yield appFn(); | ||
} | ||
try { | ||
const reqOptions = eventToRequestOptions_1.default(event, ctx); | ||
const mockResponse = yield appHandler(reqOptions); | ||
return response_1.inProcessResponseToLambdaResponse(mockResponse, eventHasMultiValueHeaders(event), eventSupportsCookies(event)); | ||
const reqOptions = (0, eventToRequestOptions_1.default)(event, ctx); | ||
const mockResponse = yield (0, light_my_request_1.inject)(dispatch, reqOptions); | ||
return (0, response_1.inProcessResponseToLambdaResponse)(mockResponse, eventHasMultiValueHeaders(event), eventSupportsCookies(event)); | ||
} | ||
catch (e) { | ||
console.error(e); | ||
return response_1.errorResponse(); | ||
return (0, response_1.errorResponse)(); | ||
} | ||
@@ -42,0 +42,0 @@ }); |
@@ -1,4 +0,4 @@ | ||
import { InProcessResponse } from 'in-process-request'; | ||
import { LambdaResponse } from './types'; | ||
export declare const inProcessResponseToLambdaResponse: (response: InProcessResponse, supportMultiHeaders: boolean, supportCookies: boolean) => LambdaResponse; | ||
import { LambdaResponse } from "./types"; | ||
import { Response } from "light-my-request"; | ||
export declare const inProcessResponseToLambdaResponse: (response: Response, supportMultiHeaders: boolean, supportCookies: boolean) => LambdaResponse; | ||
export declare const errorResponse: () => LambdaResponse; |
@@ -9,27 +9,36 @@ "use strict"; | ||
const isutf8_1 = __importDefault(require("isutf8")); | ||
exports.inProcessResponseToLambdaResponse = (response, supportMultiHeaders, supportCookies) => { | ||
const inProcessResponseToLambdaResponse = (response, supportMultiHeaders, supportCookies) => { | ||
const encoding = getEncoding(response); | ||
return Object.assign({ statusCode: response.statusCode, body: response.body.toString(encoding), isBase64Encoded: encoding === 'base64' }, fixResponseHeaders_1.default(response.headers, supportMultiHeaders, supportCookies)); | ||
return Object.assign({ statusCode: response.statusCode, body: response.rawPayload.toString(encoding), isBase64Encoded: encoding === "base64" }, (0, fixResponseHeaders_1.default)(response.headers, supportMultiHeaders, supportCookies)); | ||
}; | ||
exports.inProcessResponseToLambdaResponse = inProcessResponseToLambdaResponse; | ||
const isUTF8 = (headers) => { | ||
if (headers["content-encoding"]) { | ||
return false; | ||
} | ||
const contentType = headers["content-type"] || ""; | ||
return contentType.match(/charset=(utf-8|"utf-8")$/i) ? true : false; | ||
}; | ||
const getEncoding = (response) => { | ||
// APi Gateway REST API cannot handle html responses encoded as base64 | ||
if (response.isUTF8) { | ||
return 'utf8'; | ||
if (isUTF8(response.headers)) { | ||
return "utf8"; | ||
} | ||
const contentType = (response.headers['content-type'] || '').toLowerCase(); | ||
const isJson = () => contentType.startsWith('application/json'); | ||
const isText = () => contentType.startsWith('text/'); | ||
const contentType = (response.headers["content-type"] || "").toLowerCase(); | ||
const isJson = () => contentType.startsWith("application/json"); | ||
const isText = () => contentType.startsWith("text/"); | ||
const maybeUtf8 = isJson() || isText(); | ||
if (maybeUtf8 && isutf8_1.default(response.body)) { | ||
return 'utf8'; | ||
if (maybeUtf8 && (0, isutf8_1.default)(response.rawPayload)) { | ||
return "utf8"; | ||
} | ||
return 'base64'; | ||
return "base64"; | ||
}; | ||
exports.errorResponse = () => { | ||
const errorResponse = () => { | ||
return { | ||
statusCode: 500, | ||
multiValueHeaders: {}, | ||
body: '', | ||
isBase64Encoded: false | ||
body: "", | ||
isBase64Encoded: false, | ||
}; | ||
}; | ||
exports.errorResponse = errorResponse; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const variations = ["set-cookie", "Set-cookie", "sEt-cookie", "SEt-cookie", "seT-cookie", "SeT-cookie", "sET-cookie", "SET-cookie", "set-Cookie", "Set-Cookie", "sEt-Cookie", "SEt-Cookie", "seT-Cookie", "SeT-Cookie", "sET-Cookie", "SET-Cookie", "set-cOokie", "Set-cOokie", "sEt-cOokie", "SEt-cOokie", "seT-cOokie", "SeT-cOokie", "sET-cOokie", "SET-cOokie", "set-COokie", "Set-COokie", "sEt-COokie", "SEt-COokie", "seT-COokie", "SeT-COokie", "sET-COokie", "SET-COokie", "set-coOkie", "Set-coOkie", "sEt-coOkie", "SEt-coOkie", "seT-coOkie", "SeT-coOkie", "sET-coOkie", "SET-coOkie", "set-CoOkie", "Set-CoOkie", "sEt-CoOkie", "SEt-CoOkie", "seT-CoOkie", "SeT-CoOkie", "sET-CoOkie", "SET-CoOkie", "set-cOOkie", "Set-cOOkie", "sEt-cOOkie", "SEt-cOOkie", "seT-cOOkie", "SeT-cOOkie", "sET-cOOkie", "SET-cOOkie", "set-COOkie", "Set-COOkie", "sEt-COOkie", "SEt-COOkie", "seT-COOkie", "SeT-COOkie", "sET-COOkie", "SET-COOkie", "set-cooKie", "Set-cooKie", "sEt-cooKie", "SEt-cooKie", "seT-cooKie", "SeT-cooKie", "sET-cooKie", "SET-cooKie", "set-CooKie", "Set-CooKie", "sEt-CooKie", "SEt-CooKie", "seT-CooKie", "SeT-CooKie", "sET-CooKie", "SET-CooKie", "set-cOoKie", "Set-cOoKie", "sEt-cOoKie", "SEt-cOoKie", "seT-cOoKie", "SeT-cOoKie", "sET-cOoKie", "SET-cOoKie", "set-COoKie", "Set-COoKie", "sEt-COoKie", "SEt-COoKie", "seT-COoKie", "SeT-COoKie", "sET-COoKie", "SET-COoKie", "set-coOKie", "Set-coOKie", "sEt-coOKie", "SEt-coOKie", "seT-coOKie", "SeT-coOKie", "sET-coOKie", "SET-coOKie", "set-CoOKie", "Set-CoOKie", "sEt-CoOKie", "SEt-CoOKie", "seT-CoOKie", "SeT-CoOKie", "sET-CoOKie", "SET-CoOKie", "set-cOOKie", "Set-cOOKie", "sEt-cOOKie", "SEt-cOOKie", "seT-cOOKie", "SeT-cOOKie", "sET-cOOKie", "SET-cOOKie", "set-COOKie", "Set-COOKie", "sEt-COOKie", "SEt-COOKie", "seT-COOKie", "SeT-COOKie", "sET-COOKie", "SET-COOKie", "set-cookIe", "Set-cookIe", "sEt-cookIe", "SEt-cookIe", "seT-cookIe", "SeT-cookIe", "sET-cookIe", "SET-cookIe", "set-CookIe", "Set-CookIe", "sEt-CookIe", "SEt-CookIe", "seT-CookIe", "SeT-CookIe", "sET-CookIe", "SET-CookIe", "set-cOokIe", "Set-cOokIe", "sEt-cOokIe", "SEt-cOokIe", "seT-cOokIe", "SeT-cOokIe", "sET-cOokIe", "SET-cOokIe", "set-COokIe", "Set-COokIe", "sEt-COokIe", "SEt-COokIe", "seT-COokIe", "SeT-COokIe", "sET-COokIe", "SET-COokIe", "set-coOkIe", "Set-coOkIe", "sEt-coOkIe", "SEt-coOkIe", "seT-coOkIe", "SeT-coOkIe", "sET-coOkIe", "SET-coOkIe", "set-CoOkIe", "Set-CoOkIe", "sEt-CoOkIe", "SEt-CoOkIe", "seT-CoOkIe", "SeT-CoOkIe", "sET-CoOkIe", "SET-CoOkIe", "set-cOOkIe", "Set-cOOkIe", "sEt-cOOkIe", "SEt-cOOkIe", "seT-cOOkIe", "SeT-cOOkIe", "sET-cOOkIe", "SET-cOOkIe", "set-COOkIe", "Set-COOkIe", "sEt-COOkIe", "SEt-COOkIe", "seT-COOkIe", "SeT-COOkIe", "sET-COOkIe", "SET-COOkIe", "set-cooKIe", "Set-cooKIe", "sEt-cooKIe", "SEt-cooKIe", "seT-cooKIe", "SeT-cooKIe", "sET-cooKIe", "SET-cooKIe", "set-CooKIe", "Set-CooKIe", "sEt-CooKIe", "SEt-CooKIe", "seT-CooKIe", "SeT-CooKIe", "sET-CooKIe", "SET-CooKIe", "set-cOoKIe", "Set-cOoKIe", "sEt-cOoKIe", "SEt-cOoKIe", "seT-cOoKIe", "SeT-cOoKIe", "sET-cOoKIe", "SET-cOoKIe", "set-COoKIe", "Set-COoKIe", "sEt-COoKIe", "SEt-COoKIe", "seT-COoKIe", "SeT-COoKIe", "sET-COoKIe", "SET-COoKIe", "set-coOKIe", "Set-coOKIe", "sEt-coOKIe", "SEt-coOKIe", "seT-coOKIe", "SeT-coOKIe", "sET-coOKIe", "SET-coOKIe", "set-CoOKIe", "Set-CoOKIe", "sEt-CoOKIe", "SEt-CoOKIe", "seT-CoOKIe", "SeT-CoOKIe", "sET-CoOKIe", "SET-CoOKIe", "set-cOOKIe", "Set-cOOKIe", "sEt-cOOKIe", "SEt-cOOKIe", "seT-cOOKIe", "SeT-cOOKIe", "sET-cOOKIe", "SET-cOOKIe", "set-COOKIe", "Set-COOKIe", "sEt-COOKIe", "SEt-COOKIe", "seT-COOKIe", "SeT-COOKIe", "sET-COOKIe", "SET-COOKIe", "set-cookiE", "Set-cookiE", "sEt-cookiE", "SEt-cookiE", "seT-cookiE", "SeT-cookiE", "sET-cookiE", "SET-cookiE", "set-CookiE", "Set-CookiE", "sEt-CookiE", "SEt-CookiE", "seT-CookiE", "SeT-CookiE", "sET-CookiE", "SET-CookiE", "set-cOokiE", "Set-cOokiE", "sEt-cOokiE", "SEt-cOokiE", "seT-cOokiE", "SeT-cOokiE", "sET-cOokiE", "SET-cOokiE", "set-COokiE", "Set-COokiE", "sEt-COokiE", "SEt-COokiE", "seT-COokiE", "SeT-COokiE", "sET-COokiE", "SET-COokiE", "set-coOkiE", "Set-coOkiE", "sEt-coOkiE", "SEt-coOkiE", "seT-coOkiE", "SeT-coOkiE", "sET-coOkiE", "SET-coOkiE", "set-CoOkiE", "Set-CoOkiE", "sEt-CoOkiE", "SEt-CoOkiE", "seT-CoOkiE", "SeT-CoOkiE", "sET-CoOkiE", "SET-CoOkiE", "set-cOOkiE", "Set-cOOkiE", "sEt-cOOkiE", "SEt-cOOkiE", "seT-cOOkiE", "SeT-cOOkiE", "sET-cOOkiE", "SET-cOOkiE", "set-COOkiE", "Set-COOkiE", "sEt-COOkiE", "SEt-COOkiE", "seT-COOkiE", "SeT-COOkiE", "sET-COOkiE", "SET-COOkiE", "set-cooKiE", "Set-cooKiE", "sEt-cooKiE", "SEt-cooKiE", "seT-cooKiE", "SeT-cooKiE", "sET-cooKiE", "SET-cooKiE", "set-CooKiE", "Set-CooKiE", "sEt-CooKiE", "SEt-CooKiE", "seT-CooKiE", "SeT-CooKiE", "sET-CooKiE", "SET-CooKiE", "set-cOoKiE", "Set-cOoKiE", "sEt-cOoKiE", "SEt-cOoKiE", "seT-cOoKiE", "SeT-cOoKiE", "sET-cOoKiE", "SET-cOoKiE", "set-COoKiE", "Set-COoKiE", "sEt-COoKiE", "SEt-COoKiE", "seT-COoKiE", "SeT-COoKiE", "sET-COoKiE", "SET-COoKiE", "set-coOKiE", "Set-coOKiE", "sEt-coOKiE", "SEt-coOKiE", "seT-coOKiE", "SeT-coOKiE", "sET-coOKiE", "SET-coOKiE", "set-CoOKiE", "Set-CoOKiE", "sEt-CoOKiE", "SEt-CoOKiE", "seT-CoOKiE", "SeT-CoOKiE", "sET-CoOKiE", "SET-CoOKiE", "set-cOOKiE", "Set-cOOKiE", "sEt-cOOKiE", "SEt-cOOKiE", "seT-cOOKiE", "SeT-cOOKiE", "sET-cOOKiE", "SET-cOOKiE", "set-COOKiE", "Set-COOKiE", "sEt-COOKiE", "SEt-COOKiE", "seT-COOKiE", "SeT-COOKiE", "sET-COOKiE", "SET-COOKiE", "set-cookIE", "Set-cookIE", "sEt-cookIE", "SEt-cookIE", "seT-cookIE", "SeT-cookIE", "sET-cookIE", "SET-cookIE", "set-CookIE", "Set-CookIE", "sEt-CookIE", "SEt-CookIE", "seT-CookIE", "SeT-CookIE", "sET-CookIE", "SET-CookIE", "set-cOokIE", "Set-cOokIE", "sEt-cOokIE", "SEt-cOokIE", "seT-cOokIE", "SeT-cOokIE", "sET-cOokIE", "SET-cOokIE", "set-COokIE", "Set-COokIE", "sEt-COokIE", "SEt-COokIE", "seT-COokIE", "SeT-COokIE", "sET-COokIE", "SET-COokIE", "set-coOkIE", "Set-coOkIE", "sEt-coOkIE", "SEt-coOkIE", "seT-coOkIE", "SeT-coOkIE", "sET-coOkIE", "SET-coOkIE", "set-CoOkIE", "Set-CoOkIE", "sEt-CoOkIE", "SEt-CoOkIE", "seT-CoOkIE", "SeT-CoOkIE", "sET-CoOkIE", "SET-CoOkIE", "set-cOOkIE", "Set-cOOkIE", "sEt-cOOkIE", "SEt-cOOkIE", "seT-cOOkIE", "SeT-cOOkIE", "sET-cOOkIE", "SET-cOOkIE", "set-COOkIE", "Set-COOkIE", "sEt-COOkIE", "SEt-COOkIE", "seT-COOkIE", "SeT-COOkIE", "sET-COOkIE", "SET-COOkIE", "set-cooKIE", "Set-cooKIE", "sEt-cooKIE", "SEt-cooKIE", "seT-cooKIE", "SeT-cooKIE", "sET-cooKIE", "SET-cooKIE", "set-CooKIE", "Set-CooKIE", "sEt-CooKIE", "SEt-CooKIE", "seT-CooKIE", "SeT-CooKIE", "sET-CooKIE", "SET-CooKIE", "set-cOoKIE", "Set-cOoKIE", "sEt-cOoKIE", "SEt-cOoKIE", "seT-cOoKIE", "SeT-cOoKIE", "sET-cOoKIE", "SET-cOoKIE", "set-COoKIE", "Set-COoKIE", "sEt-COoKIE", "SEt-COoKIE", "seT-COoKIE", "SeT-COoKIE", "sET-COoKIE", "SET-COoKIE", "set-coOKIE", "Set-coOKIE", "sEt-coOKIE", "SEt-coOKIE", "seT-coOKIE", "SeT-coOKIE", "sET-coOKIE", "SET-coOKIE", "set-CoOKIE", "Set-CoOKIE", "sEt-CoOKIE", "SEt-CoOKIE", "seT-CoOKIE", "SeT-CoOKIE", "sET-CoOKIE", "SET-CoOKIE", "set-cOOKIE", "Set-cOOKIE", "sEt-cOOKIE", "SEt-cOOKIE", "seT-cOOKIE", "SeT-cOOKIE", "sET-cOOKIE", "SET-cOOKIE", "set-COOKIE", "Set-COOKIE", "sEt-COOKIE", "SEt-COOKIE", "seT-COOKIE", "SeT-COOKIE", "sET-COOKIE", "SET-COOKIE"]; | ||
const variations = [ | ||
"set-cookie", | ||
"Set-cookie", | ||
"sEt-cookie", | ||
"SEt-cookie", | ||
"seT-cookie", | ||
"SeT-cookie", | ||
"sET-cookie", | ||
"SET-cookie", | ||
"set-Cookie", | ||
"Set-Cookie", | ||
"sEt-Cookie", | ||
"SEt-Cookie", | ||
"seT-Cookie", | ||
"SeT-Cookie", | ||
"sET-Cookie", | ||
"SET-Cookie", | ||
"set-cOokie", | ||
"Set-cOokie", | ||
"sEt-cOokie", | ||
"SEt-cOokie", | ||
"seT-cOokie", | ||
"SeT-cOokie", | ||
"sET-cOokie", | ||
"SET-cOokie", | ||
"set-COokie", | ||
"Set-COokie", | ||
"sEt-COokie", | ||
"SEt-COokie", | ||
"seT-COokie", | ||
"SeT-COokie", | ||
"sET-COokie", | ||
"SET-COokie", | ||
"set-coOkie", | ||
"Set-coOkie", | ||
"sEt-coOkie", | ||
"SEt-coOkie", | ||
"seT-coOkie", | ||
"SeT-coOkie", | ||
"sET-coOkie", | ||
"SET-coOkie", | ||
"set-CoOkie", | ||
"Set-CoOkie", | ||
"sEt-CoOkie", | ||
"SEt-CoOkie", | ||
"seT-CoOkie", | ||
"SeT-CoOkie", | ||
"sET-CoOkie", | ||
"SET-CoOkie", | ||
"set-cOOkie", | ||
"Set-cOOkie", | ||
"sEt-cOOkie", | ||
"SEt-cOOkie", | ||
"seT-cOOkie", | ||
"SeT-cOOkie", | ||
"sET-cOOkie", | ||
"SET-cOOkie", | ||
"set-COOkie", | ||
"Set-COOkie", | ||
"sEt-COOkie", | ||
"SEt-COOkie", | ||
"seT-COOkie", | ||
"SeT-COOkie", | ||
"sET-COOkie", | ||
"SET-COOkie", | ||
"set-cooKie", | ||
"Set-cooKie", | ||
"sEt-cooKie", | ||
"SEt-cooKie", | ||
"seT-cooKie", | ||
"SeT-cooKie", | ||
"sET-cooKie", | ||
"SET-cooKie", | ||
"set-CooKie", | ||
"Set-CooKie", | ||
"sEt-CooKie", | ||
"SEt-CooKie", | ||
"seT-CooKie", | ||
"SeT-CooKie", | ||
"sET-CooKie", | ||
"SET-CooKie", | ||
"set-cOoKie", | ||
"Set-cOoKie", | ||
"sEt-cOoKie", | ||
"SEt-cOoKie", | ||
"seT-cOoKie", | ||
"SeT-cOoKie", | ||
"sET-cOoKie", | ||
"SET-cOoKie", | ||
"set-COoKie", | ||
"Set-COoKie", | ||
"sEt-COoKie", | ||
"SEt-COoKie", | ||
"seT-COoKie", | ||
"SeT-COoKie", | ||
"sET-COoKie", | ||
"SET-COoKie", | ||
"set-coOKie", | ||
"Set-coOKie", | ||
"sEt-coOKie", | ||
"SEt-coOKie", | ||
"seT-coOKie", | ||
"SeT-coOKie", | ||
"sET-coOKie", | ||
"SET-coOKie", | ||
"set-CoOKie", | ||
"Set-CoOKie", | ||
"sEt-CoOKie", | ||
"SEt-CoOKie", | ||
"seT-CoOKie", | ||
"SeT-CoOKie", | ||
"sET-CoOKie", | ||
"SET-CoOKie", | ||
"set-cOOKie", | ||
"Set-cOOKie", | ||
"sEt-cOOKie", | ||
"SEt-cOOKie", | ||
"seT-cOOKie", | ||
"SeT-cOOKie", | ||
"sET-cOOKie", | ||
"SET-cOOKie", | ||
"set-COOKie", | ||
"Set-COOKie", | ||
"sEt-COOKie", | ||
"SEt-COOKie", | ||
"seT-COOKie", | ||
"SeT-COOKie", | ||
"sET-COOKie", | ||
"SET-COOKie", | ||
"set-cookIe", | ||
"Set-cookIe", | ||
"sEt-cookIe", | ||
"SEt-cookIe", | ||
"seT-cookIe", | ||
"SeT-cookIe", | ||
"sET-cookIe", | ||
"SET-cookIe", | ||
"set-CookIe", | ||
"Set-CookIe", | ||
"sEt-CookIe", | ||
"SEt-CookIe", | ||
"seT-CookIe", | ||
"SeT-CookIe", | ||
"sET-CookIe", | ||
"SET-CookIe", | ||
"set-cOokIe", | ||
"Set-cOokIe", | ||
"sEt-cOokIe", | ||
"SEt-cOokIe", | ||
"seT-cOokIe", | ||
"SeT-cOokIe", | ||
"sET-cOokIe", | ||
"SET-cOokIe", | ||
"set-COokIe", | ||
"Set-COokIe", | ||
"sEt-COokIe", | ||
"SEt-COokIe", | ||
"seT-COokIe", | ||
"SeT-COokIe", | ||
"sET-COokIe", | ||
"SET-COokIe", | ||
"set-coOkIe", | ||
"Set-coOkIe", | ||
"sEt-coOkIe", | ||
"SEt-coOkIe", | ||
"seT-coOkIe", | ||
"SeT-coOkIe", | ||
"sET-coOkIe", | ||
"SET-coOkIe", | ||
"set-CoOkIe", | ||
"Set-CoOkIe", | ||
"sEt-CoOkIe", | ||
"SEt-CoOkIe", | ||
"seT-CoOkIe", | ||
"SeT-CoOkIe", | ||
"sET-CoOkIe", | ||
"SET-CoOkIe", | ||
"set-cOOkIe", | ||
"Set-cOOkIe", | ||
"sEt-cOOkIe", | ||
"SEt-cOOkIe", | ||
"seT-cOOkIe", | ||
"SeT-cOOkIe", | ||
"sET-cOOkIe", | ||
"SET-cOOkIe", | ||
"set-COOkIe", | ||
"Set-COOkIe", | ||
"sEt-COOkIe", | ||
"SEt-COOkIe", | ||
"seT-COOkIe", | ||
"SeT-COOkIe", | ||
"sET-COOkIe", | ||
"SET-COOkIe", | ||
"set-cooKIe", | ||
"Set-cooKIe", | ||
"sEt-cooKIe", | ||
"SEt-cooKIe", | ||
"seT-cooKIe", | ||
"SeT-cooKIe", | ||
"sET-cooKIe", | ||
"SET-cooKIe", | ||
"set-CooKIe", | ||
"Set-CooKIe", | ||
"sEt-CooKIe", | ||
"SEt-CooKIe", | ||
"seT-CooKIe", | ||
"SeT-CooKIe", | ||
"sET-CooKIe", | ||
"SET-CooKIe", | ||
"set-cOoKIe", | ||
"Set-cOoKIe", | ||
"sEt-cOoKIe", | ||
"SEt-cOoKIe", | ||
"seT-cOoKIe", | ||
"SeT-cOoKIe", | ||
"sET-cOoKIe", | ||
"SET-cOoKIe", | ||
"set-COoKIe", | ||
"Set-COoKIe", | ||
"sEt-COoKIe", | ||
"SEt-COoKIe", | ||
"seT-COoKIe", | ||
"SeT-COoKIe", | ||
"sET-COoKIe", | ||
"SET-COoKIe", | ||
"set-coOKIe", | ||
"Set-coOKIe", | ||
"sEt-coOKIe", | ||
"SEt-coOKIe", | ||
"seT-coOKIe", | ||
"SeT-coOKIe", | ||
"sET-coOKIe", | ||
"SET-coOKIe", | ||
"set-CoOKIe", | ||
"Set-CoOKIe", | ||
"sEt-CoOKIe", | ||
"SEt-CoOKIe", | ||
"seT-CoOKIe", | ||
"SeT-CoOKIe", | ||
"sET-CoOKIe", | ||
"SET-CoOKIe", | ||
"set-cOOKIe", | ||
"Set-cOOKIe", | ||
"sEt-cOOKIe", | ||
"SEt-cOOKIe", | ||
"seT-cOOKIe", | ||
"SeT-cOOKIe", | ||
"sET-cOOKIe", | ||
"SET-cOOKIe", | ||
"set-COOKIe", | ||
"Set-COOKIe", | ||
"sEt-COOKIe", | ||
"SEt-COOKIe", | ||
"seT-COOKIe", | ||
"SeT-COOKIe", | ||
"sET-COOKIe", | ||
"SET-COOKIe", | ||
"set-cookiE", | ||
"Set-cookiE", | ||
"sEt-cookiE", | ||
"SEt-cookiE", | ||
"seT-cookiE", | ||
"SeT-cookiE", | ||
"sET-cookiE", | ||
"SET-cookiE", | ||
"set-CookiE", | ||
"Set-CookiE", | ||
"sEt-CookiE", | ||
"SEt-CookiE", | ||
"seT-CookiE", | ||
"SeT-CookiE", | ||
"sET-CookiE", | ||
"SET-CookiE", | ||
"set-cOokiE", | ||
"Set-cOokiE", | ||
"sEt-cOokiE", | ||
"SEt-cOokiE", | ||
"seT-cOokiE", | ||
"SeT-cOokiE", | ||
"sET-cOokiE", | ||
"SET-cOokiE", | ||
"set-COokiE", | ||
"Set-COokiE", | ||
"sEt-COokiE", | ||
"SEt-COokiE", | ||
"seT-COokiE", | ||
"SeT-COokiE", | ||
"sET-COokiE", | ||
"SET-COokiE", | ||
"set-coOkiE", | ||
"Set-coOkiE", | ||
"sEt-coOkiE", | ||
"SEt-coOkiE", | ||
"seT-coOkiE", | ||
"SeT-coOkiE", | ||
"sET-coOkiE", | ||
"SET-coOkiE", | ||
"set-CoOkiE", | ||
"Set-CoOkiE", | ||
"sEt-CoOkiE", | ||
"SEt-CoOkiE", | ||
"seT-CoOkiE", | ||
"SeT-CoOkiE", | ||
"sET-CoOkiE", | ||
"SET-CoOkiE", | ||
"set-cOOkiE", | ||
"Set-cOOkiE", | ||
"sEt-cOOkiE", | ||
"SEt-cOOkiE", | ||
"seT-cOOkiE", | ||
"SeT-cOOkiE", | ||
"sET-cOOkiE", | ||
"SET-cOOkiE", | ||
"set-COOkiE", | ||
"Set-COOkiE", | ||
"sEt-COOkiE", | ||
"SEt-COOkiE", | ||
"seT-COOkiE", | ||
"SeT-COOkiE", | ||
"sET-COOkiE", | ||
"SET-COOkiE", | ||
"set-cooKiE", | ||
"Set-cooKiE", | ||
"sEt-cooKiE", | ||
"SEt-cooKiE", | ||
"seT-cooKiE", | ||
"SeT-cooKiE", | ||
"sET-cooKiE", | ||
"SET-cooKiE", | ||
"set-CooKiE", | ||
"Set-CooKiE", | ||
"sEt-CooKiE", | ||
"SEt-CooKiE", | ||
"seT-CooKiE", | ||
"SeT-CooKiE", | ||
"sET-CooKiE", | ||
"SET-CooKiE", | ||
"set-cOoKiE", | ||
"Set-cOoKiE", | ||
"sEt-cOoKiE", | ||
"SEt-cOoKiE", | ||
"seT-cOoKiE", | ||
"SeT-cOoKiE", | ||
"sET-cOoKiE", | ||
"SET-cOoKiE", | ||
"set-COoKiE", | ||
"Set-COoKiE", | ||
"sEt-COoKiE", | ||
"SEt-COoKiE", | ||
"seT-COoKiE", | ||
"SeT-COoKiE", | ||
"sET-COoKiE", | ||
"SET-COoKiE", | ||
"set-coOKiE", | ||
"Set-coOKiE", | ||
"sEt-coOKiE", | ||
"SEt-coOKiE", | ||
"seT-coOKiE", | ||
"SeT-coOKiE", | ||
"sET-coOKiE", | ||
"SET-coOKiE", | ||
"set-CoOKiE", | ||
"Set-CoOKiE", | ||
"sEt-CoOKiE", | ||
"SEt-CoOKiE", | ||
"seT-CoOKiE", | ||
"SeT-CoOKiE", | ||
"sET-CoOKiE", | ||
"SET-CoOKiE", | ||
"set-cOOKiE", | ||
"Set-cOOKiE", | ||
"sEt-cOOKiE", | ||
"SEt-cOOKiE", | ||
"seT-cOOKiE", | ||
"SeT-cOOKiE", | ||
"sET-cOOKiE", | ||
"SET-cOOKiE", | ||
"set-COOKiE", | ||
"Set-COOKiE", | ||
"sEt-COOKiE", | ||
"SEt-COOKiE", | ||
"seT-COOKiE", | ||
"SeT-COOKiE", | ||
"sET-COOKiE", | ||
"SET-COOKiE", | ||
"set-cookIE", | ||
"Set-cookIE", | ||
"sEt-cookIE", | ||
"SEt-cookIE", | ||
"seT-cookIE", | ||
"SeT-cookIE", | ||
"sET-cookIE", | ||
"SET-cookIE", | ||
"set-CookIE", | ||
"Set-CookIE", | ||
"sEt-CookIE", | ||
"SEt-CookIE", | ||
"seT-CookIE", | ||
"SeT-CookIE", | ||
"sET-CookIE", | ||
"SET-CookIE", | ||
"set-cOokIE", | ||
"Set-cOokIE", | ||
"sEt-cOokIE", | ||
"SEt-cOokIE", | ||
"seT-cOokIE", | ||
"SeT-cOokIE", | ||
"sET-cOokIE", | ||
"SET-cOokIE", | ||
"set-COokIE", | ||
"Set-COokIE", | ||
"sEt-COokIE", | ||
"SEt-COokIE", | ||
"seT-COokIE", | ||
"SeT-COokIE", | ||
"sET-COokIE", | ||
"SET-COokIE", | ||
"set-coOkIE", | ||
"Set-coOkIE", | ||
"sEt-coOkIE", | ||
"SEt-coOkIE", | ||
"seT-coOkIE", | ||
"SeT-coOkIE", | ||
"sET-coOkIE", | ||
"SET-coOkIE", | ||
"set-CoOkIE", | ||
"Set-CoOkIE", | ||
"sEt-CoOkIE", | ||
"SEt-CoOkIE", | ||
"seT-CoOkIE", | ||
"SeT-CoOkIE", | ||
"sET-CoOkIE", | ||
"SET-CoOkIE", | ||
"set-cOOkIE", | ||
"Set-cOOkIE", | ||
"sEt-cOOkIE", | ||
"SEt-cOOkIE", | ||
"seT-cOOkIE", | ||
"SeT-cOOkIE", | ||
"sET-cOOkIE", | ||
"SET-cOOkIE", | ||
"set-COOkIE", | ||
"Set-COOkIE", | ||
"sEt-COOkIE", | ||
"SEt-COOkIE", | ||
"seT-COOkIE", | ||
"SeT-COOkIE", | ||
"sET-COOkIE", | ||
"SET-COOkIE", | ||
"set-cooKIE", | ||
"Set-cooKIE", | ||
"sEt-cooKIE", | ||
"SEt-cooKIE", | ||
"seT-cooKIE", | ||
"SeT-cooKIE", | ||
"sET-cooKIE", | ||
"SET-cooKIE", | ||
"set-CooKIE", | ||
"Set-CooKIE", | ||
"sEt-CooKIE", | ||
"SEt-CooKIE", | ||
"seT-CooKIE", | ||
"SeT-CooKIE", | ||
"sET-CooKIE", | ||
"SET-CooKIE", | ||
"set-cOoKIE", | ||
"Set-cOoKIE", | ||
"sEt-cOoKIE", | ||
"SEt-cOoKIE", | ||
"seT-cOoKIE", | ||
"SeT-cOoKIE", | ||
"sET-cOoKIE", | ||
"SET-cOoKIE", | ||
"set-COoKIE", | ||
"Set-COoKIE", | ||
"sEt-COoKIE", | ||
"SEt-COoKIE", | ||
"seT-COoKIE", | ||
"SeT-COoKIE", | ||
"sET-COoKIE", | ||
"SET-COoKIE", | ||
"set-coOKIE", | ||
"Set-coOKIE", | ||
"sEt-coOKIE", | ||
"SEt-coOKIE", | ||
"seT-coOKIE", | ||
"SeT-coOKIE", | ||
"sET-coOKIE", | ||
"SET-coOKIE", | ||
"set-CoOKIE", | ||
"Set-CoOKIE", | ||
"sEt-CoOKIE", | ||
"SEt-CoOKIE", | ||
"seT-CoOKIE", | ||
"SeT-CoOKIE", | ||
"sET-CoOKIE", | ||
"SET-CoOKIE", | ||
"set-cOOKIE", | ||
"Set-cOOKIE", | ||
"sEt-cOOKIE", | ||
"SEt-cOOKIE", | ||
"seT-cOOKIE", | ||
"SeT-cOOKIE", | ||
"sET-cOOKIE", | ||
"SET-cOOKIE", | ||
"set-COOKIE", | ||
"Set-COOKIE", | ||
"sEt-COOKIE", | ||
"SEt-COOKIE", | ||
"seT-COOKIE", | ||
"SeT-COOKIE", | ||
"sET-COOKIE", | ||
"SET-COOKIE", | ||
]; | ||
exports.default = variations; |
{ | ||
"name": "lambda-request-handler", | ||
"version": "0.5.1-alpha1", | ||
"version": "0.5.1", | ||
"license": "(MIT OR Apache-2.0)", | ||
"scripts": { | ||
"prettier": "prettier --write .", | ||
"prettier:ci": "prettier --check .", | ||
"precompile": "rm -rf dist", | ||
@@ -41,20 +43,22 @@ "compile": "tsc", | ||
"dependencies": { | ||
"in-process-request": "^0.3.0", | ||
"isutf8": "^3.1.1" | ||
"in-process-request": "^0.3.1", | ||
"isutf8": "^4.0.0", | ||
"light-my-request": "^5.6.1" | ||
}, | ||
"devDependencies": { | ||
"@types/compression": "^1.7.0", | ||
"@types/cookie-parser": "^1.4.2", | ||
"@types/express": "^4.17.8", | ||
"@types/jest": "^26.0.15", | ||
"@types/node": "^14.14.6", | ||
"@types/compression": "^1.7.2", | ||
"@types/cookie-parser": "^1.4.3", | ||
"@types/express": "^4.17.14", | ||
"@types/jest": "^29.2.1", | ||
"@types/node": "^18.11.8", | ||
"compression": "^1.7.4", | ||
"cookie-parser": "^1.4.5", | ||
"ejs": "^3.1.5", | ||
"express": "^4.17.1", | ||
"jest": "^26.6.3", | ||
"ts-jest": "^26.4.3", | ||
"ts-node": "^9.0.0", | ||
"typescript": "^4.0.5" | ||
"cookie-parser": "^1.4.6", | ||
"ejs": "^3.1.8", | ||
"express": "^4.18.2", | ||
"jest": "^29.2.2", | ||
"prettier": "^2.7.1", | ||
"ts-jest": "^29.0.3", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.8.4" | ||
} | ||
} |
106
README.md
@@ -8,14 +8,15 @@ # lambda-request-handler | ||
The list of supported frameworks matches [in-process-request](https://github.com/janaz/in-process-request) | ||
* Express.js v3 | ||
* Express.js v4 | ||
* Express.js v5 | ||
* Apollo Server v2 | ||
* Hapi v19 (only supported in `nodejs12.x` runtime) | ||
* Hapi v20 (only supported in `nodejs12.x` runtime) | ||
* NestJS v7 | ||
* Connect v3 | ||
* Koa v2 | ||
* Polka | ||
* Fastify v3 | ||
- Express.js v3 | ||
- Express.js v4 | ||
- Express.js v5 | ||
- Apollo Server v2 | ||
- Hapi v19 (only supported in `nodejs12.x` runtime) | ||
- Hapi v20 (only supported in `nodejs12.x` runtime) | ||
- NestJS v7 | ||
- Connect v3 | ||
- Koa v2 | ||
- Polka | ||
- Fastify v3 | ||
Inspired by [aws-serverless-express](https://github.com/awslabs/aws-serverless-express) | ||
@@ -26,9 +27,11 @@ | ||
The main differences between this module and `aws-serverless-express` are | ||
* It's using [in-process-request](https://github.com/janaz/in-process-request) module to execute app handlers in-process without having to start background http server | ||
* Simpler setup as it doesn't require managing the internal http server | ||
* Support for applications that require asynchronous setup (for example reading config from network, or decrypting secrets from KMS) | ||
* It's faster, because it doesn't need to pass the request to the internal server through the unix socket | ||
* It's free from issues caused by limits in Node.js http module such as header size limit | ||
- It's using [in-process-request](https://github.com/janaz/in-process-request) module to execute app handlers in-process without having to start background http server | ||
- Simpler setup as it doesn't require managing the internal http server | ||
- Support for applications that require asynchronous setup (for example reading config from network, or decrypting secrets from KMS) | ||
- It's faster, because it doesn't need to pass the request to the internal server through the unix socket | ||
- It's free from issues caused by limits in Node.js http module such as header size limit | ||
The handler supports events from the following sources: | ||
- API Gateway [REST APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-rest-api.html) | ||
@@ -47,4 +50,5 @@ - API Gateway [HTTP APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api.html) | ||
An additional header is injected into the request | ||
* `x-aws-lambda-request-id` - AWS Lambda Request Id | ||
- `x-aws-lambda-request-id` - AWS Lambda Request Id | ||
```sh | ||
@@ -55,2 +59,3 @@ $ npm install lambda-request-handler | ||
### Express.js | ||
```javascript | ||
@@ -82,9 +87,9 @@ const express = require('express') | ||
```javascript | ||
const lambdaRequestHandler = require('lambda-request-handler') | ||
const AWS = require('aws-sdk') | ||
const express = require('express') | ||
const lambdaRequestHandler = require("lambda-request-handler") | ||
const AWS = require("aws-sdk") | ||
const express = require("express") | ||
const createApp = (secret) => { | ||
const app = express(); | ||
app.get('/secret', (req, res) => { | ||
const app = express() | ||
app.get("/secret", (req, res) => { | ||
res.json({ | ||
@@ -98,13 +103,14 @@ secret: secret, | ||
const kms = new AWS.KMS() | ||
const data = await kms.decrypt({ | ||
CiphertextBlob: Buffer.from(process.env.ENCRYPTED_SECRET, 'base64') | ||
}).promise() | ||
const secret = data.Plaintext.toString('ascii') | ||
return createApp(secret); | ||
}; | ||
const data = await kms | ||
.decrypt({ | ||
CiphertextBlob: Buffer.from(process.env.ENCRYPTED_SECRET, "base64"), | ||
}) | ||
.promise() | ||
const secret = data.Plaintext.toString("ascii") | ||
return createApp(secret) | ||
} | ||
const handler = lambdaRequestHandler.deferred(myAppPromise); | ||
const handler = lambdaRequestHandler.deferred(myAppPromise) | ||
module.exports = { handler } | ||
``` | ||
@@ -117,4 +123,4 @@ | ||
```javascript | ||
const Hapi = require('@hapi/hapi') | ||
const lambdaRequestHandler = require('lambda-request-handler') | ||
const Hapi = require("@hapi/hapi") | ||
const lambdaRequestHandler = require("lambda-request-handler") | ||
@@ -126,12 +132,12 @@ // create custom listener for Hapi | ||
const server = Hapi.server({ | ||
listener: myListener | ||
}); | ||
listener: myListener, | ||
}) | ||
server.route({ | ||
method: 'GET', | ||
path: '/', | ||
method: "GET", | ||
path: "/", | ||
handler: (_request: any, _h: any) => { | ||
return 'Hello World!'; | ||
} | ||
}); | ||
return "Hello World!" | ||
}, | ||
}) | ||
@@ -143,5 +149,5 @@ const myAppPromise = async () => { | ||
return myListener.handler | ||
}; | ||
} | ||
const handler = lambdaRequestHandler.deferred(myAppPromise); | ||
const handler = lambdaRequestHandler.deferred(myAppPromise) | ||
@@ -158,7 +164,7 @@ module.exports = { handler } | ||
```typescript | ||
import lambdaRequestHandler from 'lambda-request-handler' | ||
import lambdaRequestHandler from "lambda-request-handler" | ||
import { NestFactory } from '@nestjs/core'; | ||
import { Module, Get, Controller } from '@nestjs/common'; | ||
import { NestExpressApplication } from '@nestjs/platform-express'; | ||
import { NestFactory } from "@nestjs/core" | ||
import { Module, Get, Controller } from "@nestjs/common" | ||
import { NestExpressApplication } from "@nestjs/platform-express" | ||
@@ -169,3 +175,3 @@ @Controller() | ||
render() { | ||
return { hello: 'world' }; | ||
return { hello: "world" } | ||
} | ||
@@ -181,10 +187,10 @@ } | ||
const getApp = async () => { | ||
const app = await NestFactory.create<NestExpressApplication>(AppModule); | ||
const app = await NestFactory.create<NestExpressApplication>(AppModule) | ||
return await lambdaRequestHandler.nestHandler(app); | ||
return await lambdaRequestHandler.nestHandler(app) | ||
} | ||
const handler = lambdaRequestHandler.deferred(getApp); | ||
const handler = lambdaRequestHandler.deferred(getApp) | ||
exports = { handler } | ||
module.exports = { handler } | ||
``` | ||
@@ -191,0 +197,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
30895
819
210
3
14
1
+ Addedlight-my-request@^5.6.1
+ Addedcookie@0.7.2(transitive)
+ Addedisutf8@4.0.1(transitive)
+ Addedlight-my-request@5.14.0(transitive)
+ Addedprocess-warning@3.0.0(transitive)
+ Addedset-cookie-parser@2.7.1(transitive)
- Removedisutf8@3.1.1(transitive)
Updatedin-process-request@^0.3.1
Updatedisutf8@^4.0.0