Throw an error if requried env vars are missing

This commit is contained in:
Grzegorz Leoniec 2019-01-04 15:15:07 +01:00
parent e9bc848a33
commit 30d4318d17
No known key found for this signature in database
GPG Key ID: 3AA43686D4EB1377

View File

@ -14,6 +14,13 @@ import jwtStrategy from './jwt/strategy'
import jwt from 'jsonwebtoken'
dotenv.config()
// check env and warn
const requiredEnvVars = ['MAPBOX_TOKEN', 'JWT_SECRET']
requiredEnvVars.forEach(env => {
if (!process.env[env]) {
throw new Error(`ERROR: "${env}" env variable is missing`)
}
})
let schema = makeExecutableSchema({
typeDefs,