{"id":14155507,"url":"https://github.com/NobleMajo/typenvy","last_synced_at":"2025-08-06T01:31:41.490Z","repository":{"id":37995159,"uuid":"439415832","full_name":"NobleMajo/typenvy","owner":"NobleMajo","description":"A js\u0026ty environment manager","archived":false,"fork":false,"pushed_at":"2022-12-13T19:36:59.000Z","size":199,"stargazers_count":11,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-30T23:32:35.891Z","etag":null,"topics":["environment","environment-variables","javascript","javascript-library","library","node","nodejs","npm","npm-library","npm-package","typescript","typescript-library"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NobleMajo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-17T17:46:39.000Z","updated_at":"2024-10-29T19:09:11.000Z","dependencies_parsed_at":"2022-09-14T00:21:08.225Z","dependency_job_id":null,"html_url":"https://github.com/NobleMajo/typenvy","commit_stats":null,"previous_names":["majo418/typenvy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NobleMajo%2Ftypenvy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NobleMajo%2Ftypenvy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NobleMajo%2Ftypenvy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NobleMajo%2Ftypenvy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NobleMajo","download_url":"https://codeload.github.com/NobleMajo/typenvy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228821405,"owners_count":17977166,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["environment","environment-variables","javascript","javascript-library","library","node","nodejs","npm","npm-library","npm-package","typescript","typescript-library"],"created_at":"2024-08-17T08:03:44.393Z","updated_at":"2025-08-06T01:31:41.468Z","avatar_url":"https://github.com/NobleMajo.png","language":"TypeScript","funding_links":[],"categories":["typescript"],"sub_categories":[],"readme":"# typenvy (deprecated)\n\n![CI/CD](https://github.com/majo418/typenvy/workflows/Publish/badge.svg)\n![MIT](https://img.shields.io/badge/license-MIT-blue.svg)\n![typescript](https://img.shields.io/badge/dynamic/json?style=plastic\u0026color=blue\u0026label=Typescript\u0026prefix=v\u0026query=devDependencies.typescript\u0026url=https%3A%2F%2Fraw.githubusercontent.com%2Fmajo418%2Ftypenvy%2Fmain%2Fpackage.json)\n![npm](https://img.shields.io/npm/v/typenvy.svg?style=plastic\u0026logo=npm\u0026color=red)\n![github](https://img.shields.io/badge/dynamic/json?style=plastic\u0026color=darkviolet\u0026label=GitHub\u0026prefix=v\u0026query=version\u0026url=https%3A%2F%2Fraw.githubusercontent.com%2Fmajo418%2Ftypenvy%2Fmain%2Fpackage.json)\n\n![](https://img.shields.io/badge/dynamic/json?color=green\u0026label=watchers\u0026query=watchers\u0026suffix=x\u0026url=https%3A%2F%2Fapi.github.com%2Frepos%2Fmajo418%2Ftypenvy)\n![](https://img.shields.io/badge/dynamic/json?color=yellow\u0026label=stars\u0026query=stargazers_count\u0026suffix=x\u0026url=https%3A%2F%2Fapi.github.com%2Frepos%2Fmajo418%2Ftypenvy)\n![](https://img.shields.io/badge/dynamic/json?color=orange\u0026label=subscribers\u0026query=subscribers_count\u0026suffix=x\u0026url=https%3A%2F%2Fapi.github.com%2Frepos%2Fmajo418%2Ftypenvy)\n![](https://img.shields.io/badge/dynamic/json?color=navy\u0026label=forks\u0026query=forks\u0026suffix=x\u0026url=https%3A%2F%2Fapi.github.com%2Frepos%2Fmajo418%2Ftypenvy)\n![](https://img.shields.io/badge/dynamic/json?color=darkred\u0026label=open%20issues\u0026query=open_issues\u0026suffix=x\u0026url=https%3A%2F%2Fapi.github.com%2Frepos%2Fmajo418%2Ftypenvy)\n\n# table of contents \n- [typenvy](#typenvy)\n- [table of contents](#table-of-contents)\n- [About](#about)\n  - [Getting started](#getting-started)\n- [other functions](#other-functions)\n- [npm scripts](#npm-scripts)\n  - [use](#use)\n  - [base scripts](#base-scripts)\n  - [watch mode](#watch-mode)\n- [contribution](#contribution)\n\n# About \n`typenvy` is a environment managment library.\n\n## Getting started\n### 1. install typenvy\n```sh\nnpm i typenvy\n```\n\n### 2. env file\nCreate a example environment file at `./src/env/env.ts`:\n```ts\nimport * as typenvy from \"typenvy\"\nexport const envDefaults = {\n    PRODUCTION: (process.env.NODE_ENV === \"production\") as boolean,\n    VERBOSE: false as boolean,\n\n    PORT: 8080 as number,\n    API_KEY: undefined as string,\n    API_URL: undefined as string,\n}\nexport const envTypes: typenvy.VariablesTypes = {\n    PRODUCTION: [typenvy.TC_BOOLEAN],\n    VERBOSE: [typenvy.TC_BOOLEAN],\n\n    PORT: [typenvy.TC_NUMBER],\n    API_KEY: [typenvy.TC_STRING],\n    API_URL: [typenvy.TC_STRING],\n}\n``` \n\n### 3. env parser\nCreate a example environment parser file at `./src/env/envParser.ts`:\n```ts\nimport { parseEnv } from \"typenvy\"\nimport { envDefaults, envTypes } from \"./env\"\n\nexport const env = parseEnv(\n  envDefaults,\n  envTypes\n)\n  .setProcessEnv()\n  .errExit()\n  .env\nexport default env\n```\n\n### 4. load and print env in \"./src/index.ts\"\n```ts\nimport env from \"./env/envParser\"\n\nconsole.log(\"parser env: \", env)\nconsole.log(\"process env: \", process.env)\n```\n\n### 5. start and error\nIf you run the `index.js` after compile the app throws an error.  \nThis is because in the `env.ts` there is no default value provided for `API_KEY` and `API_URL`.\n\nThere are 3 options to remove this error:\n\n#### 1. Set environment variables\nDefine the variables in your shell:\n```sh\nexport API_KEY=\"qwertzui\"\nexport API_URL=\"https://api.github.io/v2/repo/majo418/testrepo\"\n```\n#### 2. Allow undefined as value\nAllow undefined as environment variable value in `env.ts`:\n```ts\nexport const variablesTypes: typenvy.VariablesTypes = {\n    PRODUCTION: [typenvy.TC_BOOLEAN],\n    VERBOSE: [typenvy.TC_BOOLEAN],\n\n    PORT: [typenvy.TC_NUMBER],\n    API_KEY: [typenvy.TC_STRING, typenvy.TC_UNDEFINED], // \u003c---\n    API_URL: [typenvy.TC_STRING, typenvy.TC_UNDEFINED], // \u003c---\n}\n```\n#### 3. Set a default value\nAllow default environment values in `envParser.ts`:\n```ts\nexport const defaultEnv = {\n    PRODUCTION: (process.env.NODE_ENV === \"production\") as boolean,\n    VERBOSE: false as boolean,\n\n    PORT: 8080 as number,\n    API_KEY: \"myDEfaultAPIkey\" as string,\n    API_URL: \"https://api.cloudflare.com/v1/dns\" as string,\n}\n```\n\n# other functions\nBy using the `parseEnv()` function tou get a `EnvResult\u003cT\u003e`.\nHere are all function of the Environment Result:\n```ts\nexport interface EnvResult\u003cT\u003e {\n  // Overwrite default values\n  overwriteEnv(\n    env: { [key: string]: any }\n  ): EnvResult\u003cT\u003e\n  // Set value if its missing in default values\n  setMissingEnv(\n    env: { [key: string]: any }\n  ): EnvResult\u003cT\u003e\n  // Put all env value as strings into process.env\n  setProcessEnv(): EnvResult\u003cT\u003e\n  // Clear all env values from process.env\n  clearProcessEnv(\n    justEqualValues: boolean = true\n  ): EnvResult\u003cT\u003e\n  // Print env errors to console\n  errPrint(): EnvResult\u003cT\u003e \n  // Throw env errors\n  errThrow(): EnvResult\u003cT\u003e\n  // Exit on error\n  errExit(\n    exitCode: number = 1\n  ): EnvResult\u003cT\u003e | never\n}\n```\n\n# npm scripts\nThe npm scripts are made for linux but can also work on mac and windows.\n## use\nYou can run npm scripts in the project folder like this:\n```sh\nnpm run \u003cscriptname\u003e\n```\nHere is an example:\n```sh\nnpm run test\n```\n\n## base scripts\nYou can find all npm scripts in the `package.json` file.\nThis is a list of the most important npm scripts:\n - test // test the app\n - build // build the app\n - exec // run the app\n - start // build and run the app\n\n## watch mode\nLike this example you can run all npm scripts in watch mode:\n```sh\nnpm run start:watch\n```\n\n# contribution\n - 1. fork the project\n - 2. implement your idea\n - 3. create a pull/merge request\n```ts\n// please create seperated forks for different kind of featues/ideas/structure changes/implementations\n```\n\n---\n**cya ;3**  \n*by majo418*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNobleMajo%2Ftypenvy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNobleMajo%2Ftypenvy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNobleMajo%2Ftypenvy/lists"}