1
0
Fork 0
mirror of https://github.com/docker/awesome-compose.git synced 2025-04-26 10:43:35 +02:00

add mongodb-angular-expressjs-nodejs docker sample

Signed-off-by: Sohaib Manah <souhaibemanah@gmail.com>
This commit is contained in:
Sohaib Manah 2023-03-24 16:02:31 +00:00
parent e6b1d2755f
commit c5c2efb203
62 changed files with 12812 additions and 0 deletions

View file

@ -0,0 +1,29 @@
import { MongoClient, ServerApiVersion } from "mongodb";
import dotenv from "dotenv";
dotenv.config();
// Create a MongoClient with a MongoClientOptions object to set the Stable API version
const client = new MongoClient(
process.env.MONGODB_URI || "mongodb://mongo:27017",
{
serverApi: {
version: ServerApiVersion.v1,
strict: true,
deprecationErrors: true,
},
}
);
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();
}
export default client.connect();