summary refs log tree commit diff
path: root/bundle/src
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-14 13:57:34 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-14 13:57:34 +0200
commitbacb78f5c58fac293d5f5231d5b31a8bc63307b8 (patch)
treeff0f354e72c11bfe9c5fb3522ff83fab92964ccf /bundle/src
parent:bug: fix Guild + Channel create (diff)
downloadserver-bacb78f5c58fac293d5f5231d5b31a8bc63307b8.tar.xz
:sparkles: server bundle
Diffstat (limited to 'bundle/src')
-rw-r--r--bundle/src/root.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/bundle/src/root.ts b/bundle/src/root.ts
new file mode 100644
index 00000000..42a3f3c3
--- /dev/null
+++ b/bundle/src/root.ts
@@ -0,0 +1,33 @@
+process.on("unhandledRejection", console.error);
+process.on("uncaughtException", console.error);
+
+import { FosscordServer as APIServer } from "@fosscord/api";
+import { Server as GatewayServer } from "@fosscord/gateway";
+import { CDNServer } from "@fosscord/cdn/";
+import { Config } from "../../util/dist";
+
+const production = true;
+
+const api = new APIServer({ production, port: Number(process.env.API_PORT) || 3001 });
+const gateway = new GatewayServer({ port: Number(process.env.GATEWAY_PORT) || 3002 });
+const cdn = new CDNServer({ production, port: Number(process.env.CDN_PORT) || 3003 });
+
+async function main() {
+	await Config.set({
+		cdn: {
+			endpointClient: "${location.host}",
+			endpoint: `http://localhost:${cdn.options.port}`,
+		},
+		gateway: {
+			endpointClient:
+				'${location.protocol === "https:" ? "wss://" : "ws://"}${location.hostname}:' + gateway.port,
+			endpoint: `ws://localhost:${gateway.port}`,
+		},
+	});
+
+	await api.start();
+	await cdn.start();
+	await gateway.start();
+}
+
+main().catch(console.error);