summary refs log tree commit diff
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-10-31 13:16:29 +1100
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-10-31 13:17:21 +1100
commit49ae07ff297b0cffbb667d627320092a1022230c (patch)
tree5d5bdb1682052612f0b460777d7714b5502834b4
parentAdd token check back to loginRedirect (diff)
downloadserver-49ae07ff297b0cffbb667d627320092a1022230c.tar.xz
Allow running api, cdn, gateway separately
-rw-r--r--package.json3
-rw-r--r--src/api/Server.ts5
-rw-r--r--src/api/start.ts1
-rw-r--r--src/gateway/Server.ts3
-rw-r--r--src/util/util/RabbitMQ.ts21
5 files changed, 19 insertions, 14 deletions
diff --git a/package.json b/package.json
index ea9c9b40..e54cafe3 100644
--- a/package.json
+++ b/package.json
@@ -5,6 +5,9 @@
 	"scripts": {
 		"postinstall": "npx patch-package",
 		"start": "node dist/bundle/start.js",
+		"start:api": "node dist/api/start.js",
+		"start:cdn": "node dist/cdn/start.js",
+		"start:gateway": "node dist/gateway/start.js",
 		"build": "tsc -p .",
 		"setup": "npm run build && npm run generate:schema",
 		"generate:rights": "node scripts/rights.js",
diff --git a/src/api/Server.ts b/src/api/Server.ts
index bd9bc4b9..6c4b5652 100644
--- a/src/api/Server.ts
+++ b/src/api/Server.ts
@@ -1,7 +1,7 @@
 import "missing-native-js-functions";
 import { Server, ServerOptions } from "lambert-server";
 import { Authentication, CORS } from "./middlewares/";
-import { Config, initDatabase, initEvent } from "@fosscord/util";
+import { BannedWords, Config, initDatabase, initEvent } from "@fosscord/util";
 import { ErrorHandler } from "./middlewares/ErrorHandler";
 import { BodyParser } from "./middlewares/BodyParser";
 import { Router, Request, Response, NextFunction } from "express";
@@ -14,7 +14,7 @@ import { initInstance } from "./util/handlers/Instance";
 import { registerRoutes } from "@fosscord/util";
 import { red } from "picocolors";
 
-export interface FosscordServerOptions extends ServerOptions {}
+export interface FosscordServerOptions extends ServerOptions { }
 
 declare global {
 	namespace Express {
@@ -38,6 +38,7 @@ export class FosscordServer extends Server {
 		await Config.init();
 		await initEvent();
 		await initInstance();
+		await BannedWords.init();
 
 		let logRequests = process.env["LOG_REQUESTS"] != undefined;
 		if (logRequests) {
diff --git a/src/api/start.ts b/src/api/start.ts
index fa120e59..a67e6f2b 100644
--- a/src/api/start.ts
+++ b/src/api/start.ts
@@ -1,3 +1,4 @@
+require("module-alias/register");
 process.on("uncaughtException", console.error);
 process.on("unhandledRejection", console.error);
 
diff --git a/src/gateway/Server.ts b/src/gateway/Server.ts
index 7e1489be..8c416b92 100644
--- a/src/gateway/Server.ts
+++ b/src/gateway/Server.ts
@@ -1,7 +1,7 @@
 import "missing-native-js-functions";
 import dotenv from "dotenv";
 dotenv.config();
-import { closeDatabase, Config, initDatabase, initEvent } from "@fosscord/util";
+import { BannedWords, closeDatabase, Config, initDatabase, initEvent } from "@fosscord/util";
 import ws from "ws";
 import { Connection } from "./events/Connection";
 import http from "http";
@@ -50,6 +50,7 @@ export class Server {
 		await initDatabase();
 		await Config.init();
 		await initEvent();
+		await BannedWords.init();
 		if (!this.server.listening) {
 			this.server.listen(this.port);
 			console.log(`[Gateway] online on 0.0.0.0:${this.port}`);
diff --git a/src/util/util/RabbitMQ.ts b/src/util/util/RabbitMQ.ts
index 1bfb3f5c..f59f6fe3 100644
--- a/src/util/util/RabbitMQ.ts
+++ b/src/util/util/RabbitMQ.ts
@@ -1,5 +1,5 @@
 import amqp, { Connection, Channel } from "amqplib";
-// import Config from "./Config";
+import { Config } from "./Config";
 
 export const RabbitMQ: {
 	connection: Connection | null;
@@ -9,15 +9,14 @@ export const RabbitMQ: {
 	connection: null,
 	channel: null,
 	init: async function () {
-		return;
-		// const host = Config.get().rabbitmq.host;
-		// if (!host) return;
-		// console.log(`[RabbitMQ] connect: ${host}`);
-		// this.connection = await amqp.connect(host, {
-		// 	timeout: 1000 * 60,
-		// });
-		// console.log(`[RabbitMQ] connected`);
-		// this.channel = await this.connection.createChannel();
-		// console.log(`[RabbitMQ] channel created`);
+		const host = Config.get().rabbitmq.host;
+		if (!host) return;
+		console.log(`[RabbitMQ] connect: ${host}`);
+		this.connection = await amqp.connect(host, {
+			timeout: 1000 * 60,
+		});
+		console.log(`[RabbitMQ] connected`);
+		this.channel = await this.connection.createChannel();
+		console.log(`[RabbitMQ] channel created`);
 	},
 };