summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-11 19:29:39 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-11 19:29:39 +0200
commitd8eece32de3b509c9171d0769d042fab672439e1 (patch)
treead3980e844a173dd4cae75871d6a5aa92f49efd0 /src
parent1.3.47 (diff)
downloadserver-d8eece32de3b509c9171d0769d042fab672439e1.tar.xz
:sparkles: rabbitmq
Diffstat (limited to 'src')
-rw-r--r--src/util/Config.ts38
-rw-r--r--src/util/RabbitMQ.ts14
-rw-r--r--src/util/index.ts3
3 files changed, 37 insertions, 18 deletions
diff --git a/src/util/Config.ts b/src/util/Config.ts
index cbdc194c..10dddc88 100644
--- a/src/util/Config.ts
+++ b/src/util/Config.ts
@@ -25,17 +25,17 @@ export interface RateLimitOptions {
 }
 
 export interface Region {
-	id: string,
-	name: string,
-	vip: boolean,
-	custom: boolean,
-	deprecated: boolean,
-	optimal: boolean,
+	id: string;
+	name: string;
+	vip: boolean;
+	custom: boolean;
+	deprecated: boolean;
+	optimal: boolean;
 }
 
 export interface KafkaBroker {
-	ip: string,
-	port: number
+	ip: string;
+	port: number;
 }
 
 export interface DefaultOptions {
@@ -133,10 +133,13 @@ export interface DefaultOptions {
 	regions: {
 		default: string;
 		available: Region[];
-	}
+	};
+	rabbitmq: {
+		host: string | null;
+	};
 	kafka: {
-		brokers: KafkaBroker[] | null
-	}
+		brokers: KafkaBroker[] | null;
+	};
 }
 
 export const DefaultOptions: DefaultOptions = {
@@ -230,17 +233,18 @@ export const DefaultOptions: DefaultOptions = {
 	},
 	regions: {
 		default: "fosscord",
-		available: [
-			{ id: "fosscord", name: "Fosscord", vip: false, custom: false, deprecated: false, optimal: false },
-		]
+		available: [{ id: "fosscord", name: "Fosscord", vip: false, custom: false, deprecated: false, optimal: false }],
+	},
+	rabbitmq: {
+		host: null,
 	},
 	kafka: {
-		brokers: null
-	}
+		brokers: null,
+	},
 };
 
 export const ConfigSchema = new Schema({}, { strict: false });
 
-export interface DefaultOptionsDocument extends DefaultOptions, Document { }
+export interface DefaultOptionsDocument extends DefaultOptions, Document {}
 
 export const ConfigModel = model<DefaultOptionsDocument>("Config", ConfigSchema, "config");
diff --git a/src/util/RabbitMQ.ts b/src/util/RabbitMQ.ts
new file mode 100644
index 00000000..9df95231
--- /dev/null
+++ b/src/util/RabbitMQ.ts
@@ -0,0 +1,14 @@
+import amqp, { Connection, Channel } from "amqplib";
+import Config from "./Config";
+
+var rabbitCon: Connection;
+var rabbitCh: Channel;
+
+export async function init() {
+	const host = Config.get().rabbitmq.host;
+	if (!host) return;
+	rabbitCon = await amqp.connect(host);
+	rabbitCh = await rabbitCon.createChannel();
+}
+
+export { rabbitCon, rabbitCh };
diff --git a/src/util/index.ts b/src/util/index.ts
index 7e8bca20..7523a6ad 100644
--- a/src/util/index.ts
+++ b/src/util/index.ts
@@ -5,4 +5,5 @@ export * from "./MessageFlags";
 export * from "./Permissions";
 export * from "./Snowflake";
 export * from "./UserFlags";
-export * from "./toBigInt"
\ No newline at end of file
+export * from "./toBigInt";
+export * from "./RabbitMQ";