summary refs log tree commit diff
path: root/bundle
diff options
context:
space:
mode:
Diffstat (limited to 'bundle')
-rw-r--r--bundle/package-lock.json4
-rw-r--r--bundle/package.json13
-rw-r--r--bundle/src/root.ts33
3 files changed, 40 insertions, 10 deletions
diff --git a/bundle/package-lock.json b/bundle/package-lock.json
index a0c8f4e6..58547168 100644
--- a/bundle/package-lock.json
+++ b/bundle/package-lock.json
@@ -41,7 +41,6 @@
 				"atomically": "^1.7.0",
 				"bcrypt": "^5.0.1",
 				"body-parser": "^1.19.0",
-				"canvas": "^2.8.0",
 				"cheerio": "^1.0.0-rc.9",
 				"dot-prop": "^6.0.1",
 				"dotenv": "^8.2.0",
@@ -141,7 +140,6 @@
 				"@types/mongoose-autopopulate": "^0.10.1",
 				"@types/uuid": "^8.3.0",
 				"@types/ws": "^7.4.0",
-				"erlpack": "^0.1.3",
 				"ts-node-dev": "^1.1.6"
 			}
 		},
@@ -1583,7 +1581,6 @@
 				"atomically": "^1.7.0",
 				"bcrypt": "^5.0.1",
 				"body-parser": "^1.19.0",
-				"canvas": "^2.8.0",
 				"caxa": "^2.1.0",
 				"cheerio": "^1.0.0-rc.9",
 				"dot-prop": "^6.0.1",
@@ -1655,7 +1652,6 @@
 				"ajv": "^8.5.0",
 				"amqplib": "^0.8.0",
 				"dotenv": "^8.2.0",
-				"erlpack": "^0.1.3",
 				"jsonwebtoken": "^8.5.1",
 				"lambert-server": "^1.2.8",
 				"missing-native-js-functions": "^1.2.3",
diff --git a/bundle/package.json b/bundle/package.json
index be584631..c8d6a9f3 100644
--- a/bundle/package.json
+++ b/bundle/package.json
@@ -11,6 +11,7 @@
 		"build:cdn": "cd ../cdn/ && npm run build",
 		"build:gateway": "cd ../gateway/ && npm run build",
 		"start": "npm run build && node dist/start.js",
+		"root": "npm run build && node dist/root.js",
 		"test": "echo \"Error: no test specified\" && exit 1"
 	},
 	"repository": {
@@ -25,19 +26,19 @@
 	},
 	"homepage": "https://fosscord.com",
 	"dependencies": {
-		"@types/async-exit-hook": "^2.0.0",
-		"@types/express": "^4.17.13",
-		"@types/node-os-utils": "^1.2.0",
-		"typescript": "^4.3.5",
-		"@types/node": "^16.6.1",
 		"@fosscord/api": "file:../api",
 		"@fosscord/cdn": "file:../cdn",
 		"@fosscord/gateway": "file:../gateway",
 		"@fosscord/util": "file:../util",
+		"@types/async-exit-hook": "^2.0.0",
+		"@types/express": "^4.17.13",
+		"@types/node": "^16.6.1",
+		"@types/node-os-utils": "^1.2.0",
 		"async-exit-hook": "^2.0.1",
 		"express": "^4.17.1",
 		"link": "^0.1.5",
 		"mongodb-memory-server-global-4.4": "^7.3.6",
-		"node-os-utils": "^1.3.5"
+		"node-os-utils": "^1.3.5",
+		"typescript": "^4.3.5"
 	}
 }
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);