How to use the envalid.cleanEnv function in envalid

To help you get started, we’ve selected a few envalid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tibdex / autorebase / src / tests-utils.ts View on Github external
const createTestContext = async (
  applicationFunction: (app: Application) => void,
): Promise => {
  const env = envalid.cleanEnv(
    // eslint-disable-next-line no-process-env
    process.env,
    {
      TEST_APP_ID: envalid.num({
        desc:
          "The ID of the GitHub App used during tests." +
          " It must have at least the same permissions than the Autorebase GitHub App.",
      }),
      TEST_APP_PRIVATE_KEY: envalid.makeValidator(str => {
        const privateKeyFromEnv = isBase64(str)
          ? Buffer.from(str, "base64").toString("utf8")
          : str;
        if (
          /-----BEGIN RSA PRIVATE KEY-----[\s\S]+-----END RSA PRIVATE KEY-----/m.test(
            privateKeyFromEnv,
          )
github cdmbase / fullstack-pro / servers / frontend-server / src / config / config.ts View on Github external
/// 
import * as envalid from 'envalid';


const { str, bool, num } = envalid;

export const config = envalid.cleanEnv(process.env, {
    NODE_ENV: str({ default: 'production', choices: ['production', 'staging', 'development', 'test'] }),
    BACKEND_URL: str({ devDefault: __BACKEND_URL__ }),
    LOCAL_BACKEND_URL: str({ devDefault: __BACKEND_URL__ }),
    LOCAL_GRAPHQL_URL: str({ default: __GRAPHQL_URL__ }),
    GRAPHQL_URL: str({ devDefault: __GRAPHQL_URL__ }),
    CLIENT_URL: str({ devDefault: __BACKEND_URL__ }),
    CONNECTION_ID: str({ devDefault: 'CONNECTION_ID' }),
    NAMESPACE: str({ default: 'default' }),
});
github reactioncommerce / reaction / imports / node-app / core / config.js View on Github external
import envalid, { bool, makeValidator, str } from "envalid";

const bodyParserValidator = makeValidator((value) => {
  if (typeof value !== "number") throw new Error("Expected type number");
  if (value <= 0) throw new Error("Expected value to be greater than 0");
  return value;
});

export default envalid.cleanEnv(process.env, {
  BODY_PARSER_SIZE_LIMIT: bodyParserValidator({
    default: 5 * 1000000 // value in bytes = 5mb
  }),
  GRAPHQL_INTROSPECTION_ENABLED: bool({ default: false }),
  GRAPHQL_PLAYGROUND_ENABLED: bool({ default: false }),
  MIGRATION_BYPASS_ENABLED: bool({
    default: false,
    desc: "Bypasses migration version checks and migration runs. Enables startup if migration state is not compatible. " +
      "This can be dangerous enough to cause data inconsistencies. Use at your own risk!"
  }),
  // This is necessary to override the envalid default
  // validation for NODE_ENV, which uses
  // str({ choices: ['development', 'test', 'production'] })
  //
  // We currently need to set NODE_ENV to "jesttest" when
  // integration tests run.
github greenkeeperio / greenkeeper / lib / env.js View on Github external
}

if (!process.env.IS_ENTERPRISE) {
  // These environment variables are only relevant for SaaS
  Object.assign(environmentConfig, {
    EMAIL_HOST: str({ devDefault: 'smtp.mandrillapp.com' }),
    EMAIL_PORT: num({ devDefault: 578 }),
    EMAIL_USER: str({ devDefault: 'email@dev.com' }),
    EMAIL_PASSWORD: str({ devDefault: 'emailpassword' }),
    EMAIL_FROM: str({ devDefault: 'support@greenkeeper.io' }),
    ROLLBAR_TOKEN_JOBS: str({ devDefault: '' }),
    STRIPE_SECRET_KEY: str({ devDefault: 'stripe-token' })
  })
}

module.exports = envalid.cleanEnv(process.env, environmentConfig)
github Jordaneisenburger / fallback-studio / src / pwa-studio / packages / venia-concept / validate-environment.js View on Github external
chalk.redBright(
                        `\nNo .env file in ${__dirname}\n\tYou may need to copy '.env.dist' to '.env' to begin, or create your own '.env' file manually.`
                    )
                );
            } else {
                console.warn(
                    chalk.redBright(
                        `\nCould not retrieve and parse ${envPath}.`,
                        e
                    )
                );
            }
        }
    }

    return envalid.cleanEnv(env, validation);
}
github reactioncommerce / reaction / src / plugins / job-queue / config.js View on Github external
import envalid from "envalid";

const { bool } = envalid;

export default envalid.cleanEnv(process.env, {
  REACTION_WORKERS_ENABLED: bool({ default: true }),
  VERBOSE_JOBS: bool({ default: false })
}, {
  dotEnvPath: null
});
github zhenyulin / ultimate-hot-boilerplate / server / constant.js View on Github external
import { cleanEnv, num, str } from 'envalid';

const env = cleanEnv(process.env, {
  PORT: num({ default: 3000 }),
  MONGO_DB_URI: str(),
});

export const { PORT, MONGO_DB_URI } = env;

export default env;
github ctco / nodejs-graphql-template / env.ts View on Github external
import * as envalid from 'envalid';

const { url, bool, str } = envalid;

const env = envalid.cleanEnv(process.env, {
  JOKE_SERVICE_URI: url({default: 'https://api.icndb.com'}),
  GRAPHIQL: bool({default: true}),
  VOYAGER: bool({default: true}),
  CORS: bool({devDefault: true, default: false}),
  NODE_ENV: str({devDefault: 'development'}),
  LOG_LEVEL: str({default: 'info'}),
});

export default env;
github scolladon / sfdc-ci-toolkit / lib / utils / options-builder.js View on Github external
const envalid = require('envalid');
const { str, url, bool, num } = envalid;

const env = envalid.cleanEnv(process.env, {
  SF_VERSION:         str(),
  SF_SERVERURL:       url(),
  SF_TESTLEVEL:       str(),
  SF_TESTSUFFIX:      str(),
  SF_SRC_PATH:        str(),
  SF_REPO_PATH:       str(),
  POST_SCRIPT_PATH:   str(),
  PRE_SCRIPT_PATH:    str()
})

module.exports = {
  'username': env.SF_USERNAME,
  'password': env.SF_PASSWORD,
  'consumerKey': env.SF_CONSUMERKEY,
  'privateKeyPath': env.PRIVATE_KEY_PATH,
  'loginUrl': env.SF_SERVERURL,
github reactioncommerce / reaction / src / plugins / payments-stripe / config.js View on Github external
import envalid from "envalid";

const { str, testOnly } = envalid;

export default envalid.cleanEnv(process.env, {
  STRIPE_API_KEY: str({
    desc: "A private Stripe API key",
    devDefault: testOnly("YOUR_PRIVATE_STRIPE_API_KEY")
  })
}, {
  dotEnvPath: null
});