@marblejs/serverless
Version:
Run Marble.js as a serverless function
20 lines (19 loc) • 840 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@marblejs/core");
var ProxyType;
(function (ProxyType) {
ProxyType["AWS"] = "aws";
})(ProxyType = exports.ProxyType || (exports.ProxyType = {}));
exports.createLambda = ({ httpListener, type, dependencies = [], proxyOptions }) => {
const context = core_1.registerAll([...dependencies])(core_1.createContext());
const app = httpListener.run(context);
switch (type) {
case ProxyType.AWS:
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { createAwsLambdaHandler } = require('./+awsLambda');
return createAwsLambdaHandler(app, proxyOptions);
default:
throw new Error(`Invalid type specified. Expected: ${Object.values(ProxyType)}`);
}
};
;