server: improve error message if NODE_ENV is unknown value

This commit is contained in:
Max Leiter 2022-04-01 16:30:09 -07:00
parent 64e9c58d5d
commit 24157ff10e
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: A3512F2F2F17EBDA

View file

@ -30,13 +30,14 @@ const config = (): Config => {
const validNodeEnvs = (str: string | undefined) => {
const valid = ["development", "production"]
if (str && !valid.includes(str)) {
throw new Error(`Invalid environment variable: ${str}`)
throw new Error(`Invalid NODE_ENV set: ${str}`)
} else if (!str) {
console.warn("No NODE_ENV specified, defaulting to development")
} else {
console.log(`Using NODE_ENV: ${str}`)
}
}
validNodeEnvs(process.env.NODE_ENV)
const config: Config = {