{"id":26851257,"url":"https://github.com/defjs/defjs","last_synced_at":"2025-04-06T23:16:10.538Z","repository":{"id":248801867,"uuid":"813914880","full_name":"defjs/defjs","owner":"defjs","description":"👏 Defjs is a library that helps you define and initiate requests, aiming to make it easier for you to define requests without worrying about the details.","archived":false,"fork":false,"pushed_at":"2025-03-19T03:01:55.000Z","size":535,"stargazers_count":44,"open_issues_count":0,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T22:19:29.966Z","etag":null,"topics":["ajax","fetch","http","http-client","http-stream","javascript","openapi","swagger","typescript","wechat-mini-program","xmlhttprequest"],"latest_commit_sha":null,"homepage":"https://defjs.org","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/defjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"defjs"}},"created_at":"2024-06-12T01:44:50.000Z","updated_at":"2025-03-19T03:01:26.000Z","dependencies_parsed_at":"2024-11-14T14:02:40.979Z","dependency_job_id":null,"html_url":"https://github.com/defjs/defjs","commit_stats":null,"previous_names":["defjs/defjs"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defjs%2Fdefjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defjs%2Fdefjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defjs%2Fdefjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defjs%2Fdefjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/defjs","download_url":"https://codeload.github.com/defjs/defjs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247563935,"owners_count":20958971,"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":["ajax","fetch","http","http-client","http-stream","javascript","openapi","swagger","typescript","wechat-mini-program","xmlhttprequest"],"created_at":"2025-03-30T22:19:16.598Z","updated_at":"2025-04-06T23:16:10.506Z","avatar_url":"https://github.com/defjs.png","language":"TypeScript","readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/defjs/defjs\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n    \u003cimg width=\"200\" src=\"logo.jpg\" alt=\"logo\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cbr/\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://npmjs.com/package/@defjs/core\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/%40defjs%2Fcore?color=%23000\u0026style=flat-square\" alt=\"npm package\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://npmjs.com/package/@defjs/core\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/%40defjs%2Fcore?color=%23000\u0026style=flat-square\" alt=\"monthly downloads\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/defjs/defjs/actions/workflows/ci.yml\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/defjs/defjs/ci.yml?branch=main\u0026color=%23000\u0026style=flat-square\" alt=\"build status\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/defjs/defjs/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/defjs/defjs?color=%23000\u0026style=flat-square\" alt=\"license\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/defjs/defjs\"\u003e\u003cimg src=\"https://img.shields.io/codecov/c/gh/defjs/defjs?color=%23000\u0026style=flat-square\" alt=\"codecov\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cbr/\u003e\n\n## Introduction\n\n`def` is an abbreviation for `define`, so it can be read as `define js`.\n\nDefjs is a library that helps you define and initiate requests, aiming to make it easier for you to define requests without worrying about the details.\n\n-\tSupports multiple request methods such as [Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API), [XMLHttpRequest](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest), custom, etc.\n-\tFunctional API.\n-\t🚧 Supports streaming. (WIP)\n-\tSupports JS/TS with complete type.\n-\tSupports any JS runtime.\n-\tSupports Interceptors.\n-\tSupports ESM\n-\t🚧 Supports Mini Programs. (WIP)\n\n## Quick Start\n\n\u003e Use for package manager\n```shell\nnpm install @defjs/core\n// or\nyarn install @defjs/core\n// or\npnpm install @defjs/core\n// or\nbun install @defjs/core\n```\n\n\u003e Use for CDN\n\n**Only can use ES modules**\n\n```javascript\nimport {\n  createGlobalClient,\n  defineRequest, \n  field\n} from 'https://unpkg.com/@defjs/core/index.min.js';\n\n/**\n * @title Step 1\n * @file src/main.ts\n * @description Setting up a global client\n */\ncreateGlobalClient({\n  host: 'https://example.com',\n});\n\n/**\n * @title Step 2\n * @file src/lib/api/user.ts\n * @description Define the request api request in the lib/api directory of the project\n */\nconst useGetUser = defineRequest('/v1/user/:id')\n  .withField({\n    id: field\u003cnumber\u003e().withParam()\n  })\n\n/**\n * @title Step 3\n * @file src/pages/home.ts\n * @description Use defined requests in business code\n */\nconst { doRequest } = useGetUser();\nconst { error, body } = await doRequest({id: 1});\nif (error) {\n  console.error(error);\n  return;\n}\nconsole.log(body);\n```\n\n## Documentation\n\nCheck out the [🚧 defjs.org](https://defjs.org) to get started.\n\n## Packages\n\n| Package                      | Version                                                                                      |\n|------------------------------|:---------------------------------------------------------------------------------------------|\n| [@defjs/core](packages/core) | ![core version](https://img.shields.io/npm/v/%40defjs%2Fcore?color=%23000\u0026style=flat-square) |\n| [@defjs/angular](packages/angular) | ![core version](https://img.shields.io/npm/v/%40defjs%2Fangular?color=%23000\u0026style=flat-square)     |\n\n## Roadmap\n\n- Documentation official website\n- Wechat mini programs handler\n- CLI Tool\n  - Generate API from OpenAPI\n  - Generate Full SDK Package (Like the [S3 SDK](https://www.npmjs.com/package/@aws-sdk/client-s3))\n- Vue wrapper package\n- React wrapper package\n- Think about simplifying useXXX and doRequest\n\n## License\n\n[MIT](LICENSE)\n\n## Reference\n\n- [Angular HttpClient](https://angular.dev/guide/http)\n- [Axios](https://axios-http.com)\n- [Zod](https://zod.dev)\n- [Deepkit Framework](https://github.com/deepkit/deepkit-framework)\n- [tRPC](https://trpc.io)\n- [Google API design guide](https://cloud.google.com/apis/design)\n- [Tanstack Query](https://tanstack.com/query)\n- [Rxjs](https://rxjs.dev)\n","funding_links":["https://github.com/sponsors/defjs"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefjs%2Fdefjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefjs%2Fdefjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefjs%2Fdefjs/lists"}