mirror of
https://github.com/TheBinaryNinja/tvapp2.git
synced 2026-06-12 15:05:41 -04:00
initial push from external dev branches
This commit is contained in:
24
server/dist/db.js
vendored
Normal file
24
server/dist/db.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import mongoose from 'mongoose';
|
||||
export async function connect(uri) {
|
||||
mongoose.connection.on('error', (err) => {
|
||||
console.error('[mongo] connection error:', err.message);
|
||||
});
|
||||
mongoose.connection.on('disconnected', () => {
|
||||
console.warn('[mongo] disconnected');
|
||||
});
|
||||
mongoose.connection.on('reconnected', () => {
|
||||
console.info('[mongo] reconnected');
|
||||
});
|
||||
await mongoose.connect(uri, {
|
||||
serverSelectionTimeoutMS: 5000,
|
||||
maxPoolSize: 10,
|
||||
});
|
||||
console.info('[mongo] connected');
|
||||
}
|
||||
export async function disconnect() {
|
||||
await mongoose.disconnect();
|
||||
}
|
||||
export function isConnected() {
|
||||
return mongoose.connection.readyState === 1;
|
||||
}
|
||||
//# sourceMappingURL=db.js.map
|
||||
Reference in New Issue
Block a user