How to use the envalid.str 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 flow-typed / flow-typed / definitions / npm / envalid_v4.x.x / flow_v0.104.x- / test_envalid_v4.x.x.js View on Github external
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()
github SolidZORO / leaa / packages / leaa-api / src / modules / config / config.service.ts View on Github external
const rule = {
      PROTOCOL: envalid.str({ choices: ['http', 'https'], default: 'http' }),
      PORT: envalid.port({ default: 5555 }),
      //
      DEMO_MODE: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      DEBUG_MODE: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      //
      BASE_HOST: envalid.str(),
      PUBLIC_DIR: envalid.str(),
      ATTACHMENT_DIR: envalid.str(),
      ATTACHMENT_LIMIT_SIZE_MB: envalid.num(),
      ATTACHMENT_SAVE_IN_LOCAL: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      ATTACHMENT_SAVE_IN_OSS: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      //
      DB_TYPE: envalid.str({ choices: ['mysql'], default: 'mysql' }),
      DB_HOST: envalid.str(),
      DB_PORT: envalid.num(),
      DB_USER: envalid.str(),
      DB_PASSWORD: envalid.str(),
      DB_DATABASE: envalid.str(),
      DB_SYNCHRONIZE: envalid.str(),
      //
      TRUST_PROXY: envalid.str(),
      JWT_SECRET_KEY: envalid.str(),
      CLIENT_COOKIE_EXPIRES_SECOND: envalid.num(),
      SERVER_COOKIE_EXPIRES_SECOND: envalid.num(),
      //
      // OSS_ALIYUN_BUCKET: envalid.str(),
      // OSS_ALIYUN_AK_SECRET: envalid.str(),
      // OSS_ALIYUN_AK_ID: envalid.str(),
      // OSS_ALIYUN_REGION: envalid.str(),
      // OSS_ALIYUN_ASSUME_ROLE: envalid.str(),
github SolidZORO / leaa / packages / leaa-api / src / modules / config / config.service.ts View on Github external
private validate(dotEnvPath: string): IDotEnv {
    const rule = {
      PROTOCOL: envalid.str({ choices: ['http', 'https'], default: 'http' }),
      PORT: envalid.port({ default: 5555 }),
      //
      DEMO_MODE: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      DEBUG_MODE: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      //
      BASE_HOST: envalid.str(),
      PUBLIC_DIR: envalid.str(),
      ATTACHMENT_DIR: envalid.str(),
      ATTACHMENT_LIMIT_SIZE_MB: envalid.num(),
      ATTACHMENT_SAVE_IN_LOCAL: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      ATTACHMENT_SAVE_IN_OSS: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      //
      DB_TYPE: envalid.str({ choices: ['mysql'], default: 'mysql' }),
      DB_HOST: envalid.str(),
      DB_PORT: envalid.num(),
      DB_USER: envalid.str(),
      DB_PASSWORD: envalid.str(),
      DB_DATABASE: envalid.str(),
      DB_SYNCHRONIZE: envalid.str(),
      //
      TRUST_PROXY: envalid.str(),
      JWT_SECRET_KEY: envalid.str(),
      CLIENT_COOKIE_EXPIRES_SECOND: envalid.num(),
      SERVER_COOKIE_EXPIRES_SECOND: envalid.num(),
      //
      // OSS_ALIYUN_BUCKET: envalid.str(),
github SolidZORO / leaa / packages / leaa-api / src / modules / config / config.service.ts View on Github external
DEBUG_MODE: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      //
      BASE_HOST: envalid.str(),
      PUBLIC_DIR: envalid.str(),
      ATTACHMENT_DIR: envalid.str(),
      ATTACHMENT_LIMIT_SIZE_MB: envalid.num(),
      ATTACHMENT_SAVE_IN_LOCAL: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      ATTACHMENT_SAVE_IN_OSS: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      //
      DB_TYPE: envalid.str({ choices: ['mysql'], default: 'mysql' }),
      DB_HOST: envalid.str(),
      DB_PORT: envalid.num(),
      DB_USER: envalid.str(),
      DB_PASSWORD: envalid.str(),
      DB_DATABASE: envalid.str(),
      DB_SYNCHRONIZE: envalid.str(),
      //
      TRUST_PROXY: envalid.str(),
      JWT_SECRET_KEY: envalid.str(),
      CLIENT_COOKIE_EXPIRES_SECOND: envalid.num(),
      SERVER_COOKIE_EXPIRES_SECOND: envalid.num(),
      //
      // OSS_ALIYUN_BUCKET: envalid.str(),
      // OSS_ALIYUN_AK_SECRET: envalid.str(),
      // OSS_ALIYUN_AK_ID: envalid.str(),
      // OSS_ALIYUN_REGION: envalid.str(),
      // OSS_ALIYUN_ASSUME_ROLE: envalid.str(),
      //
      // OAUTH_WECHAT_APP_ID: envalid.str(),
      // OAUTH_WECHAT_APP_SECRET: envalid.str(),
      // OAUTH_WECHAT_MINIPROGRAM_APP_ID: envalid.str(),
      // OAUTH_WECHAT_MINIPROGRAM_APP_SECRET: envalid.str(),
github SolidZORO / leaa / packages / leaa-api / src / modules / config / config.service.ts View on Github external
DEMO_MODE: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      DEBUG_MODE: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      //
      BASE_HOST: envalid.str(),
      PUBLIC_DIR: envalid.str(),
      ATTACHMENT_DIR: envalid.str(),
      ATTACHMENT_LIMIT_SIZE_MB: envalid.num(),
      ATTACHMENT_SAVE_IN_LOCAL: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      ATTACHMENT_SAVE_IN_OSS: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      //
      DB_TYPE: envalid.str({ choices: ['mysql'], default: 'mysql' }),
      DB_HOST: envalid.str(),
      DB_PORT: envalid.num(),
      DB_USER: envalid.str(),
      DB_PASSWORD: envalid.str(),
      DB_DATABASE: envalid.str(),
      DB_SYNCHRONIZE: envalid.str(),
      //
      TRUST_PROXY: envalid.str(),
      JWT_SECRET_KEY: envalid.str(),
      CLIENT_COOKIE_EXPIRES_SECOND: envalid.num(),
      SERVER_COOKIE_EXPIRES_SECOND: envalid.num(),
      //
      // OSS_ALIYUN_BUCKET: envalid.str(),
      // OSS_ALIYUN_AK_SECRET: envalid.str(),
      // OSS_ALIYUN_AK_ID: envalid.str(),
      // OSS_ALIYUN_REGION: envalid.str(),
      // OSS_ALIYUN_ASSUME_ROLE: envalid.str(),
      //
      // OAUTH_WECHAT_APP_ID: envalid.str(),
      // OAUTH_WECHAT_APP_SECRET: envalid.str(),
      // OAUTH_WECHAT_MINIPROGRAM_APP_ID: envalid.str(),
github SolidZORO / leaa / packages / leaa-api / src / modules / config / config.service.ts View on Github external
private validate(dotEnvPath: string): IDotEnv {
    const rule = {
      PROTOCOL: envalid.str({ choices: ['http', 'https'], default: 'http' }),
      PORT: envalid.port({ default: 5555 }),
      //
      DEMO_MODE: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      DEBUG_MODE: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      //
      BASE_HOST: envalid.str(),
      PUBLIC_DIR: envalid.str(),
      ATTACHMENT_DIR: envalid.str(),
      ATTACHMENT_LIMIT_SIZE_MB: envalid.num(),
      ATTACHMENT_SAVE_IN_LOCAL: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      ATTACHMENT_SAVE_IN_OSS: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      //
      DB_TYPE: envalid.str({ choices: ['mysql'], default: 'mysql' }),
      DB_HOST: envalid.str(),
      DB_PORT: envalid.num(),
      DB_USER: envalid.str(),
      DB_PASSWORD: envalid.str(),
      DB_DATABASE: envalid.str(),
      DB_SYNCHRONIZE: envalid.str(),
      //
      TRUST_PROXY: envalid.str(),
      JWT_SECRET_KEY: envalid.str(),
      CLIENT_COOKIE_EXPIRES_SECOND: envalid.num(),
      SERVER_COOKIE_EXPIRES_SECOND: envalid.num(),
      //
      // OSS_ALIYUN_BUCKET: envalid.str(),
      // OSS_ALIYUN_AK_SECRET: envalid.str(),
github SolidZORO / leaa / packages / leaa-api / src / modules / config / config.service.ts View on Github external
PUBLIC_DIR: envalid.str(),
      ATTACHMENT_DIR: envalid.str(),
      ATTACHMENT_LIMIT_SIZE_MB: envalid.num(),
      ATTACHMENT_SAVE_IN_LOCAL: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      ATTACHMENT_SAVE_IN_OSS: envalid.str({ choices: ['true', 'false'], default: 'false' }),
      //
      DB_TYPE: envalid.str({ choices: ['mysql'], default: 'mysql' }),
      DB_HOST: envalid.str(),
      DB_PORT: envalid.num(),
      DB_USER: envalid.str(),
      DB_PASSWORD: envalid.str(),
      DB_DATABASE: envalid.str(),
      DB_SYNCHRONIZE: envalid.str(),
      //
      TRUST_PROXY: envalid.str(),
      JWT_SECRET_KEY: envalid.str(),
      CLIENT_COOKIE_EXPIRES_SECOND: envalid.num(),
      SERVER_COOKIE_EXPIRES_SECOND: envalid.num(),
      //
      // OSS_ALIYUN_BUCKET: envalid.str(),
      // OSS_ALIYUN_AK_SECRET: envalid.str(),
      // OSS_ALIYUN_AK_ID: envalid.str(),
      // OSS_ALIYUN_REGION: envalid.str(),
      // OSS_ALIYUN_ASSUME_ROLE: envalid.str(),
      //
      // OAUTH_WECHAT_APP_ID: envalid.str(),
      // OAUTH_WECHAT_APP_SECRET: envalid.str(),
      // OAUTH_WECHAT_MINIPROGRAM_APP_ID: envalid.str(),
      // OAUTH_WECHAT_MINIPROGRAM_APP_SECRET: envalid.str(),
      // OAUTH_WECHAT_TOKEN: envalid.str(),
      // OAUTH_WECHAT_REDIRECT_URL: envalid.str(),
    };
github mwanago / express-typescript / src / utils / validateEnv.ts View on Github external
function validateEnv() {
  cleanEnv(process.env, {
    JWT_SECRET: str(),
    MONGO_PASSWORD: str(),
    MONGO_PATH: str(),
    MONGO_USER: str(),
    PORT: port(),
  });
}
github mikesparr / typescript-postgres-auth-example / src / utils / validation.helper.ts View on Github external
const validateEnv = () => {
  cleanEnv(process.env, {
    API_BASE_URL: url(),
    CLIENT_REDIRECT_URL: url(),
    EMAIL_FROM_DEFAULT: str(),
    EMAIL_TO_DEFAULT: str(),
    JWT_SECRET: str(),
    OPEN_CAGE_DATA_KEY: str(),
    PORT: port(),
    POSTGRES_DB: str(),
    POSTGRES_HOST: str(),
    POSTGRES_PASSWORD: str(),
    POSTGRES_PORT: port(),
    POSTGRES_USER: str(),
    REDIS_URL: str(),
    SENDGRID_API_KEY: str(),
  });
};
github poanetwork / tokenbridge-contracts / deploy / src / loadEnv.js View on Github external
}

if (!validRewardModes.includes(HOME_REWARDABLE)) {
  throw new Error(
    `Invalid HOME_REWARDABLE: ${HOME_REWARDABLE}. Supported values are ${validRewardModes}`
  )
}

if (!validRewardModes.includes(FOREIGN_REWARDABLE)) {
  throw new Error(
    `Invalid FOREIGN_REWARDABLE: ${FOREIGN_REWARDABLE}. Supported values are ${validRewardModes}`
  )
}

let validations = {
  DEPLOYMENT_ACCOUNT_PRIVATE_KEY: envalid.str(),
  DEPLOYMENT_GAS_LIMIT_EXTRA: envalid.num(),
  HOME_DEPLOYMENT_GAS_PRICE: bigNumValidator(),
  FOREIGN_DEPLOYMENT_GAS_PRICE: bigNumValidator(),
  GET_RECEIPT_INTERVAL_IN_MILLISECONDS: bigNumValidator(),
  HOME_RPC_URL: envalid.str(),
  HOME_BRIDGE_OWNER: addressValidator(),
  HOME_VALIDATORS_OWNER: addressesValidator(),
  HOME_UPGRADEABLE_ADMIN: addressValidator(),
  HOME_DAILY_LIMIT: bigNumValidator(),
  HOME_MAX_AMOUNT_PER_TX: bigNumValidator(),
  HOME_MIN_AMOUNT_PER_TX: bigNumValidator(),
  HOME_REQUIRED_BLOCK_CONFIRMATIONS: envalid.num(),
  HOME_GAS_PRICE: bigNumValidator(),
  FOREIGN_RPC_URL: envalid.str(),
  FOREIGN_BRIDGE_OWNER: addressValidator(),
  FOREIGN_VALIDATORS_OWNER: addressValidator(),