@studyportals/sp-r2d2
Version:
A framework that contains various components used when developing projects that will be deployed via AWS λ.
51 lines • 2.29 kB
JavaScript
;
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.BaseBootstrapper = void 0;
class BaseBootstrapper {
get process() {
return process;
}
constructor(responseSender) {
this.responseSender = responseSender;
}
bootstrap() {
return __awaiter(this, void 0, void 0, function* () {
this.installGlobalUncaughtErrorHandlers();
if (!BaseBootstrapper.ENVIRONMENT_BOOTSTRAPPED) {
yield this.configureEnvironment();
BaseBootstrapper.ENVIRONMENT_BOOTSTRAPPED = true;
}
yield this.configureInstance();
});
}
cleanup() {
return __awaiter(this, void 0, void 0, function* () { });
}
configureEnvironment() {
return __awaiter(this, void 0, void 0, function* () { });
}
configureInstance() {
return __awaiter(this, void 0, void 0, function* () { });
}
installGlobalUncaughtErrorHandlers() {
this.process.removeAllListeners('uncaughtException');
this.process.removeAllListeners('unhandledRejection');
this.process.on('uncaughtException', (e) => this.handleUncaughtError(e));
this.process.on('unhandledRejection', (e) => this.handleUncaughtError(e));
}
handleUncaughtError(e) {
const error = e instanceof Error ? e : new Error(JSON.stringify(e));
return this.responseSender.sendUncaughtError(error);
}
}
exports.BaseBootstrapper = BaseBootstrapper;
//# sourceMappingURL=base-bootstrapper.class.js.map