diff --git a/bundle/package-lock.json b/bundle/package-lock.json index a0c8f4e6..58547168 100644 Binary files a/bundle/package-lock.json and b/bundle/package-lock.json differ 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); diff --git a/gateway/package-lock.json b/gateway/package-lock.json index 15388b4f..dc25c3be 100644 Binary files a/gateway/package-lock.json and b/gateway/package-lock.json differ diff --git a/gateway/package.json b/gateway/package.json index 7c9f5678..5a401e9f 100644 --- a/gateway/package.json +++ b/gateway/package.json @@ -32,7 +32,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" } } diff --git a/util/package-lock.json b/util/package-lock.json index a988b927..4c678510 100644 Binary files a/util/package-lock.json and b/util/package-lock.json differ diff --git a/util/package.json b/util/package.json index 1f2f2320..a33df2ba 100644 --- a/util/package.json +++ b/util/package.json @@ -32,7 +32,6 @@ "@types/mongoose-autopopulate": "^0.10.1", "@types/mongoose-lean-virtuals": "^0.5.1", "@types/node": "^14.17.9", - "typescript": "^4.1.3", "ajv": "^8.5.0", "amqplib": "^0.8.0", "dot-prop": "^6.0.1", @@ -41,6 +40,7 @@ "missing-native-js-functions": "^1.2.2", "mongodb": "^3.6.9", "mongoose": "^5.13.7", - "mongoose-autopopulate": "^0.12.3" + "mongoose-autopopulate": "^0.12.3", + "typescript": "^4.1.3" } }