{"id":15311771,"url":"https://github.com/aslemammad/coffee","last_synced_at":"2025-10-08T21:30:44.033Z","repository":{"id":105995957,"uuid":"274425880","full_name":"Aslemammad/coffee","owner":"Aslemammad","description":"Deno Configuration","archived":false,"fork":true,"pushed_at":"2020-07-08T13:44:22.000Z","size":51,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-29T15:23:27.803Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"irandeno/coffee","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Aslemammad.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,"governance":null}},"created_at":"2020-06-23T14:22:05.000Z","updated_at":"2020-07-08T13:37:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"ff46d908-41b4-422b-8f8a-198bcbd980ab","html_url":"https://github.com/Aslemammad/coffee","commit_stats":{"total_commits":27,"total_committers":4,"mean_commits":6.75,"dds":0.2592592592592593,"last_synced_commit":"d549402d73dd8a8e0de3e2c6710da25b2acae1bb"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aslemammad%2Fcoffee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aslemammad%2Fcoffee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aslemammad%2Fcoffee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aslemammad%2Fcoffee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aslemammad","download_url":"https://codeload.github.com/Aslemammad/coffee/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219877266,"owners_count":16554910,"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":[],"created_at":"2024-10-01T08:34:29.212Z","updated_at":"2025-10-08T21:30:38.745Z","avatar_url":"https://github.com/Aslemammad.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![coffee](https://i.ibb.co/xHw5pkq/coffee.png)\n\nType-safe, Easy To Use, \u003cb\u003eDeno Configuration\u003c/b\u003e\n\n## Getting Started\nGetting started with coffee is as easy as writing two lines of code ...\n\n```ts\n// coffee.ts\nimport coffee from \"https://deno.land/x/coffee/mod.ts\";\nconst dbName: string = coffee.get(\"database.name\").string();\n```\n```json\n- coffee.ts\n- config\n  - default.json\n\n// default.json\n{\n  \"database\": {\n    \"name\": \"my-db-name\",\n  }\n}\n```\nand run \n```shell\ndeno run --allow-read --allow-env coffee.ts\n```\n\n## Type Safety\ncoffee's goal is to have the most safe types, so you can get the configurations in the desired types.\n```ts\nconst name: string = coffee.get(\"person.name\").string();\nconst age: number = coffee.get(\"person.age\").number();\nconst passed: boolean = coffee.get(\"person.test.passed\").boolean();\n```\n_**NOTE**_\n\ncoffee saves raw, unknown type values in `value` property of result of `get` method.\n```ts\nconst magical: unknown = coffee.get(\"person.superpower\").value;\n```\n\n## Has \u0026 Set\ncheck configuration is available on config files with `has` method and set new configuration during runtume with `set`.\n```ts\ncoffee.has(\"requests.limit\"); // false\ncoffee.set(\"requests.limit\" , 100);\ncoffee.has(\"requests.limit\"); // true\n```\n\n## Custom Environment Variables\nIf you want to use environment variables, just create a file called `custom-environment-variable` and give it values that you want to read from environment variables.\n```json\nENV_NAME=coffee\n\n- coffee.ts\n- config\n  - custom-environment-variables.json\n\n  // custom-environment-variables.json \n  {\n   \"name\" : \"ENV_NAME\"\n  }\n```\n```ts\n// coffee.ts\nimport coffee from \"https://deno.land/x/coffee/mod.ts\";\nconst name: string = coffee.get(\"database.name\").string(); // coffee, reads from ENV_NAME environment variable\n```\n\n## Related Environment Variables\ncoffee can read related environment variables from desired environment specified in `DENO_ENV` env.\n```json\nDENO_ENV=production\n\n- coffee.ts\n- config\n  - production.json\n\n  // production.json\n  {\n   \"something\" : \"amazing\"\n  }\n```\n```ts\n// coffee.ts\nimport coffee from \"https://deno.land/x/coffee/mod.ts\";\nconst name: string = coffee.get(\"something\").string();\n```\n\n## Customize Coffee Load\ncoffee can read the configurations from the desired directory.\n```\n- coffee.ts\n- custom\n  - default.json\n  - cev.json\n  - production.json\n```\n```ts\n// coffee.ts\nimport coffee from \"https://deno.land/x/coffee/mod.ts\";\ncoffee.load({ \n   configDir: \"./custom\", // specify the custom config directory\n   customEnvVarFileName: \"cev\", // specify the desired custom environment variable config file name\n   env: \"production\" // force relative environment variables to loads from this env\n},);\nconst dbName: string = coffee.get(\"database.name\").string();\n```\n\n## Error Handling\ncoffee tries to make a specific Error for each situation.\n```ts\nimport coffee, { errors } from \"../mod.ts\";\n\ntry {\n  coffee.load({ configDir: \"./bad-config-dir\" });\n} catch (e) {\n  if (e instanceof errors.NoConfigDir) {\n    // now IDE knows about \"e\" and can provide hints.\n    e.message; // \"./bad-config-dir\" directory is not exists.\n  }\n}\n```\n\nthere are 4 kinds of Error Classes that exported from coffee module:\n\n`NoConfigDir` : throwed when no config dir available.\n\n`NoConfigFile` : throwed when there is no valid config file in config directory.\n\n`BadConfigPath` : throwed when tries to get an undefined path from configs.\n\n`BadConfigType` : throwed when tries to get an config with wrong type.\n\n## Supported Formats\nWe currently support these formats : \n### json\n```json\n{\n  \"database\":{\n    \"name\" : \"my-db-name\"\n  }\n}\n```\n### yml\n```yml\ndatabase:\n  name: my-db-name\n```\n\n## Examples\nA number of examples are included in [examples](./examples/) folder.\n\n## Contributing\nWe are very pleased with your cooperation, so feel free to open issues and pull requests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faslemammad%2Fcoffee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faslemammad%2Fcoffee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faslemammad%2Fcoffee/lists"}