{"id":24630933,"url":"https://github.com/jarweb/rufetch","last_synced_at":"2025-08-12T06:47:28.133Z","repository":{"id":42872404,"uuid":"257849973","full_name":"Jarweb/rufetch","owner":"Jarweb","description":"a lightweight fetch lib with middleware inpired by koa","archived":false,"fork":false,"pushed_at":"2023-01-06T04:00:19.000Z","size":2387,"stargazers_count":2,"open_issues_count":19,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-08T02:19:21.412Z","etag":null,"topics":["fetch","middleware"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jarweb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-22T09:12:22.000Z","updated_at":"2023-03-10T08:13:02.000Z","dependencies_parsed_at":"2023-02-05T06:46:21.873Z","dependency_job_id":null,"html_url":"https://github.com/Jarweb/rufetch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Jarweb/rufetch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jarweb%2Frufetch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jarweb%2Frufetch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jarweb%2Frufetch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jarweb%2Frufetch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jarweb","download_url":"https://codeload.github.com/Jarweb/rufetch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jarweb%2Frufetch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270016659,"owners_count":24512963,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["fetch","middleware"],"created_at":"2025-01-25T07:13:49.387Z","updated_at":"2025-08-12T06:47:28.079Z","avatar_url":"https://github.com/Jarweb.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### intro\n\na lightweight fetch lib with middleware inspired by koa\n\n\n\n### quick start\n\n```\nyarn add @jarzzzi/rufetch\n```\n\n\n### example\n\n```javascript\nconst http = new Rufetch({\n  baseURL: 'https://github.com/api',\n})\n\nconst getUser = (name) =\u003e {\n  return http.get(`/user/${name}`)\n}\n\nconst getReps = (name, page) =\u003e {\n  return http.get(`/user/${name}`, {params: {page}})\n}\n\nconst createReps = (name, data) =\u003e {\n  return http.post(`/user/${name}`, {data})\n}\n```\n\n### middleware\n- built in middleware\n  - cache\n  - fetch\n\n- error middleware\n```javascript\nhttp.use(async (ctx: any, next: any) =\u003e {\n  await next()\n  const {error} = ctx.res\n\n  if (error?.status \u003e= 400 \u0026\u0026 error?.status \u003c 500) {\n    console.error('client error')\n  }\n  if (error?.status \u003e= 500) {\n    console.error('server error')\n  }\n  if (error === 'fetch timeout') {\n    console.error('fetch timeout')\n  }\n})\n```\n- token middleware\n```javascript\nhttp.use(async (ctx: any, next: any) =\u003e {\n  const token = await getToken()\n  ctx.req.requestInit.setHeaders(token, token)\n  await next()\n})\n```\n\n### api\n- options\n  - baseURL\n  - timeout: default 15000\n  - params: url search params\n  - data: body alias\n  - responseType: default json, arrayBuffer, blob, json, text, formData, stream...\n  - cacheOptions\n    - cache: boolean\n    - expiredAge: default 5000\n  - body\n  - cache\n  - credentials\n  - headers\n  - integrity\n  - keepalive\n  - method\n  - mode\n  - redirect\n  - referrer\n  - referrerPolicy\n  - signal\n  - window\n- new (options)\n- instance.get\n- instance.post\n- instance.put\n- instance.delete\n- instance.head\n- instance.use\n  - add middleware\n  - ctx\n    - req\n    - request\n    - res\n    - response\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjarweb%2Frufetch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjarweb%2Frufetch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjarweb%2Frufetch/lists"}