added express js

This commit is contained in:
2025-10-02 10:14:53 +02:00
parent f1d5bead86
commit f99aee302a
7 changed files with 1276 additions and 105 deletions

20
db.js Normal file
View File

@@ -0,0 +1,20 @@
import { MongoClient } from "mongodb";
const client = new MongoClient(`mongodb://${process.env.MONGODB_USER}:${process.env.MONGODB_PASSWORD}@${process.env.MONGODB_URL}`);
const dbName = `jeopardy`;
/**
* @type {Db}
*/
export let db;
export async function initDbConnection() {
await client.connect();
console.log('Connected successfully to mongodb');
db = client.db(dbName);
}
export function close() {
client.close();
}