https://github.com/boxpositron/vre
Check if environmental variables exist and verify if their types
https://github.com/boxpositron/vre
dotenv nodejs package runtime typescript validation
Last synced: 3 days ago
JSON representation
Check if environmental variables exist and verify if their types
- Host: GitHub
- URL: https://github.com/boxpositron/vre
- Owner: boxpositron
- License: mit
- Created: 2022-10-30T12:42:21.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-30T17:03:53.000Z (over 3 years ago)
- Last Synced: 2026-04-22T09:46:22.780Z (2 months ago)
- Topics: dotenv, nodejs, package, runtime, typescript, validation
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@boxpositron/vre
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Validate Runtime
Check if environmental variables exist and verify if their types
## installation
```shell
pnpm install @boxpositron/vre
or
npm install @boxpositron/vre
or
yarn add @boxpositron/vre
```
## Usage
Call the validate package the moment your application starts up and has loaded its environment. If there are missing environmental variables, the application will exit whilst displaying the missing parameters.
### Typescript
```ts
import validate, { RequiredEnvironmentTypes } from "validate-runtime-environment";
// Ensure you saturate your environment before calling validate
// You can use the dotenv package
// import dotenv from "dotenv";
// dotenv.config()
validate([
{
name: "MONGODB_URI",
type: RequiredEnvironmentTypes.String, // "string"
},
{
name: "PORT",
type: RequiredEnvironmentTypes.Number, // "number"
}
]);
```js
### Javascript
```ts
const validate = require("@boxpositron/vre").default;
// Ensure you saturate your environment before calling validate
// You can use the dotenv package
// import dotenv from "dotenv";
// dotenv.config()
validate([
{
name: "MONGODB_URI",
type: "string",
},
{
name: "PORT",
type: "number",
}
]);
```