This package provides a set of scripts for environment variable validation in Next.js applications. It ensures that your environment variables are set up correctly and adhere to a specified schema.
TODO: Yet to publish the package to npm registry!!
To install the package, run:
npm install env-validationThis will automatically set up the required files and scripts in your project.
Run the following command to create the initial files:
npm run prestartThis command will execute the setup script, generate the initial environment schema, and update the .env.example file.
Edit the envSchema.js file in the root directory to match your application's specific environment requirements.
To update the .env.example file based on the modified schema, run:
npm run updateEnvExampleTo start your Next.js application with environment variable validation, run:
npm startThis command will validate your environment variables against the schema defined in envSchema.js before starting the Next.js application.
-
env-validation/
- src/
- validateEnvironment.js
- scripts/
- setup.js
- updateEnvExample.js
- generateEnvSchema.js
- .gitignore
- .npmignore
- package.json
- README.md
- .env.example
- envSchema.js
- src/
validateEnvironment.js: Script for environment variable validation.setup.js: Script to create the initial .env.example file.updateEnvExample.js: Script to update the .env.example file based on the modified schema.generateEnvSchema.js: Script to generate the initial envSchema.js file with dummy values..env.example: Example file with placeholder values for environment variables.envSchema.js: File containing the schema for environment variables.
Modify the envSchema.js file to match your application's specific environment requirements.