summary refs log tree commit diff
path: root/bundle
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-29 16:58:53 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-29 16:58:53 +0200
commitb68b1a118144baaef7da849ad7d42767401cad01 (patch)
tree0d5d505c8b8e952669a268186c790811d390572e /bundle
parentfix login register + message (diff)
downloadserver-b68b1a118144baaef7da849ad7d42767401cad01.tar.xz
fix bundle
Diffstat (limited to 'bundle')
-rw-r--r--bundle/database.dbbin0 -> 225280 bytes
-rw-r--r--bundle/package-lock.json60
-rw-r--r--bundle/package.json3
-rw-r--r--bundle/src/Database.ts44
-rw-r--r--bundle/src/Server.ts4
-rw-r--r--bundle/src/start.ts2
6 files changed, 43 insertions, 70 deletions
diff --git a/bundle/database.db b/bundle/database.db
new file mode 100644
index 00000000..9572c45e
--- /dev/null
+++ b/bundle/database.db
Binary files differdiff --git a/bundle/package-lock.json b/bundle/package-lock.json
index 379b1c18..9fcb5490 100644
--- a/bundle/package-lock.json
+++ b/bundle/package-lock.json
@@ -63,19 +63,21 @@
 				"i18next-http-middleware": "^3.1.3",
 				"i18next-node-fs-backend": "^2.1.3",
 				"jsonwebtoken": "^8.5.1",
-				"lambert-server": "^1.2.8",
-				"missing-native-js-functions": "^1.2.10",
+				"lambert-server": "^1.2.10",
+				"missing-native-js-functions": "^1.2.11",
 				"mongoose": "^5.12.3",
 				"mongoose-autopopulate": "^0.12.3",
 				"mongoose-long": "^0.3.2",
 				"multer": "^1.4.2",
-				"node-fetch": "^2.6.1"
+				"node-fetch": "^2.6.1",
+				"typeorm": "^0.2.37"
 			},
 			"devDependencies": {
 				"@types/amqplib": "^0.8.1",
 				"@types/bcrypt": "^5.0.0",
 				"@types/express": "^4.17.9",
 				"@types/i18next-node-fs-backend": "^2.1.0",
+				"@types/jest": "^27.0.1",
 				"@types/jsonwebtoken": "^8.5.0",
 				"@types/mongodb": "^3.6.9",
 				"@types/mongoose": "^5.10.5",
@@ -111,11 +113,13 @@
 				"file-type": "^16.5.0",
 				"fs-extra": "^10.0.0",
 				"image-size": "^1.0.0",
+				"jest": "^27.0.6",
 				"lambert-db": "^1.2.3",
 				"lambert-server": "^1.2.8",
 				"missing-native-js-functions": "^1.2.10",
 				"multer": "^1.4.2",
 				"node-fetch": "^2.6.1",
+				"supertest": "^6.1.6",
 				"typescript": "^4.1.2",
 				"uuid": "^8.3.2"
 			},
@@ -173,26 +177,30 @@
 			"hasInstallScript": true,
 			"license": "GPLV3",
 			"dependencies": {
-				"ajv": "^8.5.0",
+				"ajv": "^8.6.2",
 				"amqplib": "^0.8.0",
+				"class-validator": "^0.13.1",
 				"dot-prop": "^6.0.1",
 				"env-paths": "^2.2.1",
 				"jsonwebtoken": "^8.5.1",
-				"missing-native-js-functions": "^1.2.10",
-				"mongodb": "^3.6.9",
-				"mongoose": "^5.13.7",
-				"mongoose-autopopulate": "^0.12.3",
+				"lambert-server": "^1.2.10",
+				"missing-native-js-functions": "^1.2.11",
 				"node-fetch": "^2.6.1",
-				"typescript": "^4.1.3"
+				"patch-package": "^6.4.7",
+				"pg": "^8.7.1",
+				"reflect-metadata": "^0.1.13",
+				"sqlite3": "^5.0.2",
+				"typeorm": "^0.2.37",
+				"typescript": "^4.3.5",
+				"typescript-json-schema": "^0.50.1"
 			},
 			"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",
-				"@types/node-fetch": "^2.5.12"
+				"@types/node-fetch": "^2.5.12",
+				"jest": "^27.0.6"
 			}
 		},
 		"node_modules/@babel/runtime": {
@@ -1868,6 +1876,7 @@
 				"@types/bcrypt": "^5.0.0",
 				"@types/express": "^4.17.9",
 				"@types/i18next-node-fs-backend": "^2.1.0",
+				"@types/jest": "^27.0.1",
 				"@types/jsonwebtoken": "^8.5.0",
 				"@types/mongodb": "^3.6.9",
 				"@types/mongoose": "^5.10.5",
@@ -1899,8 +1908,8 @@
 				"image-size": "^1.0.0",
 				"jest": "^26.6.3",
 				"jsonwebtoken": "^8.5.1",
-				"lambert-server": "^1.2.8",
-				"missing-native-js-functions": "^1.2.10",
+				"lambert-server": "^1.2.10",
+				"missing-native-js-functions": "^1.2.11",
 				"mongoose": "^5.12.3",
 				"mongoose-autopopulate": "^0.12.3",
 				"mongoose-long": "^0.3.2",
@@ -1909,6 +1918,7 @@
 				"saslprep": "^1.0.3",
 				"ts-node": "^9.1.1",
 				"ts-node-dev": "^1.1.6",
+				"typeorm": "^0.2.37",
 				"typescript": "^4.1.2"
 			}
 		},
