summary refs log tree commit diff
path: root/bundle/src/Database.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-01 10:47:00 +0200
committerGitHub <noreply@github.com>2021-09-01 10:47:00 +0200
commitdf1d633c4b56bea97e0b76da34171d80c0c6a3ff (patch)
tree7e57837ec000a641935a32649ac17b38ef2e29d8 /bundle/src/Database.ts
parentMerge pull request #287 from EMREOYUN/patch-1 (diff)
parentMerge pull request #299 from AlTech98/typeorm (diff)
downloadserver-df1d633c4b56bea97e0b76da34171d80c0c6a3ff.tar.xz
Merge pull request #300 from fosscord/typeorm
Diffstat (limited to 'bundle/src/Database.ts')
-rw-r--r--bundle/src/Database.ts44
1 files changed, 0 insertions, 44 deletions
diff --git a/bundle/src/Database.ts b/bundle/src/Database.ts
deleted file mode 100644

index 12febc1c..00000000 --- a/bundle/src/Database.ts +++ /dev/null
@@ -1,44 +0,0 @@ -import fs from "fs"; -import { MongoMemoryServer } from "mongodb-memory-server"; -import path from "path"; -import exitHook from "async-exit-hook"; - -if (process.arch == "ia32") { - Object.defineProperty(process, "arch", { - value: "x64", - }); -} - -export async function setupDatabase() { - if (process.env.MONGO_URL) return; // exit because the user provides his own mongodb - const dbPath = path.join(__dirname, "..", "..", "db"); - const dbName = "fosscord"; - const storageEngine = "wiredTiger"; - const port = 27020; - const ip = "127.0.0.1"; - var mongod: MongoMemoryServer; - fs.mkdirSync(dbPath, { recursive: true }); - - exitHook((callback: any) => { - (async () => { - console.log(`Stopping MongoDB ...`); - await mongod.stop(); - console.log(`Stopped MongoDB`); - callback(); - })(); - }); - - console.log(`[Database] starting ...`); - mongod = new MongoMemoryServer({ - instance: { - port, - ip, - dbName, - dbPath, - storageEngine, - auth: false, // by default `mongod` is started with '--noauth', start `mongod` with '--auth' - }, - }); - await mongod.start(); - process.env.MONGO_URL = mongod.getUri(dbName); -}