summary refs log tree commit diff
path: root/gateway/src/Server.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
commitee35e42153d1c57f5964225cccda1abacdc43f48 (patch)
tree5b5b159ae4ec956415a88679ed774b524523e0d9 /gateway/src/Server.ts
parentMerge pull request #287 from EMREOYUN/patch-1 (diff)
parentMerge pull request #299 from AlTech98/typeorm (diff)
downloadserver-ee35e42153d1c57f5964225cccda1abacdc43f48.tar.xz
Merge pull request #300 from fosscord/typeorm
Diffstat (limited to '')
-rw-r--r--gateway/src/Server.ts13
1 files changed, 3 insertions, 10 deletions
diff --git a/gateway/src/Server.ts b/gateway/src/Server.ts

index a50c24a6..944174c7 100644 --- a/gateway/src/Server.ts +++ b/gateway/src/Server.ts
@@ -1,7 +1,7 @@ import "missing-native-js-functions"; import dotenv from "dotenv"; dotenv.config(); -import { Config, db, initEvent, RabbitMQ } from "@fosscord/util"; +import { closeDatabase, Config, initDatabase, initEvent, RabbitMQ } from "@fosscord/util"; import { Server as WebSocketServer } from "ws"; import { Connection } from "./events/Connection"; import http from "http"; @@ -38,15 +38,8 @@ export class Server { this.ws.on("error", console.error); } - async setupSchema() { - // TODO: adjust expireAfterSeconds -> lower - await Promise.all([db.collection("events").createIndex({ created_at: 1 }, { expireAfterSeconds: 60 })]); - } - async start(): Promise<void> { - // @ts-ignore - await (db as Promise<Connection>); - await this.setupSchema(); + await initDatabase(); await Config.init(); await initEvent(); if (!this.server.listening) { @@ -56,7 +49,7 @@ export class Server { } async stop() { - await db.close(); + closeDatabase(); this.server.close(); } }