refactor(server/plugins): add plugin
use mongodb as unstorage driver
This commit is contained in:
parent
4d6398d09f
commit
da8b960004
13
server/plugins/storage.ts
Normal file
13
server/plugins/storage.ts
Normal file
@ -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);
|
||||
});
|
Loading…
Reference in New Issue
Block a user