import { Injectable, Logger } from '@nestjs/common'; import nano from 'nano'; import configuration from '../configs/app'; const config = configuration(); @Injectable() export class CouchDb { private static logger = new Logger(CouchDb.name); private static couchdb: nano.ServerScope | null = null; static getCouchDb(): nano.ServerScope { if (CouchDb.couchdb) { return CouchDb.couchdb; } const n = nano(config.couchDbUrl); CouchDb.logger.log(`CouchDb connected by url ${config.couchDbUrl} ...`); CouchDb.couchdb = n; return CouchDb.couchdb; } }