20 lines
396 B
TypeScript
20 lines
396 B
TypeScript
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();
|
|
}
|
|
}
|
|
}
|
|
|
|
export default new MemoryServer();
|