This commit is contained in:
May 2024-05-15 20:54:26 +00:00 committed by GitHub
parent 17db90898f
commit 8d24d1b652
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 27 additions and 13 deletions

View file

@ -1,5 +1,5 @@
PORT= PORT=3000
REQUEST_TIMEOUT= REQUEST_TIMEOUT=3600000
TRUST_PROXY= TRUST_PROXY=
FORCE_SSL= FORCE_SSL=
@ -10,12 +10,14 @@ MAX__DISCORD_FILE_SIZE=
MAX__UPLOAD_ID_LENGTH= MAX__UPLOAD_ID_LENGTH=
TARGET__CHANNEL= TARGET__CHANNEL=
ACCOUNTS__REGISTRATION_ENABLED= ACCOUNTS__REGISTRATION_ENABLED=true
ACCOUNTS__REQUIRED_FOR_UPLOAD= ACCOUNTS__REQUIRED_FOR_UPLOAD=false
MAIL__HOST= MAIL__HOST=
MAIL__PORT= MAIL__PORT=
MAIL__SECURE= MAIL__SECURE=
MAIL__SEND_FROM= MAIL__SEND_FROM=
MAIL__USER= MAIL__USER=
MAIL__PASS= MAIL__PASS=
DATABASE_DIRECTORY=

15
package-lock.json generated
View file

@ -35,6 +35,7 @@
"@types/bytes": "^3.1.1", "@types/bytes": "^3.1.1",
"@types/cookie-parser": "^1.4.3", "@types/cookie-parser": "^1.4.3",
"@types/formidable": "^3.4.5", "@types/formidable": "^3.4.5",
"@types/node": "^20.12.12",
"@types/range-parser": "^1.2.6", "@types/range-parser": "^1.2.6",
"discord-api-types": "^0.37.61", "discord-api-types": "^0.37.61",
"sass": "^1.57.1", "sass": "^1.57.1",
@ -244,9 +245,12 @@
} }
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "18.7.23", "version": "20.12.12",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.23.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz",
"integrity": "sha512-DWNcCHolDq0ZKGizjx2DZjR/PqsYwAcYUJmfMWqtVU2MBMG5Mo+xFZrhGId5r/O5HOuMPyQEcM6KUBp5lBZZBg==" "integrity": "sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==",
"dependencies": {
"undici-types": "~5.26.4"
}
}, },
"node_modules/@types/nodemailer": { "node_modules/@types/nodemailer": {
"version": "6.4.8", "version": "6.4.8",
@ -1824,6 +1828,11 @@
"node": ">=14.17" "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": { "node_modules/unpipe": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",

View file

@ -44,6 +44,7 @@
"@types/bytes": "^3.1.1", "@types/bytes": "^3.1.1",
"@types/cookie-parser": "^1.4.3", "@types/cookie-parser": "^1.4.3",
"@types/formidable": "^3.4.5", "@types/formidable": "^3.4.5",
"@types/node": "^20.12.12",
"@types/range-parser": "^1.2.6", "@types/range-parser": "^1.2.6",
"discord-api-types": "^0.37.61", "discord-api-types": "^0.37.61",
"sass": "^1.57.1", "sass": "^1.57.1",

View file

@ -4,6 +4,7 @@ import { readFile, writeFile } from "fs/promises"
import { FileVisibility } from "./files.js"; import { FileVisibility } from "./files.js";
import { AccountSchemas } from "./schemas/index.js"; import { AccountSchemas } from "./schemas/index.js";
import { z } from "zod" import { z } from "zod"
import Configuration from "./config.js";
// this is probably horrible // this is probably horrible
// but i don't even care anymore // but i don't even care anymore
@ -184,16 +185,15 @@ export namespace files {
* @returns A promise which resolves when accounts.json finishes writing * @returns A promise which resolves when accounts.json finishes writing
*/ */
export function save() { 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)) .catch((err) => console.error(err))
} }
readFile(`${process.cwd()}/.data/accounts.json`) readFile(`${Configuration.dbDir}/accounts.json`)
.then((buf) => { .then((buf) => {
Accounts = JSON.parse(buf.toString()) Accounts = JSON.parse(buf.toString())
}).catch(err => console.error(err)) }).catch(err => console.error(err))
.finally(() => { .finally(() => {
if (!Accounts.find(e => e.admin)) { if (!Accounts.find(e => e.admin))
create("admin","admin",true) create("admin","admin",true)
}
}) })

View file

@ -26,7 +26,8 @@ export interface Configuration {
} }
user: string user: string
pass: string pass: string
} },
dbDir: string
} }
export interface ClientConfiguration { export interface ClientConfiguration {
@ -72,4 +73,5 @@ export default {
user: process.env.MAIL__USER, user: process.env.MAIL__USER,
pass: process.env.MAIL__PASS, pass: process.env.MAIL__PASS,
}, },
dbDir: (process.env.DATABASE_DIRECTORY || `${process.cwd()}/.data/`).replace(/\/$/,""),
} as Configuration } as Configuration