Florian Bouillon 4cd2a365ae log connection string
Signed-off-by: Avior <github@avior.me>
2023-06-22 01:14:53 +02:00

20 lines
496 B
TypeScript

import { MongoClient } from 'mongodb'
import mongoose from 'mongoose'
export default class Client {
private static connectionString = import.meta.env.MONGODB
private static client = false
public static async get() {
if (!this.connectionString) {
throw new Error('Can\'t connect to the database, missing the connection string')
}
if (!this.client) {
console.log(this.connectionString)
mongoose.connect(this.connectionString)
this.client = true
}
return this.client
}
}