UNPKG

convert-lambda-to-express

Version:

Wrapper to run lambda on express. Works great for running lambdas as an express server during development but is production ready. Developed to work in conjunction with matthewkeil/full-stack-pattern cdk construct.

25 lines (24 loc) 872 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isHttpMethod = exports.httpMethods = exports.TimeoutError = exports.generateRandomHex = void 0; const hexChars = '0123456789abcdef'.split(''); function generateRandomHex(length) { let hexVal = ''; for (let i = 0; i < length; i++) { hexVal += hexChars[Math.floor(Math.random() * hexChars.length)]; } return hexVal; } exports.generateRandomHex = generateRandomHex; class TimeoutError extends Error { constructor(m) { super(m); this.name = 'TimeoutError'; } } exports.TimeoutError = TimeoutError; exports.httpMethods = ['GET', 'PUT', 'POST', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS']; function isHttpMethod(value) { return typeof value === 'string' && exports.httpMethods.includes(value.toUpperCase()); } exports.isHttpMethod = isHttpMethod;