Files
freeCodeCamp/tools/contributor/lib/config.js
Oliver Eyton-Williams c8d7f0a782 feat(tools): remove eslint-plugin-prettier for prettier (#42438)
* feat: remove eslint-plugin-prettier for prettier

This removes the annoying lint warnings when all that needs to change is
formatting

* fix: use .js lint-staged config to ignore properly

* fix: lint everything if a lot of files are changed

It's faster than making lots of individual linter calls

* chore: apply prettier

* fix: ignore code in curriculum-file-structure
2021-10-06 21:02:21 +05:30

45 lines
1.2 KiB
JavaScript

const Joi = require('joi');
const path = require('path');
require('dotenv').config({ path: path.resolve(__dirname, '../.env') });
// define validation for all the env vars
const envVarsSchema = Joi.object({
NODE_ENV: Joi.string()
.allow(['development', 'production', 'test', 'provision'])
.default('development'),
PORT: Joi.number().default(3001),
MONGO_HOST: Joi.string().required().description('Mongo DB host url'),
GITHUB_USERNAME: Joi.string().required(),
GITHUB_ACCESS_TOKEN: Joi.string().required(),
REPOSITORY_OWNER: Joi.string().required(),
REPOSITORY: Joi.string().required(),
DEFAULT_BASE: Joi.string().required(),
PRODUCTION_RUN: Joi.boolean().default(false)
})
.unknown()
.required();
const { error, value: envVars } = Joi.validate(process.env, envVarsSchema);
if (error) {
throw new Error(`Config validation error: ${error.message}`);
}
const config = {
env: envVars.NODE_ENV,
mongo: {
host: envVars.MONGO_HOST
},
github: {
id: envVars.GITHUB_USERNAME,
secret: envVars.GITHUB_ACCESS_TOKEN,
owner: envVars.REPOSITORY_OWNER,
freeCodeCampRepo: envVars.REPOSITORY,
defaultBase: envVars.DEFAULT_BASE
},
oneoff: {
productionRun: envVars.PRODUCTION_RUN
}
};
module.exports = config;