UNPKG

@mwcp/paradedb

Version:

ParadeDb JavaScript Client Library Component for Midway.js

101 lines 4.05 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import assert from 'node:assert'; import { App, Configuration, Inject, Logger, MidwayEnvironmentService, MidwayInformationService, MidwayWebRouterService, } from '@midwayjs/core'; import { TraceInit } from '@mwcp/otel'; import { MConfig, deleteRouter, } from '@mwcp/share'; import * as DefaultConfig from './config/config.default.js'; import * as LocalConfig from './config/config.local.js'; import * as UnittestConfig from './config/config.unittest.js'; import { useComponents } from './imports.js'; import { ParadeDbManager } from './lib/paradedb-manager.js'; import { ConfigKey } from './lib/types.js'; let AutoConfiguration = class AutoConfiguration { app; environmentService; informationService; webRouterService; logger; config; mwConfig; dbSourceManager; async onConfigLoad() { /* c8 ignore next 3 */ if (!this.config.enableDefaultRoute) { await deleteRouter(`/_${ConfigKey.namespace}`, this.webRouterService); } else if (this.mwConfig.ignore) { this.mwConfig.ignore.push(new RegExp(`/_${ConfigKey.namespace}/.+`, 'u')); } } async onReady(container) { void container; assert(this.app, 'this.app undefined. If start for development, please set env first like `export MIDWAY_SERVER_ENV=local`'); } async onStop(container) { void container; this.logger.info(`[${ConfigKey.componentName}] stopping`); await this.dbSourceManager.stop(); this.logger.info(`[${ConfigKey.componentName}] stopped`); } }; __decorate([ App(), __metadata("design:type", Object) ], AutoConfiguration.prototype, "app", void 0); __decorate([ Inject(), __metadata("design:type", MidwayEnvironmentService) ], AutoConfiguration.prototype, "environmentService", void 0); __decorate([ Inject(), __metadata("design:type", MidwayInformationService) ], AutoConfiguration.prototype, "informationService", void 0); __decorate([ Inject(), __metadata("design:type", MidwayWebRouterService) ], AutoConfiguration.prototype, "webRouterService", void 0); __decorate([ Logger(), __metadata("design:type", Object) ], AutoConfiguration.prototype, "logger", void 0); __decorate([ MConfig(ConfigKey.config), __metadata("design:type", Object) ], AutoConfiguration.prototype, "config", void 0); __decorate([ MConfig(ConfigKey.middlewareConfig), __metadata("design:type", Object) ], AutoConfiguration.prototype, "mwConfig", void 0); __decorate([ Inject(), __metadata("design:type", ParadeDbManager) ], AutoConfiguration.prototype, "dbSourceManager", void 0); __decorate([ TraceInit({ namespace: ConfigKey.namespace }), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise) ], AutoConfiguration.prototype, "onReady", null); AutoConfiguration = __decorate([ Configuration({ namespace: ConfigKey.namespace, importConfigs: [ { default: DefaultConfig, local: LocalConfig, unittest: UnittestConfig, }, ], imports: useComponents, }) ], AutoConfiguration); export { AutoConfiguration }; //# sourceMappingURL=configuration.js.map