{"id":13736142,"url":"https://github.com/irandeno/coffee","last_synced_at":"2026-02-20T12:31:52.793Z","repository":{"id":62420925,"uuid":"274413823","full_name":"irandeno/coffee","owner":"irandeno","description":"Deno Configuration","archived":false,"fork":false,"pushed_at":"2020-08-25T06:21:54.000Z","size":46,"stargazers_count":33,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-20T19:49:23.031Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/irandeno.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":"2020-06-23T13:32:03.000Z","updated_at":"2024-02-24T21:22:26.000Z","dependencies_parsed_at":"2022-11-01T17:30:58.522Z","dependency_job_id":null,"html_url":"https://github.com/irandeno/coffee","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/irandeno/coffee","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irandeno%2Fcoffee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irandeno%2Fcoffee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irandeno%2Fcoffee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irandeno%2Fcoffee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/irandeno","download_url":"https://codeload.github.com/irandeno/coffee/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irandeno%2Fcoffee/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29650835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-20T09:27:29.698Z","status":"ssl_error","status_checked_at":"2026-02-20T09:26:12.373Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-08-03T03:01:16.518Z","updated_at":"2026-02-20T12:31:52.777Z","avatar_url":"https://github.com/irandeno.png","language":"TypeScript","funding_links":[],"categories":["Modules","基础设施"],"sub_categories":["Utils","Assistants","Deno 源"],"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## Command Line Arguments\ncoffee can read forced configs from command line arguments.\n\n*note* for get config in coffee configurations we shoud prefix flags by \"config\".\n```shell\ncd examples\ndeno run --allow-read --allow-env coffee.ts --config.username=something\n```\n```ts\n// coffee.ts\nimport coffee from \"https://deno.land/x/coffee/mod.ts\";\nconst username: string = coffee.get(\"username\").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%2Firandeno%2Fcoffee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Firandeno%2Fcoffee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firandeno%2Fcoffee/lists"}