import { config as configDotenv } from 'dotenv'; import ValidatorJS from 'validator'; configDotenv(); export const config = { internal_port: parseInt(process.env.APP_PORT) || 4010, development: process.env.NODE_ENV === "production", jwt_secret: process.env.JWT_SECRET || "secretjwtsecret", phone_validation_countrycode: process.env.PHONE_COUNTRYCODE || "ZZ", postalcode_validation_countrycode: getPostalCodeLocale(), version: process.env.VERSION || require('../package.json').version } let errors = 0 if (typeof config.internal_port !== "number") { errors++ } if (typeof config.phone_validation_countrycode !== "string") { errors++ } if (config.phone_validation_countrycode.length !== 2) { errors++ } if (typeof config.development !== "boolean") { errors++ } function getPostalCodeLocale(): any { try { const stringArray: String[] = ValidatorJS.isPostalCodeLocales; let index = stringArray.indexOf(process.env.POSTALCODE_COUNTRYCODE); return ValidatorJS.isPostalCodeLocales[index]; } catch (error) { return null; } } export let e = errors