Skip to content

Generate a .d.ts and .env.example file from your .env file

Notifications You must be signed in to change notification settings

AsyncLegs/gen-env-types

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gen-env-types

Takes your .env file as input

SESSION_SECRET=asdjpfowqip
STRIPE_ACCESS_TOKEN=qoi120wqe

And generates a .d.ts file

declare namespace NodeJS {
  export interface ProcessEnv {
    SESSION_SECRET: string;
    STRIPE_ACCESS_TOKEN: string;
  }
}

Now process.env.SESSION_SECRET will autocomplete and be type-safe.

Usage

npx gen-env-types path/to/.env

Options

  -V, --version               Show version number
  -h, --help                  Show usage information
  -o, --types-output          Output name/path for types file | defaults to `env.d.ts`
  -e, --example-env-path      Path to save .env.example file

Example with options

npx gen-env-types .env -o src/types/env.d.ts -e .

About

Generate a .d.ts and .env.example file from your .env file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%