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-08-29 00:30:04 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-29 00:30:04 +0200
commitb4b8d1d8df3bf8263116310273c7f7ba65557806 (patch)
tree218dc458f44ba5d532b21a8dbe649e5c444e9b09 /gateway/src/Server.ts
parent:sparkles: update util (diff)
downloadserver-b4b8d1d8df3bf8263116310273c7f7ba65557806.tar.xz
:sparkles: typeorm gateway
Diffstat (limited to 'gateway/src/Server.ts')
-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(); } }