How to use the envalid.port 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
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()
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(),
github mikesparr / typescript-postgres-auth-example / src / utils / env.validator.ts View on Github external
function validateEnv() {
  cleanEnv(process.env, {
    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(),
  });
}
github mikesparr / typescript-postgres-auth-example / src / utils / env.validator.ts View on Github external
function validateEnv() {
  cleanEnv(process.env, {
    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(),
  });
}
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 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(),
  });
};