mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
check if config variables are present only when server is started
This commit is contained in:
parent
a1db7fa201
commit
15bfabcefd
@ -2,37 +2,30 @@ import dotenv from 'dotenv'
|
||||
|
||||
dotenv.config()
|
||||
|
||||
const requiredConfigs = {
|
||||
export const requiredConfigs = {
|
||||
MAPBOX_TOKEN: process.env.MAPBOX_TOKEN,
|
||||
JWT_SECRET: process.env.JWT_SECRET,
|
||||
PRIVATE_KEY_PASSPHRASE: process.env.PRIVATE_KEY_PASSPHRASE,
|
||||
}
|
||||
|
||||
const neo4jConfigs = {
|
||||
export const neo4jConfigs = {
|
||||
NEO4J_URI: process.env.NEO4J_URI || 'bolt://localhost:7687',
|
||||
NEO4J_USERNAME: process.env.NEO4J_USERNAME || 'neo4j',
|
||||
NEO4J_PASSWORD: process.env.NEO4J_PASSWORD || 'neo4j',
|
||||
}
|
||||
|
||||
const serverConfigs = {
|
||||
export const serverConfigs = {
|
||||
GRAPHQL_PORT: process.env.GRAPHQL_PORT || 4000,
|
||||
CLIENT_URI: process.env.CLIENT_URI || 'http://localhost:3000',
|
||||
GRAPHQL_URI: process.env.GRAPHQL_URI || 'http://localhost:4000',
|
||||
}
|
||||
|
||||
const developmentConfigs = {
|
||||
export const developmentConfigs = {
|
||||
DEBUG: process.env.NODE_ENV !== 'production' && process.env.DEBUG === 'true',
|
||||
MOCKS: process.env.MOCKS === 'true',
|
||||
DISABLED_MIDDLEWARES: process.env.DISABLED_MIDDLEWARES || '',
|
||||
}
|
||||
|
||||
// check required configs and throw error
|
||||
Object.entries(requiredConfigs).map(entry => {
|
||||
if (!entry[1]) {
|
||||
throw new Error(`ERROR: "${entry[0]}" env variable is missing.`)
|
||||
}
|
||||
})
|
||||
|
||||
export default {
|
||||
...requiredConfigs,
|
||||
...neo4jConfigs,
|
||||
|
||||
@ -8,6 +8,13 @@ import { getDriver } from './bootstrap/neo4j'
|
||||
import decode from './jwt/decode'
|
||||
import schema from './schema'
|
||||
|
||||
// check required configs and throw error
|
||||
Object.entries(CONFIG.requiredConfigs).map(entry => {
|
||||
if (!entry[1]) {
|
||||
throw new Error(`ERROR: "${entry[0]}" env variable is missing.`)
|
||||
}
|
||||
})
|
||||
|
||||
const driver = getDriver()
|
||||
|
||||
const createServer = options => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user