UNPKG

lemon-core

Version:
103 lines 4.58 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (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 __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; 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; }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.FunctionsModule = exports._$web = exports.FunctionWEBHandler = void 0; /** * `cores/lambda/index.tx` * - lambda services for serverless micro-service. * * * @author Ian Kim <ian@lemoncloud.io> * @date 2023-10-30 initial version * * @copyright (C) lemoncloud.io 2023 - All Rights Reserved. */ const engine_1 = require("../../engine/"); //! export default __exportStar(require("./functions-handler"), exports); //! export core classes var functions_web_handler_1 = require("./functions-web-handler"); Object.defineProperty(exports, "FunctionWEBHandler", { enumerable: true, get: function () { return functions_web_handler_1.FunctionWEBHandler; } }); //! export by group const _$web = __importStar(require("./functions-web-handler")); exports._$web = _$web; //! import default with named. const functions_handler_1 = require("./functions-handler"); const functions_web_handler_2 = require("./functions-web-handler"); /** * class: `LambdaModule` * - default module */ class FunctionsModule { constructor(engine) { //! module setting. this.getModuleName = () => 'functions'; this.engine = engine || engine_1.$engine; // use input engine or global. if (this.engine) this.engine.register(this); //! make default lambda-handler to initialize engine properly. const thiz = this; const functions = new (class extends functions_handler_1.FunctionHandler { handle(ctx, req) { const _super = Object.create(null, { handle: { get: () => super.handle } }); return __awaiter(this, void 0, void 0, function* () { return thiz.engine.initialize().then(() => _super.handle.call(this, ctx, req)); }); } })(); this.functions = functions; this.web = new functions_web_handler_2.FunctionWEBHandler(functions, true); } initModule(level) { return __awaiter(this, void 0, void 0, function* () { // it should wait until config-module is ready. const $conf = this.engine.module('config'); if (level === undefined) { return $conf ? (yield $conf.initModule()) + 1 : 1; } //console.info(`! LambdaModule.init()..`); if ($conf) this.functions.config = $conf.config; }); } } exports.FunctionsModule = FunctionsModule; //! create default instance, then export as default. exports.default = new FunctionsModule(); //# sourceMappingURL=index.js.map