{"_id":"@aligheisar/http-utils","_rev":"2-ee0ac6031a29f50949eae6abe3a31721","name":"@aligheisar/http-utils","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@aligheisar/http-utils","version":"0.1.0","keywords":["http","error","http-error","network","api","typescript","javascript","utilities"],"author":{"url":"https://github.com/aligheisar","name":"Ali Gheisar","email":"ali.gheisar.dev@gmail.com"},"license":"ISC","_id":"@aligheisar/http-utils@0.1.0","maintainers":[{"name":"aligheisar","email":"ali.gheisar.dev@gmail.com"}],"homepage":"https://github.com/aligheisar/http-utils","bugs":{"url":"https://github.com/aligheisar/http-utils/issues"},"dist":{"shasum":"39cf15ed2004aeb849e505b98b14c6894d3cbcce","tarball":"https://registry.npmjs.org/@aligheisar/http-utils/-/http-utils-0.1.0.tgz","fileCount":9,"integrity":"sha512-BEYwNTJxa0OMQfXcSDibRi6q1koWk1Sa1mx/CDUl+WXIxBEA4vjzhd0tj0U+0VYM1zOjDAD6guhlSQdaSWyX5g==","signatures":[{"sig":"MEQCICHVEKZo2Q/p50kPU9ULdJAiFHDXN5MbouMDkjDH1haZAiBn7jlWPOj1DSn6FbCaXdHLHTEhujDX82aEzsShl9isKA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5373},"main":"./dist/index.cjs","type":"module","_from":"file:aligheisar-http-utils-0.1.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","lint":"biome lint","build":"tsup","check":"biome check","format":"biome format --write","lint:fix":"biome lint --write","check:fix":"biome check --write","lint-staged":"lint-staged"},"_npmUser":{"name":"aligheisar","email":"ali.gheisar.dev@gmail.com"},"_resolved":"/tmp/a0afebb56313bb5c229c89ee83504e00/aligheisar-http-utils-0.1.0.tgz","_integrity":"sha512-BEYwNTJxa0OMQfXcSDibRi6q1koWk1Sa1mx/CDUl+WXIxBEA4vjzhd0tj0U+0VYM1zOjDAD6guhlSQdaSWyX5g==","repository":{"url":"git+https://github.com/aligheisar/http-utils.git","type":"git"},"_npmVersion":"11.5.1","description":"Small, focused HTTP utilities for fetch-based applications.","directories":{},"sideEffects":false,"_nodeVersion":"24.6.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.1","husky":"^9.1.7","typescript":"^5.9.3","lint-staged":"^16.2.7","@biomejs/biome":"^2.3.13"},"_npmOperationalInternal":{"tmp":"tmp/http-utils_0.1.0_1769675878223_0.20419291732355127","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@aligheisar/http-utils","version":"0.1.1","description":"Small, focused HTTP utilities for fetch-based applications.","author":{"name":"Ali Gheisar","email":"ali.gheisar.dev@gmail.com","url":"https://github.com/aligheisar"},"repository":{"type":"git","url":"git+https://github.com/aligheisar/http-utils.git"},"homepage":"https://github.com/aligheisar/http-utils","keywords":["http","error","http-error","network","api","typescript","javascript","utilities"],"license":"ISC","type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":"./dist/index.js","require":"./dist/index.cjs"}},"sideEffects":false,"devDependencies":{"@biomejs/biome":"^2.3.13","husky":"^9.1.7","lint-staged":"^16.2.7","tsup":"^8.5.1","typescript":"^5.9.3"},"scripts":{"build":"tsup","dev":"tsup --watch","lint":"biome lint","lint:fix":"biome lint --write","check":"biome check","check:fix":"biome check --write","format":"biome format --write","lint-staged":"lint-staged"},"_id":"@aligheisar/http-utils@0.1.1","bugs":{"url":"https://github.com/aligheisar/http-utils/issues"},"_integrity":"sha512-VszJWxJ9F+IoKpyfrAYJmwVCzmbGkAHu4Of7qPzyIhdS5Gk5vpKeVC5z0X/nA8bqQ0pja44voXO3wPoT5Ie9uA==","_resolved":"/tmp/56cfaeabcd0260a1f99bb7fa7e12a620/aligheisar-http-utils-0.1.1.tgz","_from":"file:aligheisar-http-utils-0.1.1.tgz","_nodeVersion":"24.6.0","_npmVersion":"11.5.1","dist":{"integrity":"sha512-VszJWxJ9F+IoKpyfrAYJmwVCzmbGkAHu4Of7qPzyIhdS5Gk5vpKeVC5z0X/nA8bqQ0pja44voXO3wPoT5Ie9uA==","shasum":"d20e870b03d177627806a2cf8827360ef1bba269","tarball":"https://registry.npmjs.org/@aligheisar/http-utils/-/http-utils-0.1.1.tgz","fileCount":9,"unpackedSize":7502,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD9i4s0uDJ0ZK0HW8JyZleRU3aNaBfErCXlzI4ej/m1iAIhAIPeXEeaVEbCSF2bzD1n5Q2PZ/xYIa9hKm6uRObyh9Iz"}]},"_npmUser":{"name":"aligheisar","email":"ali.gheisar.dev@gmail.com"},"directories":{},"maintainers":[{"name":"aligheisar","email":"ali.gheisar.dev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/http-utils_0.1.1_1769757774375_0.7410955248993629"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-29T08:37:58.138Z","modified":"2026-01-30T07:22:54.611Z","0.1.0":"2026-01-29T08:37:58.360Z","0.1.1":"2026-01-30T07:22:54.515Z"},"bugs":{"url":"https://github.com/aligheisar/http-utils/issues"},"author":{"name":"Ali Gheisar","email":"ali.gheisar.dev@gmail.com","url":"https://github.com/aligheisar"},"license":"ISC","homepage":"https://github.com/aligheisar/http-utils","keywords":["http","error","http-error","network","api","typescript","javascript","utilities"],"repository":{"type":"git","url":"git+https://github.com/aligheisar/http-utils.git"},"description":"Small, focused HTTP utilities for fetch-based applications.","maintainers":[{"name":"aligheisar","email":"ali.gheisar.dev@gmail.com"}],"readme":"# http-utils\n\nA small collection of HTTP-related utilities for modern JavaScript and\nTypeScript applications.\n\nThis package focuses on improving error handling and developer\nergonomics when working with the Fetch API and HTTP responses.\n\n## Installation\n\n``` bash\nnpm install @aligheisar/http-utils\n```\n\nor\n\n``` bash\npnpm add @aligheisar/http-utils\n```\n\nor\n\n``` bash\nyarn add @aligheisar/http-utils\n```\n\n## HttpError\n\n`HttpError` is a custom error class designed for HTTP requests. It wraps\na `Response` object and exposes useful metadata such as status code,\nstatus text, response body, and request URL.\n\n### Why use HttpError?\n\nThe native `fetch` API does **not** throw errors for non-2xx responses.\n`HttpError` gives you a structured, typed way to represent HTTP failures\nand handle them consistently across your app.\n\n### API\n\n``` ts\nclass HttpError extends Error {\n  status: number;\n  statusText: string;\n  body: unknown;\n  url: string;\n\n  constructor(res: Response, body: unknown);\n}\n```\n\n### Properties\n\n-   **status** -- HTTP status code (e.g. `404`, `500`)\n-   **statusText** -- HTTP status text (e.g. `\"Not Found\"`)\n-   **body** -- Parsed response body (JSON, text, etc.)\n-   **url** -- Request URL\n-   **message** -- Automatically set to `HTTP <status> <statusText>`\n\n### Example usage\n\n``` ts\nimport { HttpError } from \"@aligheisar/http-utils\";\n\nasync function fetchUser(id: string) {\n  const res = await fetch(`/api/users/${id}`);\n  const body = await res.json();\n\n  if (!res.ok) {\n    throw new HttpError(res, body);\n  }\n\n  return body;\n}\n```\n\n### Handling the error\n\n``` ts\ntry {\n  const user = await fetchUser(\"123\");\n} catch (err) {\n  if (err instanceof HttpError) {\n    console.error(err.status);\n    console.error(err.statusText);\n    console.error(err.body);\n    console.error(err.url);\n  } else {\n    throw err;\n  }\n}\n```\n\n## TypeScript support\n\nThis package is written in TypeScript and ships with type definitions\nout of the box.\n\n## Scope and philosophy\n\n`http-utils` is intentionally small and focused. Each utility solves a\nspecific HTTP-related problem without adding abstractions or\ndependencies you don't need.","readmeFilename":"README.md"}