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,
)
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,
)
) {
return privateKeyFromEnv;
}
throw new Error("invalid GitHub App RSA private key");
const booleanValidatorSpec: ValidatorSpec = bool()
const numberValidatorSpec: ValidatorSpec = num()
const stringValidatorSpec: ValidatorSpec = str()
const jsonValidatorSpec: ValidatorSpec = json()
const urlValidatorSpec: ValidatorSpec = url()
const emailValidatorSpec: ValidatorSpec = email()
const hostValidatorSpec: ValidatorSpec = host()
const portValidatorSpec: ValidatorSpec = port()
const env1: { NODE_ENV: string, ... } = cleanEnv({ NODE_ENV: 'TEST' }, {
NODE_ENV: str()
})
// $ExpectError
const env2: { NODE_ENV: number, ... } = cleanEnv({ NODE_ENV: 'TEST' }, {
NODE_ENV: str()
})
// $ExpectError
const invalidBooleanValidatorSpec: ValidatorSpec = bool()
import {
bool,
cleanEnv,
email,
host,
json,
port,
num,
str,
url,
type ValidatorSpec
} from 'envalid'
const booleanValidatorSpec: ValidatorSpec = bool()
const numberValidatorSpec: ValidatorSpec = num()
const stringValidatorSpec: ValidatorSpec = str()
const jsonValidatorSpec: ValidatorSpec = json()
const urlValidatorSpec: ValidatorSpec = url()
const emailValidatorSpec: ValidatorSpec = email()
const hostValidatorSpec: ValidatorSpec = host()
const portValidatorSpec: ValidatorSpec = port()
const env1: { NODE_ENV: string, ... } = cleanEnv({ NODE_ENV: 'TEST' }, {
NODE_ENV: str()
})
// $ExpectError
const env2: { NODE_ENV: number, ... } = cleanEnv({ NODE_ENV: 'TEST' }, {
NODE_ENV: str()
})
import {
bool,
cleanEnv,
email,
host,
json,
port,
num,
str,
url,
type ValidatorSpec
} from 'envalid'
const booleanValidatorSpec: ValidatorSpec = bool()
const numberValidatorSpec: ValidatorSpec = num()
const stringValidatorSpec: ValidatorSpec = str()
const jsonValidatorSpec: ValidatorSpec = json()
const urlValidatorSpec: ValidatorSpec = url()
const emailValidatorSpec: ValidatorSpec = email()
const hostValidatorSpec: ValidatorSpec = host()
const portValidatorSpec: ValidatorSpec = port()
const env1: { NODE_ENV: string, ... } = cleanEnv({ NODE_ENV: 'TEST' }, {
NODE_ENV: str()
})
// $ExpectError
const env2: { NODE_ENV: number, ... } = cleanEnv({ NODE_ENV: 'TEST' }, {
NODE_ENV: str()
})
const urlValidatorSpec: ValidatorSpec = url()
const emailValidatorSpec: ValidatorSpec = email()
const hostValidatorSpec: ValidatorSpec = host()
const portValidatorSpec: ValidatorSpec = port()
const env1: { NODE_ENV: string, ... } = cleanEnv({ NODE_ENV: 'TEST' }, {
NODE_ENV: str()
})
// $ExpectError
const env2: { NODE_ENV: number, ... } = cleanEnv({ NODE_ENV: 'TEST' }, {
NODE_ENV: str()
})
// $ExpectError
const invalidBooleanValidatorSpec: ValidatorSpec = bool()
json,
port,
num,
str,
url,
type ValidatorSpec
} from 'envalid'
const booleanValidatorSpec: ValidatorSpec = bool()
const numberValidatorSpec: ValidatorSpec = num()
const stringValidatorSpec: ValidatorSpec = str()
const jsonValidatorSpec: ValidatorSpec = json()
const urlValidatorSpec: ValidatorSpec = url()
const emailValidatorSpec: ValidatorSpec = email()
const hostValidatorSpec: ValidatorSpec = host()
const portValidatorSpec: ValidatorSpec = port()
const env1: { NODE_ENV: string, ... } = cleanEnv({ NODE_ENV: 'TEST' }, {
NODE_ENV: str()
})
// $ExpectError
const env2: { NODE_ENV: number, ... } = cleanEnv({ NODE_ENV: 'TEST' }, {
NODE_ENV: str()
})
// $ExpectError
const invalidBooleanValidatorSpec: ValidatorSpec = bool()
cleanEnv,
email,
host,
json,
port,
num,
str,
url,
type ValidatorSpec
} from 'envalid'
const booleanValidatorSpec: ValidatorSpec = bool()
const numberValidatorSpec: ValidatorSpec = num()
const stringValidatorSpec: ValidatorSpec = str()
const jsonValidatorSpec: ValidatorSpec = json()
const urlValidatorSpec: ValidatorSpec = url()
const emailValidatorSpec: ValidatorSpec = email()
const hostValidatorSpec: ValidatorSpec = host()
const portValidatorSpec: ValidatorSpec = port()
const env1: { NODE_ENV: string, ... } = cleanEnv({ NODE_ENV: 'TEST' }, {
NODE_ENV: str()
})
// $ExpectError
const env2: { NODE_ENV: number, ... } = cleanEnv({ NODE_ENV: 'TEST' }, {
NODE_ENV: str()
})
// $ExpectError
const invalidBooleanValidatorSpec: ValidatorSpec = bool()
email,
host,
json,
port,
num,
str,
url,
type ValidatorSpec
} from 'envalid'
const booleanValidatorSpec: ValidatorSpec = bool()
const numberValidatorSpec: ValidatorSpec = num()
const stringValidatorSpec: ValidatorSpec = str()
const jsonValidatorSpec: ValidatorSpec = json()
const urlValidatorSpec: ValidatorSpec = url()
const emailValidatorSpec: ValidatorSpec = email()
const hostValidatorSpec: ValidatorSpec = host()
const portValidatorSpec: ValidatorSpec = port()
const env1: { NODE_ENV: string, ... } = cleanEnv({ NODE_ENV: 'TEST' }, {
NODE_ENV: str()
})
// $ExpectError
const env2: { NODE_ENV: number, ... } = cleanEnv({ NODE_ENV: 'TEST' }, {
NODE_ENV: str()
})
// $ExpectError
const invalidBooleanValidatorSpec: ValidatorSpec = bool()
host,
json,
port,
num,
str,
url,
type ValidatorSpec
} from 'envalid'
const booleanValidatorSpec: ValidatorSpec = bool()
const numberValidatorSpec: ValidatorSpec = num()
const stringValidatorSpec: ValidatorSpec = str()
const jsonValidatorSpec: ValidatorSpec = json()
const urlValidatorSpec: ValidatorSpec = url()
const emailValidatorSpec: ValidatorSpec = email()
const hostValidatorSpec: ValidatorSpec = host()
const portValidatorSpec: ValidatorSpec = port()
const env1: { NODE_ENV: string, ... } = cleanEnv({ NODE_ENV: 'TEST' }, {
NODE_ENV: str()
})
// $ExpectError
const env2: { NODE_ENV: number, ... } = cleanEnv({ NODE_ENV: 'TEST' }, {
NODE_ENV: str()
})
// $ExpectError
const invalidBooleanValidatorSpec: ValidatorSpec = bool()