api: alias deprecated envs to maintain backwards compatibility

This commit is contained in:
dumbmoron 2024-03-05 13:41:22 +00:00
parent 0f515498dc
commit 12833e1827
No known key found for this signature in database
GPG key ID: C59997C76C6A8E5F
2 changed files with 23 additions and 0 deletions

View file

@ -1,4 +1,5 @@
import "dotenv/config";
import "./modules/sub/alias-envs.js";
import express from "express";

View file

@ -0,0 +1,22 @@
import { Red } from "./consoleText.js";
const mapping = {
apiPort: 'API_PORT',
apiURL: 'API_URL',
apiName: 'API_NAME',
cors: 'CORS_WILDCARD',
cookiePath: 'COOKIE_PATH',
webPort: 'WEB_PORT',
webUrl: 'WEB_URL',
showSponsors: 'SHOW_SPONSORS',
isBeta: 'IS_BETA'
}
for (const [ oldEnv, newEnv ] of Object.entries(mapping)) {
if (process.env[oldEnv] && !process.env[newEnv]) {
process.env[newEnv] = process.env[oldEnv];
console.error(`${Red('[!]')} ${oldEnv} is deprecated and will be removed in a future version.`);
console.error(` You should use ${newEnv} instead.`);
console.error();
}
}