UNPKG

naga-audit-service

Version:

A comprehensive audit service library for NestJS applications with MongoDB support

63 lines 2.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AuditServiceStarter = void 0; exports.startAuditService = startAuditService; exports.stopAuditService = stopAuditService; const config_1 = require("./config"); class AuditServiceStarter { constructor() { this.isStarted = false; } static getInstance() { if (!AuditServiceStarter.instance) { AuditServiceStarter.instance = new AuditServiceStarter(); } return AuditServiceStarter.instance; } async start(config) { if (this.isStarted) { console.log('Audit service is already started'); return; } try { console.log('🚀 Starting Noukha Audit Log Service...'); await config_1.NoukhaAuditLog.configure(config); this.isStarted = true; console.log('🎉 Noukha Audit Log Service started successfully!'); } catch (error) { console.error('💥 Failed to start Noukha Audit Log Service:', error); throw error; } } async stop() { if (!this.isStarted) { console.log('Audit service is not running'); return; } try { console.log('🛑 Stopping Noukha Audit Log Service...'); this.isStarted = false; } catch (error) { console.error('💥 Error stopping service:', error); throw error; } } isServiceRunning() { return this.isStarted && config_1.NoukhaAuditLog.isServiceReady(); } async waitForService() { return config_1.NoukhaAuditLog.waitForReady(); } } exports.AuditServiceStarter = AuditServiceStarter; async function startAuditService(config) { const starter = AuditServiceStarter.getInstance(); await starter.start(config); } async function stopAuditService() { const starter = AuditServiceStarter.getInstance(); await starter.stop(); } //# sourceMappingURL=service-starter.js.map