Initial commit
This commit is contained in:
commit
92e96b9107
85 changed files with 24969 additions and 0 deletions
20
app/server/plugins/mongodb.ts
Normal file
20
app/server/plugins/mongodb.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import mongoose from "mongoose";
|
||||
|
||||
export default defineNitroPlugin(async () => {
|
||||
const config = useRuntimeConfig();
|
||||
|
||||
try {
|
||||
await mongoose.connect(config.mongodbUri as string);
|
||||
console.log("✓ MongoDB connected successfully");
|
||||
} catch (error) {
|
||||
console.error("✗ MongoDB connection error:", error);
|
||||
throw error;
|
||||
}
|
||||
|
||||
// Graceful shutdown
|
||||
process.on("SIGINT", async () => {
|
||||
await mongoose.connection.close();
|
||||
console.log("MongoDB connection closed");
|
||||
process.exit(0);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue