api & web: ports in env are no longer strictly required

This commit is contained in:
wukko
2023-12-02 22:01:58 +06:00
parent 3e8c059a3a
commit afab7f94a7
4 changed files with 13 additions and 11 deletions

View File

@@ -139,9 +139,9 @@ export function runAPI(express, app, gitCommit, gitBranch, __dirname) {
version: version,
commit: gitCommit,
branch: gitBranch,
name: process.env.apiName ? process.env.apiName : "unknown",
name: process.env.apiName || "unknown",
url: process.env.apiURL,
cors: process.env.cors && process.env.cors === "0" ? 0 : 1,
cors: process.env?.cors === "0" ? 0 : 1,
startTime: `${startTimestamp}`
});
default:
@@ -167,12 +167,12 @@ export function runAPI(express, app, gitCommit, gitBranch, __dirname) {
res.redirect('/api/json')
});
app.listen(process.env.apiPort, () => {
app.listen(process.env.apiPort || 9000, () => {
console.log(`\n` +
`${Cyan("cobalt")} API ${Bright(`v.${version}-${gitCommit} (${gitBranch})`)}\n` +
`Start time: ${Bright(`${startTime.toUTCString()} (${startTimestamp})`)}\n\n` +
`URL: ${Cyan(`${process.env.apiURL}`)}\n` +
`Port: ${process.env.apiPort}\n`
`Port: ${process.env.apiPort || 9000}\n`
)
});
}