summary refs log tree commit diff
path: root/bundle
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-13 22:57:46 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-13 22:57:46 +0200
commit194ef5478eb48d870c5d8844f1be6393dcd37ffa (patch)
treedf2f00bad728d42771e7c7131ee408455117f6ea /bundle
parentMerge branch 'master' of https://github.com/fosscord/fosscord-api (diff)
downloadserver-194ef5478eb48d870c5d8844f1be6393dcd37ffa.tar.xz
:construction: fix server bundle
Diffstat (limited to 'bundle')
-rw-r--r--bundle/.vscode/launch.json18
-rw-r--r--bundle/package-lock.json22
-rw-r--r--bundle/package.json2
-rw-r--r--bundle/src/Server.ts13
4 files changed, 38 insertions, 17 deletions
diff --git a/bundle/.vscode/launch.json b/bundle/.vscode/launch.json
new file mode 100644
index 00000000..0b5d2287
--- /dev/null
+++ b/bundle/.vscode/launch.json
@@ -0,0 +1,18 @@
+{
+	// Use IntelliSense to learn about possible attributes.
+	// Hover to view descriptions of existing attributes.
+	// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+	"version": "0.2.0",
+	"configurations": [
+		{
+			"sourceMaps": true,
+			"type": "node",
+			"request": "launch",
+			"name": "Launch server bundle",
+			"program": "${workspaceFolder}/dist/start.js",
+			"preLaunchTask": "tsc: build - tsconfig.json",
+			"outFiles": ["${workspaceFolder}/dist/**/*.js"],
+			"envFile": "${workspaceFolder}/.env"
+		}
+	]
+}
diff --git a/bundle/package-lock.json b/bundle/package-lock.json
index 218c1a55..a0c8f4e6 100644
--- a/bundle/package-lock.json
+++ b/bundle/package-lock.json
@@ -7,6 +7,7 @@
 		"": {
 			"name": "@fosscord/server",
 			"version": "1.0.0",
+			"hasInstallScript": true,
 			"license": "AGPLV3",
 			"dependencies": {
 				"@fosscord/api": "file:../api",
@@ -28,7 +29,6 @@
 		"../api": {
 			"name": "@fosscord/api",
 			"version": "1.0.0",
-			"hasInstallScript": true,
 			"license": "ISC",
 			"dependencies": {
 				"@fosscord/util": "file:../util",
@@ -85,7 +85,6 @@
 		"../cdn": {
 			"name": "@fosscord/cdn",
 			"version": "1.0.0",
-			"hasInstallScript": true,
 			"license": "ISC",
 			"dependencies": {
 				"@fosscord/util": "file:../util",
@@ -121,7 +120,6 @@
 		"../gateway": {
 			"name": "@fosscord/gateway",
 			"version": "1.0.0",
-			"hasInstallScript": true,
 			"license": "ISC",
 			"dependencies": {
 				"@fosscord/util": "file:../util",
@@ -152,7 +150,13 @@
 			"version": "1.3.55",
 			"hasInstallScript": true,
 			"license": "GPLV3",
-			"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",
 				"ajv": "^8.5.0",
 				"amqplib": "^0.8.0",
 				"dot-prop": "^6.0.1",
@@ -161,15 +165,7 @@
 				"missing-native-js-functions": "^1.2.2",
 				"mongodb": "^3.6.9",
 				"mongoose": "^5.13.7",
-				"mongoose-autopopulate": "^0.12.3"
-			},
-			"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",
+				"mongoose-autopopulate": "^0.12.3",
 				"typescript": "^4.1.3"
 			}
 		},
diff --git a/bundle/package.json b/bundle/package.json
index 56ef9591..be584631 100644
--- a/bundle/package.json
+++ b/bundle/package.json
@@ -4,7 +4,7 @@
 	"description": "",
 	"main": "src/start.js",
 	"scripts": {
-		"postinstall": "cd ../api/ && npm i && cd ../cdn/ && npm i && cd ../gateway/ && npm i && ",
+		"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",
diff --git a/bundle/src/Server.ts b/bundle/src/Server.ts
index 68966bf4..6951c1c4 100644
--- a/bundle/src/Server.ts
+++ b/bundle/src/Server.ts
@@ -9,9 +9,10 @@ import express from "express";
 import { Config } from "../../util/dist";
 
 const app = express();
-const server = http.createServer(app);
+const server = http.createServer();
 const port = Number(process.env.PORT) || 8080;
 const production = true;
+server.on("request", app);
 
 // @ts-ignore
 const api = new APIServer({ server, port, production, app });
@@ -22,8 +23,14 @@ 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}` },
+		cdn: {
+			endpointClient: "${location.host}",
+			endpoint: `http://localhost:${port}`,
+		},
+		gateway: {
+			endpointClient: '${location.protocol === "https:" ? "wss://" : "ws://"}${location.host}',
+			endpoint: `ws://localhost:${port}`,
+		},
 	});
 
 	await api.start();