How to use the envalid.url 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
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()
github chainpoint / chainpoint-cli / lib / parse-env.js View on Github external
* distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

const envalid = require('envalid')
const config = require('./config.js')

let envDefinitions = {
  // ***********************************************************************
  // * Global variables with default values
  // ***********************************************************************

  // Chainpoint service location
  CHAINPOINT_NODE_API_BASE_URI: envalid.url({
    default: 'http://0.0.0.0',
    desc: 'Base URI for the Chainpoint Node instance to consume'
  })
}

module.exports = envalid.cleanEnv(process.env, envDefinitions, {
  strict: true,
  dotEnvPath: config.pathToConfigFile
})
github tibdex / autorebase / src / tests-utils.ts View on Github external
throw new Error("invalid GitHub App RSA private key");
      })({
        docs:
          "https://developer.github.com/apps/building-integrations/setting-up-and-registering-github-apps/registering-github-apps/#generating-a-private-key",
      }),
      TEST_INSTALLATION_ID: envalid.num({
        desc:
          'Can be found in the "Installed GitHub Apps" section of the developer settings',
      }),
      TEST_REPOSITORY_NAME: envalid.str({
        desc: "Name of the repository against which the tests will be run",
      }),
      TEST_REPOSITORY_OWNER: envalid.str({
        desc: "Owner of the repository against which the tests will be run.",
      }),
      TEST_SMEE_URL: envalid.url({
        desc: "The smee URL used as the webhook URL of the test APP.",
      }),
      TEST_WEBHOOK_SECRET: envalid.str({
        desc: "The webhook secret used by the test App.",
      }),
    },
    { strict: true },
  );

  const repo = env.TEST_REPOSITORY_NAME;
  const owner = env.TEST_REPOSITORY_OWNER;
  const privateKey = env.TEST_APP_PRIVATE_KEY as string;

  const probot = createProbot({
    cert: privateKey,
    id: env.TEST_APP_ID,
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(),
  });
};