server: improve error message if NODE_ENV is unknown value
This commit is contained in:
parent
64e9c58d5d
commit
24157ff10e
1 changed files with 2 additions and 1 deletions
|
@ -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 = {
|
||||
|
|
Loading…
Reference in a new issue