diff --git a/.gitignore b/.gitignore index b2868e2..dcd4d8f 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,4 @@ testem.log Thumbs.db environment.ts environment.ts +backend/environment.js diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..5ee509f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cSpell.words": ["openai"] +} diff --git a/backend/app.js b/backend/app.js index 5fbd92e..80c1634 100644 --- a/backend/app.js +++ b/backend/app.js @@ -1,7 +1,32 @@ const express = require("express"); const bodyParser = require("body-parser"); +const environment = require("./environment"); const app = express(); +const { MongoClient, ServerApiVersion } = require('mongodb'); +const uri = environment.mongoDB.MONGODB_URI; +// Create a MongoClient with a MongoClientOptions object to set the Stable API version +const client = new MongoClient(uri, { + serverApi: { + version: ServerApiVersion.v1, + strict: true, + deprecationErrors: true, + } +}); + +async function run() { + try { + // Connect the client to the server (optional starting in v4.7) + await client.connect(); + // Send a ping to confirm a successful connection + await client.db("admin").command({ ping: 1 }); + console.log("Pinged your deployment. You successfully connected to MongoDB!"); + } finally { + // Ensures that the client will close when you finish/error + await client.close(); + } +} +run().catch(console.dir); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); diff --git a/package-lock.json b/package-lock.json index 4217f4a..e3c6d23 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "bootstrap": "^5.2.3", "bootstrap-icons": "^1.10.5", "express": "^4.18.2", + "mongodb": "^5.5.0", "mongoose": "^7.2.0", "openai": "^3.2.1", "rxjs": "~7.8.0", diff --git a/package.json b/package.json index f49dbce..f374079 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "bootstrap": "^5.2.3", "bootstrap-icons": "^1.10.5", "express": "^4.18.2", + "mongodb": "^5.5.0", "mongoose": "^7.2.0", "openai": "^3.2.1", "rxjs": "~7.8.0",