UNPKG

agenda-admin

Version:
33 lines (32 loc) 1.14 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.setAgendaInstance = exports.getAgendaInstance = void 0; const agenda_1 = __importDefault(require("agenda")); let agendaInstance; const getAgendaInstance = () => { if (!agendaInstance) { if (!process.env.CONNECTION_STRING) { throw new Error('No mongoDB connection string provided!'); } agendaInstance = new agenda_1.default({ db: { address: process.env.CONNECTION_STRING, collection: process.env.COLLECTION, }, }, (error) => { if (error) { console.error('Unable to connect to the database: ' + error.message); process.exit(1); } }); } return agendaInstance; }; exports.getAgendaInstance = getAgendaInstance; const setAgendaInstance = (newInstance) => { agendaInstance = newInstance; }; exports.setAgendaInstance = setAgendaInstance;