mirror of
https://github.com/alexgo-io/redstone-cache-layer.git
synced 2026-01-12 22:43:30 +08:00
15 lines
492 B
TypeScript
15 lines
492 B
TypeScript
import { writeFileSync } from "fs";
|
|
import { MongoMemoryServer } from "mongodb-memory-server";
|
|
|
|
// The DB can be stopped by killing the process (e.g sending SIGTERM signal)
|
|
|
|
const FILE_NAME_WITH_MONGO_DB_URI = "./tmp-mongo-db-uri.log";
|
|
|
|
(async () => {
|
|
const filePath = process.argv[2] ?? FILE_NAME_WITH_MONGO_DB_URI;
|
|
const mongod = await MongoMemoryServer.create();
|
|
const uri = mongod.getUri();
|
|
writeFileSync(filePath, uri);
|
|
console.log(`Started mongo DB in memory: ${uri}`);
|
|
})();
|