@midwayjs/faas
Version:
Midway Framework for FaaS (Function as a Service)
63 lines • 2.15 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractBootstrapStarter = void 0;
const core_1 = require("@midwayjs/core");
const path_1 = require("path");
const core_2 = require("@midwayjs/core");
class AbstractBootstrapStarter {
options;
applicationContext;
framework;
constructor(options = {}) {
this.options = options;
}
startedExports;
getApplicationContext() {
return this.applicationContext;
}
async close() {
await this.onClose();
}
getBaseDir() {
if (this.options.baseDir) {
return this.options.baseDir;
}
if ((0, core_2.isTypeScriptEnvironment)()) {
return (0, path_1.join)(this.options.appDir, 'src');
}
else {
return (0, path_1.join)(this.options.appDir, 'dist');
}
}
start(options) {
if (!this.startedExports) {
this.options = Object.assign(this.options, options);
if (this.options.appDir && !this.options.baseDir) {
this.options.baseDir = this.getBaseDir();
}
this.startedExports = this.onStart();
}
if (this.startedExports) {
if (options) {
// 单测时这里要再覆盖一次,不然外面的 options 传不进来
this.options = Object.assign(this.options, options);
}
this.startedExports['getStarter'] = () => {
return this;
};
return this.startedExports;
}
}
async initFramework(bootstrapOptions = {}) {
// init midway
this.applicationContext =
await (0, core_1.initializeGlobalApplicationContext)(bootstrapOptions);
const midwayFrameworkService = this.applicationContext.get(core_1.MidwayFrameworkService);
this.framework = midwayFrameworkService.getMainFramework();
}
createDefaultMockHttpEvent() { }
createDefaultMockEvent() { }
createDefaultMockContext() { }
}
exports.AbstractBootstrapStarter = AbstractBootstrapStarter;
//# sourceMappingURL=starter.js.map