mirror of
https://github.com/andwati/order-service.git
synced 2026-10-23 12:32:15 +00:00
feat: implement MongoDB connection logic
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import mongoose from "mongoose";
|
||||
import { env } from "./env.js";
|
||||
|
||||
export async function connectDB(): Promise<void> {
|
||||
try {
|
||||
mongoose.set("strictQuery", true);
|
||||
|
||||
await mongoose.connect(env.mongoUri);
|
||||
|
||||
console.log("Connected to MongoDB");
|
||||
} catch (error) {
|
||||
console.error("Failed to connect to MongoDB", error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user