diff --git a/api/package-lock.json b/api/package-lock.json index 24e67599c..3308a6be6 100644 Binary files a/api/package-lock.json and b/api/package-lock.json differ diff --git a/api/src/middlewares/TestClient.ts b/api/src/middlewares/TestClient.ts index 45b8a0726..f93d0b3ac 100644 --- a/api/src/middlewares/TestClient.ts +++ b/api/src/middlewares/TestClient.ts @@ -1,6 +1,4 @@ -import bodyParser, { OptionsJson } from "body-parser"; -import express, { NextFunction, Request, Response, Application } from "express"; -import { HTTPError } from "lambert-server"; +import express, { Request, Response, Application } from "express"; import fs from "fs"; import path from "path"; import fetch, { Response as FetchResponse } from "node-fetch"; @@ -58,8 +56,9 @@ export default function TestClient(app: Application) { const CDN_ENDPOINT = (Config.get()?.cdn.endpoint || process.env.CDN || "").replace(/(https?)?(:\/\/?)/g, ""); const GATEWAY_ENDPOINT = Config.get()?.gateway.endpoint || process.env.GATEWAY || ""; - if (CDN_ENDPOINT) html = html.replace(/CDN_HOST: .+/, `CDN_HOST: "${CDN_ENDPOINT}",`); - if (GATEWAY_ENDPOINT) html = html.replace(/GATEWAY_ENDPOINT: .+/, `GATEWAY_ENDPOINT: "${GATEWAY_ENDPOINT}",`); + if (CDN_ENDPOINT && Config.get().cdn.endpointClient) html = html.replace(/CDN_HOST: .+/, `CDN_HOST: "${CDN_ENDPOINT}",`); + if (GATEWAY_ENDPOINT && Config.get().gateway.endpointClient) + html = html.replace(/GATEWAY_ENDPOINT: .+/, `GATEWAY_ENDPOINT: "${GATEWAY_ENDPOINT}",`); res.send(html); }); diff --git a/bundle/package-lock.json b/bundle/package-lock.json index 5b389440a..218c1a55a 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 a3478e035..56ef95912 100644 --- a/bundle/package.json +++ b/bundle/package.json @@ -4,9 +4,12 @@ "description": "", "main": "src/start.js", "scripts": { - "linkInstall": "npm run --prefix ../util/ link && npm run --prefix ../api/ link && npm run --prefix ../cdn/ link && npm run --prefix ../gateway/ link", - "postinstall": "npm run linkInstall && npm link @fosscord/util && npm link @fosscord/api && npm link @fosscord/gateway && npm link @fosscord/cdn", - "build": "tsc -b .", + "postinstall": "cd ../api/ && npm i && cd ../cdn/ && npm i && cd ../gateway/ && npm i && ", + "build": "npm run build:api && npm run build:cdn && npm run build:gateway && npm run build:bundle", + "build:bundle": "tsc -b .", + "build:api": "cd ../api/ && npm run build", + "build:cdn": "cd ../cdn/ && npm run build", + "build:gateway": "cd ../gateway/ && npm run build", "start": "npm run build && node dist/start.js", "test": "echo \"Error: no test specified\" && exit 1" }, @@ -21,14 +24,12 @@ "url": "https://github.com/fosscord/fosscord-server/issues" }, "homepage": "https://fosscord.com", - "devDependencies": { + "dependencies": { "@types/async-exit-hook": "^2.0.0", "@types/express": "^4.17.13", - "@types/node": "^16.6.1", "@types/node-os-utils": "^1.2.0", - "typescript": "^4.3.5" - }, - "dependencies": { + "typescript": "^4.3.5", + "@types/node": "^16.6.1", "@fosscord/api": "file:../api", "@fosscord/cdn": "file:../cdn", "@fosscord/gateway": "file:../gateway", diff --git a/bundle/src/Server.ts b/bundle/src/Server.ts index 14abc1286..19d9e168b 100644 --- a/bundle/src/Server.ts +++ b/bundle/src/Server.ts @@ -22,12 +22,14 @@ const cdn = new CDNServer({ server, port, production, app }); const gateway = new GatewayServer({ server, port, production }); async function main() { + await Config.set({ + cdn: { endpointClientKeepDefault: true, endpoint: `http://localhost:${port}` }, + gateway: { endpointClientKeepDefault: true, endpoint: `ws://localhost:${port}` }, + }); + await api.start(); await cdn.start(); await gateway.start(); - - if (!Config.get().gateway.endpoint) await Config.set({ gateway: { endpoint: `ws://localhost:${port}` } }); - if (!Config.get().cdn.endpoint) await Config.set({ cdn: { endpoint: `http://localhost:${port}` } }); } main().catch(console.error); diff --git a/cdn/package-lock.json b/cdn/package-lock.json new file mode 100644 index 000000000..a539832a2 Binary files /dev/null and b/cdn/package-lock.json differ diff --git a/gateway/package-lock.json b/gateway/package-lock.json new file mode 100644 index 000000000..15388b4f5 Binary files /dev/null and b/gateway/package-lock.json differ diff --git a/util/package-lock.json b/util/package-lock.json index 3bd26d11f..a988b9275 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 082d5cb38..1f2f2320c 100644 --- a/util/package.json +++ b/util/package.json @@ -25,13 +25,14 @@ "url": "https://github.com/fosscord/fosscord-server-util/issues" }, "homepage": "https://docs.fosscord.com/", - "dependencies": { + "devDependencies": { "@types/amqplib": "^0.8.1", "@types/jsonwebtoken": "^8.5.0", "@types/mongodb": "^3.6.9", "@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", @@ -40,7 +41,6 @@ "missing-native-js-functions": "^1.2.2", "mongodb": "^3.6.9", "mongoose": "^5.13.7", - "mongoose-autopopulate": "^0.12.3", - "typescript": "^4.1.3" + "mongoose-autopopulate": "^0.12.3" } } diff --git a/util/src/util/Config.ts b/util/src/util/Config.ts index b4648668a..a23d724da 100644 --- a/util/src/util/Config.ts +++ b/util/src/util/Config.ts @@ -43,9 +43,11 @@ export interface KafkaBroker { export interface DefaultOptions { gateway: { + endpointClientKeepDefault?: boolean; endpoint: string | null; }; cdn: { + endpointClientKeepDefault?: boolean; endpoint: string | null; }; general: { @@ -148,9 +150,11 @@ export interface DefaultOptions { export const DefaultOptions: DefaultOptions = { gateway: { + endpointClientKeepDefault: false, endpoint: null, }, cdn: { + endpointClientKeepDefault: false, endpoint: null, }, general: {