diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-10-02 15:12:47 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-10-02 15:12:47 +0200 |
commit | 7bd0a2004c9d7f1c59b510a5462b82c4b0a0ce7a (patch) | |
tree | 4e77c193c08b2acb234981a6244836e1c5398bcf /gateway/src | |
parent | Merge pull request #410 from TheArcaneBrony/master (diff) | |
download | server-7bd0a2004c9d7f1c59b510a5462b82c4b0a0ce7a.tar.xz |
:art: restructure gateway
Diffstat (limited to 'gateway/src')
-rw-r--r-- | gateway/src/Server.ts | 15 | ||||
-rw-r--r-- | gateway/src/events/Connection.ts | 7 | ||||
-rw-r--r-- | gateway/src/util/Heartbeat.ts (renamed from gateway/src/util/setHeartbeat.ts) | 0 | ||||
-rw-r--r-- | gateway/src/util/WebSocket.ts | 1 | ||||
-rw-r--r-- | gateway/src/util/index.ts | 2 |
5 files changed, 18 insertions, 7 deletions
diff --git a/gateway/src/Server.ts b/gateway/src/Server.ts index 944174c7..b4e92a75 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 { closeDatabase, Config, initDatabase, initEvent, RabbitMQ } from "@fosscord/util"; +import { closeDatabase, Config, initDatabase, initEvent } from "@fosscord/util"; import { Server as WebSocketServer } from "ws"; import { Connection } from "./events/Connection"; import http from "http"; @@ -12,15 +12,24 @@ export class Server { public server: http.Server; public production: boolean; - constructor({ port, server, production }: { port: number; server?: http.Server; production?: boolean }) { + constructor({ + port, + server, + production, + }: { + port: number; + server?: http.Server; + production?: boolean; + }) { this.port = port; this.production = production || false; if (server) this.server = server; - else + else { this.server = http.createServer(function (req, res) { res.writeHead(200).end("Online"); }); + } this.server.on("upgrade", (request, socket, head) => { console.log("socket requests upgrade", request.url); diff --git a/gateway/src/events/Connection.ts b/gateway/src/events/Connection.ts index 85f92b77..f84f9d9b 100644 --- a/gateway/src/events/Connection.ts +++ b/gateway/src/events/Connection.ts @@ -35,8 +35,11 @@ export async function Connection( // @ts-ignore socket.encoding = searchParams.get("encoding") || "json"; if (!["json", "etf"].includes(socket.encoding)) { - if (socket.encoding === "etf" && erlpack) - throw new Error("Erlpack is not installed: 'npm i -D erlpack'"); + if (socket.encoding === "etf" && erlpack) { + throw new Error( + "Erlpack is not installed: 'npm i @yukikaze-bot/erlpack'" + ); + } return socket.close(CLOSECODES.Decode_error); } diff --git a/gateway/src/util/setHeartbeat.ts b/gateway/src/util/Heartbeat.ts index f6871cfe..f6871cfe 100644 --- a/gateway/src/util/setHeartbeat.ts +++ b/gateway/src/util/Heartbeat.ts diff --git a/gateway/src/util/WebSocket.ts b/gateway/src/util/WebSocket.ts index b80265a7..49626b2a 100644 --- a/gateway/src/util/WebSocket.ts +++ b/gateway/src/util/WebSocket.ts @@ -1,7 +1,6 @@ import { Intents, Permissions } from "@fosscord/util"; import WS from "ws"; import { Deflate } from "zlib"; -import { Channel } from "amqplib"; export interface WebSocket extends WS { version: number; diff --git a/gateway/src/util/index.ts b/gateway/src/util/index.ts index 27af5813..0be5ecee 100644 --- a/gateway/src/util/index.ts +++ b/gateway/src/util/index.ts @@ -1,5 +1,5 @@ export * from "./Constants"; export * from "./Send"; export * from "./SessionUtils"; -export * from "./setHeartbeat"; +export * from "./Heartbeat"; export * from "./WebSocket"; |