2023-12-29 14:24:29 +00:00
|
|
|
import { MongoMemoryServer } from "mongodb-memory-server";
|
|
|
|
|
|
|
|
class MemoryServer {
|
|
|
|
mongod: MongoMemoryServer | undefined;
|
|
|
|
|
|
|
|
async start() {
|
|
|
|
this.mongod = await MongoMemoryServer.create();
|
|
|
|
const uri = this.mongod.getUri("bot");
|
|
|
|
process.env.MONGODB_URI = uri;
|
|
|
|
}
|
|
|
|
|
|
|
|
async stop() {
|
|
|
|
if (this.mongod) {
|
|
|
|
await this.mongod.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-29 18:37:35 +00:00
|
|
|
export default new MemoryServer();
|