UNPKG

@nodeboot/ghost-server

Version:

Node-Boot Ghost Server for Pure IoC Applications. Suitable for Auto-configuration testing, background jobs, etc

67 lines 2.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GhostServer = void 0; const context_1 = require("@nodeboot/context"); const core_1 = require("@nodeboot/core"); const engine_1 = require("@nodeboot/engine"); const driver_1 = require("../driver"); class GhostServer extends core_1.BaseServer { driver; constructor() { super("no-server"); this.driver = new driver_1.GhostDriver(); } async run(additionalConfig) { const context = context_1.ApplicationContext.get(); // Configure server - in this case the 'app' is the driver itself. await super.configure(this.driver, this.driver, additionalConfig); if (context.applicationAdapter) { const engineOptions = context.applicationAdapter.bind(context.diOptions?.iocContainer); // Create NodeBoot server engine with our driver and engine options engine_1.NodeBootToolkit.createServer(this.driver, engineOptions); } else { throw new Error("Error starting Application. Please enable NodeBoot application using @NodeBootApplication"); } return this; } /** * No real HTTP listening here. * For testing, CLI, or auto-configuration, this resolves immediately. */ async listen() { this.logger.info("NoServer running in non-HTTP mode (CLI / test / auto-configuration)."); super.started(); return this.appView(); } /** * For CLI or tests, simulate shutting down any resources. */ async close() { this.logger.info("NoServer stopped."); super.stopped(); } /** * Provide access to the driver to manually execute actions with mock requests. */ getDriver() { return this.driver; } async configureHttpLogging() { // If you want to add any HTTP logging hooks or CLI-specific logging here, do it. } getHttpServer() { // No real HTTP server in this driver, so we return a dummy server. return {}; } getFramework() { // No specific framework in this driver, so we return undefined. return undefined; } getRouter() { // No specific router in this driver, so we return undefined. return undefined; } } exports.GhostServer = GhostServer; //# sourceMappingURL=GhostServer.js.map