@@ -1940,11 +1950,13 @@
 				"file-type": "^16.5.0",
 				"fs-extra": "^10.0.0",
 				"image-size": "^1.0.0",
+				"jest": "^27.0.6",
 				"lambert-db": "^1.2.3",
 				"lambert-server": "^1.2.8",
 				"missing-native-js-functions": "^1.2.10",
 				"multer": "^1.4.2",
 				"node-fetch": "^2.6.1",
+				"supertest": "^6.1.6",
 				"typescript": "^4.1.2",
 				"uuid": "^8.3.2"
 			}
@@ -1981,22 +1993,26 @@
 			"requires": {
 				"@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",
 				"@types/node-fetch": "^2.5.12",
-				"ajv": "^8.5.0",
+				"ajv": "^8.6.2",
 				"amqplib": "^0.8.0",
+				"class-validator": "^0.13.1",
 				"dot-prop": "^6.0.1",
 				"env-paths": "^2.2.1",
+				"jest": "^27.0.6",
 				"jsonwebtoken": "^8.5.1",
-				"missing-native-js-functions": "^1.2.10",
-				"mongodb": "^3.6.9",
-				"mongoose": "^5.13.7",
-				"mongoose-autopopulate": "^0.12.3",
+				"lambert-server": "^1.2.10",
+				"missing-native-js-functions": "^1.2.11",
 				"node-fetch": "^2.6.1",
-				"typescript": "^4.1.3"
+				"patch-package": "^6.4.7",
+				"pg": "^8.7.1",
+				"reflect-metadata": "^0.1.13",
+				"sqlite3": "^5.0.2",
+				"typeorm": "^0.2.37",
+				"typescript": "^4.3.5",
+				"typescript-json-schema": "^0.50.1"
 			}
 		},
 		"@types/amqplib": {
diff --git a/bundle/package.json b/bundle/package.json
index 38377d15..71d7efea 100644
--- a/bundle/package.json
+++ b/bundle/package.json
@@ -5,8 +5,9 @@
 	"main": "src/start.js",
 	"scripts": {
 		"preinstall": "cd ../util && npm i && 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": "npm run build:util && npm run build:api && npm run build:cdn && npm run build:gateway && npm run build:bundle",
 		"build:bundle": "npx tsc -b .",
+		"build:util": "cd ../util/ && npm run build",
 		"build:api": "cd ../api/ && npm run build",
 		"build:cdn": "cd ../cdn/ && npm run build",
 		"build:gateway": "cd ../gateway/ && npm run build",
diff --git a/bundle/src/Database.ts b/bundle/src/Database.ts
deleted file mode 100644
index 12febc1c..00000000
--- a/bundle/src/Database.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-import fs from "fs";
-import { MongoMemoryServer } from "mongodb-memory-server";
-import path from "path";
-import exitHook from "async-exit-hook";
-
-if (process.arch == "ia32") {
-	Object.defineProperty(process, "arch", {
-		value: "x64",
-	});
-}
-
-export async function setupDatabase() {
-	if (process.env.MONGO_URL) return; // exit because the user provides his own mongodb
-	const dbPath = path.join(__dirname, "..", "..", "db");
-	const dbName = "fosscord";
-	const storageEngine = "wiredTiger";
-	const port = 27020;
-	const ip = "127.0.0.1";
-	var mongod: MongoMemoryServer;
-	fs.mkdirSync(dbPath, { recursive: true });
-
-	exitHook((callback: any) => {
-		(async () => {
-			console.log(`Stopping MongoDB ...`);
-			await mongod.stop();
-			console.log(`Stopped MongoDB`);
-			callback();
-		})();
-	});
-
-	console.log(`[Database] starting ...`);
-	mongod = new MongoMemoryServer({
-		instance: {
-			port,
-			ip,
-			dbName,
-			dbPath,
-			storageEngine,
-			auth: false, // by default `mongod` is started with '--noauth', start `mongod` with '--auth'
-		},
-	});
-	await mongod.start();
-	process.env.MONGO_URL = mongod.getUri(dbName);
-}
diff --git a/bundle/src/Server.ts b/bundle/src/Server.ts
index e0586601..56c82cd1 100644
--- a/bundle/src/Server.ts
+++ b/bundle/src/Server.ts
@@ -6,7 +6,7 @@ import { FosscordServer as APIServer } from "@fosscord/api";
 import { Server as GatewayServer } from "@fosscord/gateway";
 import { CDNServer } from "@fosscord/cdn/";
 import express from "express";
-import { Config } from "@fosscord/util";
+import { Config, initDatabase } from "@fosscord/util";
 
 const app = express();
 const server = http.createServer();
@@ -22,6 +22,8 @@ const cdn = new CDNServer({ server, port, production, app });
 const gateway = new GatewayServer({ server, port, production });
 
 async function main() {
+	await initDatabase();
+	await Config.init();
 	await Config.set({
 		cdn: {
 			endpointClient: "${location.host}",
diff --git a/bundle/src/start.ts b/bundle/src/start.ts
index 323995ae..843e3812 100644
--- a/bundle/src/start.ts
+++ b/bundle/src/start.ts
@@ -1,7 +1,6 @@
 // process.env.MONGOMS_DEBUG = "true";
 import cluster from "cluster";
 import os from "os";
-import { setupDatabase } from "./Database";
 import { initStats } from "./stats";
 
 // TODO: add tcp socket event transmission
@@ -12,7 +11,6 @@ if (cluster.isMaster && !process.env.masterStarted) {
 
 	(async () => {
 		initStats();
-		await setupDatabase();
 
 		if (cores === 1) {
 			require("./Server.js");