Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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,
)
///
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' }),
});
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.
}
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)
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);
}
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
});
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;
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;
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,
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
});