From 8d24d1b65239fa33ff774f504586133263f2f557 Mon Sep 17 00:00:00 2001 From: stringsplit <77242831+nbitzz@users.noreply.github.com> Date: Wed, 15 May 2024 20:54:26 +0000 Subject: [PATCH] uh --- .env.example | 12 +++++++----- package-lock.json | 15 ++++++++++++--- package.json | 1 + src/server/lib/accounts.ts | 8 ++++---- src/server/lib/config.ts | 4 +++- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/.env.example b/.env.example index 76a2d76..c3f28e0 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,5 @@ -PORT= -REQUEST_TIMEOUT= +PORT=3000 +REQUEST_TIMEOUT=3600000 TRUST_PROXY= FORCE_SSL= @@ -10,12 +10,14 @@ MAX__DISCORD_FILE_SIZE= MAX__UPLOAD_ID_LENGTH= TARGET__CHANNEL= -ACCOUNTS__REGISTRATION_ENABLED= -ACCOUNTS__REQUIRED_FOR_UPLOAD= +ACCOUNTS__REGISTRATION_ENABLED=true +ACCOUNTS__REQUIRED_FOR_UPLOAD=false MAIL__HOST= MAIL__PORT= MAIL__SECURE= MAIL__SEND_FROM= MAIL__USER= -MAIL__PASS= \ No newline at end of file +MAIL__PASS= + +DATABASE_DIRECTORY= \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index c21765a..1dd4b00 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,6 +35,7 @@ "@types/bytes": "^3.1.1", "@types/cookie-parser": "^1.4.3", "@types/formidable": "^3.4.5", + "@types/node": "^20.12.12", "@types/range-parser": "^1.2.6", "discord-api-types": "^0.37.61", "sass": "^1.57.1", @@ -244,9 +245,12 @@ } }, "node_modules/@types/node": { - "version": "18.7.23", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.23.tgz", - "integrity": "sha512-DWNcCHolDq0ZKGizjx2DZjR/PqsYwAcYUJmfMWqtVU2MBMG5Mo+xFZrhGId5r/O5HOuMPyQEcM6KUBp5lBZZBg==" + "version": "20.12.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz", + "integrity": "sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==", + "dependencies": { + "undici-types": "~5.26.4" + } }, "node_modules/@types/nodemailer": { "version": "6.4.8", @@ -1824,6 +1828,11 @@ "node": ">=14.17" } }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + }, "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", diff --git a/package.json b/package.json index af8bc38..1efd9f9 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "@types/bytes": "^3.1.1", "@types/cookie-parser": "^1.4.3", "@types/formidable": "^3.4.5", + "@types/node": "^20.12.12", "@types/range-parser": "^1.2.6", "discord-api-types": "^0.37.61", "sass": "^1.57.1", diff --git a/src/server/lib/accounts.ts b/src/server/lib/accounts.ts index 87c2357..5376a8c 100644 --- a/src/server/lib/accounts.ts +++ b/src/server/lib/accounts.ts @@ -4,6 +4,7 @@ import { readFile, writeFile } from "fs/promises" import { FileVisibility } from "./files.js"; import { AccountSchemas } from "./schemas/index.js"; import { z } from "zod" +import Configuration from "./config.js"; // this is probably horrible // but i don't even care anymore @@ -184,16 +185,15 @@ export namespace files { * @returns A promise which resolves when accounts.json finishes writing */ export function save() { - return writeFile(`${process.cwd()}/.data/accounts.json`,JSON.stringify(Accounts)) + return writeFile(`${Configuration.dbDir}/.data/accounts.json`,JSON.stringify(Accounts)) .catch((err) => console.error(err)) } -readFile(`${process.cwd()}/.data/accounts.json`) +readFile(`${Configuration.dbDir}/accounts.json`) .then((buf) => { Accounts = JSON.parse(buf.toString()) }).catch(err => console.error(err)) .finally(() => { - if (!Accounts.find(e => e.admin)) { + if (!Accounts.find(e => e.admin)) create("admin","admin",true) - } }) \ No newline at end of file diff --git a/src/server/lib/config.ts b/src/server/lib/config.ts index e6103c0..9a8dce3 100644 --- a/src/server/lib/config.ts +++ b/src/server/lib/config.ts @@ -26,7 +26,8 @@ export interface Configuration { } user: string pass: string - } + }, + dbDir: string } export interface ClientConfiguration { @@ -72,4 +73,5 @@ export default { user: process.env.MAIL__USER, pass: process.env.MAIL__PASS, }, + dbDir: (process.env.DATABASE_DIRECTORY || `${process.cwd()}/.data/`).replace(/\/$/,""), } as Configuration