Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 1x 1x | 'use strict'; import mongoose, {Connection} from 'mongoose'; export default class MongoDBConnector { public static async init(mongoDbUri: string): Promise<Connection> { Iif (!this._connection) { await mongoose.connect(mongoDbUri, {minPoolSize: 20, maxPoolSize: 100}); mongoose.connection.on('connecting', () => console.log('[@owservable] -> MongoDB connecting to', mongoDbUri, '...')); mongoose.connection.on('connected', () => console.log('[@owservable] -> MongoDB connected to', mongoDbUri)); mongoose.connection.on('open', () => console.log('[@owservable] -> MongoDB opened connection to', mongoDbUri)); mongoose.connection.on('error', console.error.bind(console, '[@owservable] -> MongoDB connection error:')); mongoose.connection.on('disconnecting', () => console.error('[@owservable] -> MongoDB disconnecting from', mongoDbUri, '...')); mongoose.connection.on('disconnected', () => console.error('[@owservable] -> MongoDB disconnected from', mongoDbUri)); mongoose.connection.on('close', () => console.error('[@owservable] -> MongoDB closed connection to', mongoDbUri)); this._connection = mongoose.connection; } return this._connection; } public static get connection(): Connection { return this._connection; } private static _connection: Connection; private constructor() {} } |