diff --git a/server/plugins/storage.ts b/server/plugins/storage.ts new file mode 100644 index 0000000..7ea1d3b --- /dev/null +++ b/server/plugins/storage.ts @@ -0,0 +1,13 @@ +import mongoDriver from "unstorage/drivers/mongodb"; + +export default defineNitroPlugin(() => { + const storage = useStorage(); + const db = useRuntimeConfig().database; + const driver = mongoDriver({ + connectionString: + process.env.NODE_ENV == "production" ? `mongodb://${db.user}:${db.password}@localhost:27017/${db.name}` : `mongodb://localhost:27017/${db.name}`, + databaseName: db.name, + collectionName: "cache", + }); + storage.mount("", driver); +});