{"_id":"@bekaert-dev/rqst","_rev":"5-b730745a750cf4c3d18a1c60a3c1a6c7","name":"@bekaert-dev/rqst","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"@bekaert-dev/rqst","version":"1.0.0","license":"MIT","_id":"@bekaert-dev/rqst@1.0.0","maintainers":[{"name":"tbekaert","email":"thomas@bekaert.dev"}],"homepage":"https://github.com/bekaert-dev/monorepo/tree/main/packages/rqst","bugs":{"url":"https://github.com/bekaert-dev/monorepo/issues"},"dist":{"shasum":"33911d66458177149399ccaca13599a2f6b3f7bf","tarball":"https://registry.npmjs.org/@bekaert-dev/rqst/-/rqst-1.0.0.tgz","fileCount":8,"integrity":"sha512-FAJ/R4t1t7pHz+YgLLuSTyKbWMCMdymxGRr725/pfteIXUMm5i0ZIcG8vVOg5naZgMFMrJFyu7j7DfJcvMK6SQ==","signatures":[{"sig":"MEQCIBZs3sbq0eFPxvANRIatFPerrls+bb0WOgMaVCrHV5o+AiAsJBUmMZuYCx/nvpOWSFH8jFXozO2hyXa3Wmcp/7cJ1A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":36252},"main":"dist/index.cjs","type":"module","_from":"file:bekaert-dev-rqst-1.0.0.tgz","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"lint":"eslint .","test":"vitest run","build":"tsup","typecheck":"tsc -p tsconfig.json --noEmit"},"_npmUser":{"name":"tbekaert","email":"thomas@bekaert.dev"},"_resolved":"/tmp/0e7af94f493939c0bdd681fe56c1f688/bekaert-dev-rqst-1.0.0.tgz","_integrity":"sha512-FAJ/R4t1t7pHz+YgLLuSTyKbWMCMdymxGRr725/pfteIXUMm5i0ZIcG8vVOg5naZgMFMrJFyu7j7DfJcvMK6SQ==","repository":{"url":"git+https://github.com/bekaert-dev/monorepo.git","type":"git","directory":"packages/rqst"},"_npmVersion":"11.6.2","description":"A small axios + zod based request client with built in data validation and builders for headers, body, and query string handling.","directories":{},"_nodeVersion":"24.12.0","dependencies":{"axios":"^1.12.2","query-string":"^9.3.1","@bekaert-dev/tsconfig":"1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.4.0","eslint":"^9.39.2","vitest":"^4.0.18","typescript":"^5.9.3","@bekaert-dev/eslint-config":"1.0.1"},"peerDependencies":{"zod":"^4.1.11"},"peerDependenciesMeta":{"zod":{"optional":false}},"_npmOperationalInternal":{"tmp":"tmp/rqst_1.0.0_1770139614949_0.19874228573051278","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@bekaert-dev/rqst","version":"1.0.1","license":"MIT","_id":"@bekaert-dev/rqst@1.0.1","maintainers":[{"name":"tbekaert","email":"thomas@bekaert.dev"}],"homepage":"https://github.com/bekaert-dev/monorepo/tree/main/packages/rqst","bugs":{"url":"https://github.com/bekaert-dev/monorepo/issues"},"dist":{"shasum":"118efa36478306c00be928d9e52ec2e25be35062","tarball":"https://registry.npmjs.org/@bekaert-dev/rqst/-/rqst-1.0.1.tgz","fileCount":8,"integrity":"sha512-NBoYxvkziQfUytwa1P9ooiLhGg0OFr65WufiUHbI54+Zaomhe/1+zQoMSjO6s7VIQ0wQov3/7SKQF5cEXXgYFw==","signatures":[{"sig":"MEUCIFz1WwSMF+VENY4FWtHVRTWkjSC/D+/3YBUZepzIU+IpAiEA07xN62UGWmE9M/gKFJMhrVNF1l1U5Uao5HDsjIXuDek=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":35321},"main":"dist/index.cjs","type":"module","_from":"file:bekaert-dev-rqst-1.0.1.tgz","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"lint":"eslint .","test":"vitest run","build":"tsup","typecheck":"tsc -p tsconfig.json --noEmit"},"_npmUser":{"name":"tbekaert","email":"thomas@bekaert.dev"},"_resolved":"/tmp/920d55d3f5f1f648c76df915d5cfe5d8/bekaert-dev-rqst-1.0.1.tgz","_integrity":"sha512-NBoYxvkziQfUytwa1P9ooiLhGg0OFr65WufiUHbI54+Zaomhe/1+zQoMSjO6s7VIQ0wQov3/7SKQF5cEXXgYFw==","repository":{"url":"git+https://github.com/bekaert-dev/monorepo.git","type":"git","directory":"packages/rqst"},"_npmVersion":"11.6.2","description":"A small axios + zod based request client with built in data validation and builders for headers, body, and query string handling.","directories":{},"_nodeVersion":"24.12.0","dependencies":{"axios":"^1.12.2","query-string":"^9.3.1","@bekaert-dev/tsconfig":"1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.4.0","eslint":"^9.39.2","vitest":"^4.0.18","typescript":"^5.9.3","@bekaert-dev/eslint-config":"1.0.1"},"peerDependencies":{"zod":"^4.1.11"},"peerDependenciesMeta":{"zod":{"optional":false}},"_npmOperationalInternal":{"tmp":"tmp/rqst_1.0.1_1770191209412_0.44165635267954495","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@bekaert-dev/rqst","version":"1.0.2","license":"MIT","_id":"@bekaert-dev/rqst@1.0.2","maintainers":[{"name":"tbekaert","email":"thomas@bekaert.dev"}],"homepage":"https://github.com/bekaert-dev/monorepo/tree/main/packages/rqst","bugs":{"url":"https://github.com/bekaert-dev/monorepo/issues"},"dist":{"shasum":"e9af818df31da02200840783e1e4b6b21200dce5","tarball":"https://registry.npmjs.org/@bekaert-dev/rqst/-/rqst-1.0.2.tgz","fileCount":8,"integrity":"sha512-+wyJtuF9EGNjyMhrr+Ho/tpanqPRTRtPzSE70uH59QeTtRDmbyL/pnqeeexxrJTk7L97ZHtqUp9Sx2ByrAEmPg==","signatures":[{"sig":"MEQCIGQegd9foTg9jhEcRxEysGfKFoUYDNbjmvIWMlWlBccdAiAKb3pFTLJP7c57bnsQCxxnpkGIg/TmaKmgp+Lvr1xDMA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":35535},"main":"dist/index.cjs","type":"module","_from":"file:bekaert-dev-rqst-1.0.2.tgz","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"lint":"biome lint .","test":"vitest run","build":"tsup","format":"biome format --write .","typecheck":"tsc -p tsconfig.json --noEmit"},"_npmUser":{"name":"tbekaert","email":"thomas@bekaert.dev"},"_resolved":"/tmp/2a26278c08ed390b584669e1934079d9/bekaert-dev-rqst-1.0.2.tgz","_integrity":"sha512-+wyJtuF9EGNjyMhrr+Ho/tpanqPRTRtPzSE70uH59QeTtRDmbyL/pnqeeexxrJTk7L97ZHtqUp9Sx2ByrAEmPg==","repository":{"url":"git+https://github.com/bekaert-dev/monorepo.git","type":"git","directory":"packages/rqst"},"_npmVersion":"11.6.2","description":"A small axios + zod based request client with built in data validation and builders for headers, body, and query string handling.","directories":{},"_nodeVersion":"24.12.0","dependencies":{"axios":"^1.12.2","query-string":"^9.3.1","@bekaert-dev/tsconfig":"1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.4.0","vitest":"^4.0.18","typescript":"^5.9.3","@biomejs/biome":"2.3.14"},"peerDependencies":{"zod":"^4.1.11"},"peerDependenciesMeta":{"zod":{"optional":false}},"_npmOperationalInternal":{"tmp":"tmp/rqst_1.0.2_1770394805804_0.9552253524339356","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@bekaert-dev/rqst","version":"1.0.3","license":"MIT","_id":"@bekaert-dev/rqst@1.0.3","maintainers":[{"name":"tbekaert","email":"thomas@bekaert.dev"}],"homepage":"https://github.com/bekaert-dev/monorepo/tree/main/packages/rqst","bugs":{"url":"https://github.com/bekaert-dev/monorepo/issues"},"dist":{"shasum":"490cf9f15628d3ec6491f5db512b1f6a47c05009","tarball":"https://registry.npmjs.org/@bekaert-dev/rqst/-/rqst-1.0.3.tgz","fileCount":8,"integrity":"sha512-qrMRtiZe1yWJmmcPS7XW6VgYQyVdlA3E6YYJ5+ek8hkUB10NKVnCwLb6T8aDbq5lkYkttMSMGKyWfb9ZmDU8Lw==","signatures":[{"sig":"MEUCIQD/6OfB0VJoOqgvKrAAHc9ybSC7OJRsK85Nfc5yaJu0PwIgEmVvynSCxt6b7O4HtdF1ONDDieUpaNVO+NbRXqsdIzU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":35576},"main":"dist/index.cjs","type":"module","_from":"file:bekaert-dev-rqst-1.0.3.tgz","types":"dist/index.d.ts","module":"dist/index.js","engines":{"node":">=20.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"lint":"biome lint .","test":"vitest run","build":"tsup","format":"biome format --write .","typecheck":"tsc -p tsconfig.json --noEmit"},"_npmUser":{"name":"tbekaert","email":"thomas@bekaert.dev"},"_resolved":"/tmp/185f63e73eebd1abe425e3a47ecd08db/bekaert-dev-rqst-1.0.3.tgz","_integrity":"sha512-qrMRtiZe1yWJmmcPS7XW6VgYQyVdlA3E6YYJ5+ek8hkUB10NKVnCwLb6T8aDbq5lkYkttMSMGKyWfb9ZmDU8Lw==","repository":{"url":"git+https://github.com/bekaert-dev/monorepo.git","type":"git","directory":"packages/rqst"},"_npmVersion":"11.6.2","description":"A small axios + zod based request client with built in data validation and builders for headers, body, and query string handling.","directories":{},"_nodeVersion":"24.12.0","dependencies":{"axios":"^1.12.2","query-string":"^9.3.1","@bekaert-dev/tsconfig":"1.0.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.4.0","vitest":"^4.0.18","typescript":"^5.9.3","@biomejs/biome":"2.3.14"},"peerDependencies":{"zod":"^4.1.11"},"peerDependenciesMeta":{"zod":{"optional":false}},"_npmOperationalInternal":{"tmp":"tmp/rqst_1.0.3_1770723010679_0.9549324925862501","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@bekaert-dev/rqst","version":"1.0.4","type":"module","license":"MIT","homepage":"https://github.com/bekaert-dev/monorepo/tree/main/packages/rqst","publishConfig":{"access":"public"},"main":"dist/index.cjs","module":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"dependencies":{"axios":"^1.13.5","query-string":"^9.3.1","@bekaert-dev/tsconfig":"1.0.1"},"peerDependencies":{"zod":"^4.1.11"},"peerDependenciesMeta":{"zod":{"optional":false}},"devDependencies":{"@biomejs/biome":"2.3.15","tsup":"^8.4.0","typescript":"^5.9.3","vitest":"^4.0.18"},"repository":{"type":"git","url":"git+https://github.com/bekaert-dev/monorepo.git","directory":"packages/rqst"},"engines":{"node":">=20.0"},"scripts":{"build":"tsup","lint":"biome lint .","format":"biome format --write .","test":"vitest run","typecheck":"tsc -p tsconfig.json --noEmit"},"_id":"@bekaert-dev/rqst@1.0.4","description":"A small axios + zod based request client with built in data validation and builders for headers, body, and query string handling.","bugs":{"url":"https://github.com/bekaert-dev/monorepo/issues"},"_integrity":"sha512-bGrv1QhRSu1lCw6+gx53/7lQoTfsPdqeh0MmmGqRa1nDR0VxSabg6k5DqljdzosvoDo/ANVyU2Ses69ZdESt2Q==","_resolved":"/tmp/22cc2e5dd000c9eb089f67b7d397fdb1/bekaert-dev-rqst-1.0.4.tgz","_from":"file:bekaert-dev-rqst-1.0.4.tgz","_nodeVersion":"24.12.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-bGrv1QhRSu1lCw6+gx53/7lQoTfsPdqeh0MmmGqRa1nDR0VxSabg6k5DqljdzosvoDo/ANVyU2Ses69ZdESt2Q==","shasum":"6e029aa596036dfbc7774e06eab0d0b83d1f53d9","tarball":"https://registry.npmjs.org/@bekaert-dev/rqst/-/rqst-1.0.4.tgz","fileCount":8,"unpackedSize":35576,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDYSwdtAk/Ph2ktRJg8LnnPFsQFjcOtdYj0sEApX2uqCAIhAKzHTDfYr9H/QgXTKcIASkkVHzvho9G2/3VvBs4Y2s73"}]},"_npmUser":{"name":"tbekaert","email":"thomas@bekaert.dev"},"directories":{},"maintainers":[{"name":"tbekaert","email":"thomas@bekaert.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/rqst_1.0.4_1771185832027_0.8909350163356149"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-03T17:26:54.832Z","modified":"2026-02-15T20:03:52.318Z","1.0.0":"2026-02-03T17:26:55.135Z","1.0.1":"2026-02-04T07:46:49.573Z","1.0.2":"2026-02-06T16:20:05.952Z","1.0.3":"2026-02-10T11:30:10.826Z","1.0.4":"2026-02-15T20:03:52.176Z"},"bugs":{"url":"https://github.com/bekaert-dev/monorepo/issues"},"license":"MIT","homepage":"https://github.com/bekaert-dev/monorepo/tree/main/packages/rqst","repository":{"type":"git","url":"git+https://github.com/bekaert-dev/monorepo.git","directory":"packages/rqst"},"description":"A small axios + zod based request client with built in data validation and builders for headers, body, and query string handling.","maintainers":[{"name":"tbekaert","email":"thomas@bekaert.dev"}],"readme":"# @bekaert-dev/rqst\n\nA small axios + zod based request client with built in data validation and builders for headers, body, and query string handling.\n\n## Install\n\n```bash\npnpm add @bekaert-dev/rqst\n```\n\nPeer dependency (required):\n\n```bash\npnpm add zod\n```\n\nDocs:\n\n- axios: https://axios-http.com\n- zod: https://zod.dev\n\n## Quick start\n\n```ts\nimport { rqst } from '@bekaert-dev/rqst'\nimport { z } from 'zod'\n\nconst api = rqst({ baseURL: 'https://api.example.com' })\n\nconst User = z.object({ id: z.string(), name: z.string() })\n\nconst user = await api.get('/users/1', User).execute()\n```\n\n## API\n\n### `rqst(options?, instanceOptions?)`\n\nCreates a new client instance.\n\n- `options` (`AxiosRequestConfig`, optional): Base axios config applied to all requests.\n- `instanceOptions` (`InstanceOptions`, optional): Extra rqst options.\n\nReturns an object with HTTP methods and interceptor helpers:\n\n- `get`, `post`, `put`, `patch`, `delete`\n- `addRequestInterceptor`, `clearRequestInterceptor`\n- `addResponseInterceptor`, `clearResponseInterceptor`\n\n### Request builder\n\nEach HTTP method returns a request builder:\n\n```ts\napi.get('/users', schema)\n```\n\nThe builder supports chaining:\n\n- `withOptions(options)`\n- `withHeaders(headers)`\n- `withBody(body)`\n- `withQS(qs)`\n- `execute(params?)`\n\n### `execute(params?)`\n\n```ts\ntype ExecuteParams<RequestResponse> = {\n  debug?: boolean\n  fallback?: RequestResponse\n  rethrowOnError?: boolean\n}\n```\n\nBehavior:\n\n- `RequestResponse`: the inferred output type from the zod schema you pass to the request (i.e. `z.output<typeof schema>`). It represents the successful return type of `.execute()` and also the type of any `fallback` you provide.\n- `debug`: logs the full axios response with `console.log`.\n- `fallback`: returned if response decoding fails (zod validation error). When used, no error is thrown.\n- `rethrowOnError`: when `true`, request errors are rethrown. Defaults to `true`.\n\n`fallback` and `rethrowOnError` can be used together. When both are set and decoding fails, the fallback is returned (and the decoding error is still logged) but the error is not rethrown. Request errors will still be rethrown when `rethrowOnError` is `true`.\n\n### Interceptors\n\nThe instance exposes helpers to register and clear interceptors. These map directly to axios interceptors.\n\n```ts\nconst api = rqst()\n\nconst requestId = api.addRequestInterceptor(config => {\n  return config\n})\n\nconst responseId = api.addResponseInterceptor(response => {\n  return response\n})\n\napi.clearRequestInterceptor(requestId)\napi.clearResponseInterceptor(responseId)\n```\n\n## Error logging\n\nErrors are normalized into a small set of types, and passed to a custom logger if provided. The `customErrorLogger` receives:\n\n```ts\ntype customErrorLogger = (\n  url: string,\n  errorType: RqstErrorType,\n  err: unknown,\n) => void\n```\n\n`RqstErrorType` values:\n\n- `HTTP_ERROR`\n- `NO_RESPONSE`\n- `REQUEST_SETUP_INVALID`\n- `DECODING_FAILED`\n- `UNKNOWN`\n\nExample handling with a switch:\n\n```ts\nconst api = rqst(undefined, {\n  customErrorLogger: (_url, errorType, err) => {\n    switch (errorType) {\n      case 'HTTP_ERROR':\n        console.error('Server returned an error response', err)\n        break\n      case 'NO_RESPONSE':\n        console.error('No response received', err)\n        break\n      case 'REQUEST_SETUP_INVALID':\n        console.error('Request setup failed', err)\n        break\n      case 'DECODING_FAILED':\n        console.error('Response validation failed', err)\n        break\n      case 'UNKNOWN':\n      default:\n        console.error('Unknown error', err)\n    }\n  },\n})\n```\n\nTo provide a custom logger:\n\n```ts\nconst api = rqst(\n  { baseURL: 'https://api.example.com' },\n  {\n    customErrorLogger: (url, type, err) => {\n      console.error(url, type, err)\n    },\n  },\n)\n```\n\n## Examples\n\n### With headers and query string\n\n```ts\nconst schema = z.object({ ok: z.boolean() })\n\nconst result = await api\n  .get('/health', schema)\n  .withHeaders({ 'x-trace-id': 'abc' })\n  .withQS({ verbose: true })\n  .execute()\n```\n\n### With body and fallback\n\n```ts\nconst schema = z.object({ id: z.string() })\n\nconst result = await api\n  .post('/users', schema)\n  .withBody({ name: 'Ada' })\n  .execute({ fallback: { id: 'unknown' } })\n```\n\n### Swallowing request errors\n\n```ts\nconst schema = z.object({ ok: z.boolean() })\n\nconst result = await api\n  .get('/maybe-down', schema)\n  .execute({ rethrowOnError: false })\n\nif (result === undefined) {\n  // request failed and was swallowed\n}\n```\n\n## Type exports\n\n```ts\nimport type { RqstAPI, RqstErrorType } from '@bekaert-dev/rqst'\n```\n\n### `RqstAPI`\n\n```ts\ntype RqstAPI = ReturnType<typeof rqst>\n```\n\n## TypeScript & module format\n\nThis package is written in TypeScript and built with `tsup`. It publishes ESM and CJS builds.\n\n- Module format: ESM (`dist/index.js`) and CJS (`dist/index.cjs`).\n- TypeScript: developed against TypeScript 5.9.x. Other versions may work, but 5.9.x is the supported baseline.\n","readmeFilename":"README.md"}