refactor: centralize envs and their defaults in modules/config (#464)

* feat(config): centralized env variables and their default values

* fix: fip `corsWildcard` variable check in `corsConfig`

* fix(config): use already declared variables and default some strings to undefined

* fix: check processingPriority against NaN
This commit is contained in:
jsopn
2024-04-29 18:56:05 +07:00
committed by GitHub
parent d780192ada
commit 5fbf35a8d3
10 changed files with 68 additions and 42 deletions

View File

@@ -1,4 +1,4 @@
import { genericUserAgent, version } from "../modules/config.js";
import { genericUserAgent, version, env } from "../modules/config.js";
import { apiJSON, languageCode } from "../modules/sub/utils.js";
import { Bright, Cyan } from "../modules/sub/consoleText.js";
@@ -76,12 +76,12 @@ export async function runWeb(express, app, gitCommit, gitBranch, __dirname) {
return res.redirect('/')
});
app.listen(process.env.WEB_PORT || 9001, () => {
app.listen(env.webPort, () => {
console.log(`\n` +
`${Cyan("cobalt")} WEB ${Bright(`v.${version}-${gitCommit} (${gitBranch})`)}\n` +
`Start time: ${Bright(`${startTime.toUTCString()} (${startTimestamp})`)}\n\n` +
`URL: ${Cyan(`${process.env.WEB_URL}`)}\n` +
`Port: ${process.env.WEB_PORT || 9001}\n`
`URL: ${Cyan(`${env.webURL}`)}\n` +
`Port: ${env.webPort}\n`
)
})
}