{"id":25996913,"url":"https://github.com/clickup/rest-client","last_synced_at":"2025-07-16T06:47:10.040Z","repository":{"id":245092914,"uuid":"703650811","full_name":"clickup/rest-client","owner":"clickup","description":"A syntax sugar tool around Node fetch() API, tailored to work with typescript-is or superstruct validators","archived":false,"fork":false,"pushed_at":"2025-02-20T16:23:52.000Z","size":209,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-29T07:43:01.232Z","etag":null,"topics":["fetch","node","rest","validation"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@clickup/rest-client","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/clickup.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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-11T16:30:04.000Z","updated_at":"2025-02-20T16:09:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"32e58b86-d2bf-4ef7-b67d-6c0d7816a19e","html_url":"https://github.com/clickup/rest-client","commit_stats":{"total_commits":11,"total_committers":2,"mean_commits":5.5,"dds":0.09090909090909094,"last_synced_commit":"0b23dc766cd5f49582adf58f192847de7eb65124"},"previous_names":["clickup/rest-client"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/clickup/rest-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clickup%2Frest-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clickup%2Frest-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clickup%2Frest-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clickup%2Frest-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clickup","download_url":"https://codeload.github.com/clickup/rest-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clickup%2Frest-client/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265489221,"owners_count":23775284,"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":["fetch","node","rest","validation"],"created_at":"2025-03-05T16:55:30.614Z","updated_at":"2025-07-16T06:47:09.994Z","avatar_url":"https://github.com/clickup.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rest-client: a syntax sugar tool around Node fetch() API, tailored to work with typescript-is or superstruct validators\n\nSee also [Full API documentation](https://github.com/clickup/rest-client/blob/master/docs/modules.md).\n\n![CI run](https://github.com/clickup/rest-client/actions/workflows/ci.yml/badge.svg?branch=main)\n\n## Examples\n\nIn the example below we use\n[superstruct](https://www.npmjs.com/package/superstruct) library to build a\nstrongly typed response validator. Validator is just a function passed to\n`json()` method: it must throw if the argument passed doesn't match what it\nexpects the value to be.\n\n```ts\nimport { array, number, object, string } from \"superstruct\";\nimport RestClient from \"rest-client\";\n\n// Initialized once. See RestOptions for lots of other options.\nconst client = new RestClient()\n  .withOptions({\n    timeoutMs: 1000,\n    logger: (_event) =\u003e {\n      /* myLogger.log(event); */\n    },\n  })\n  .withBase(\"https://reqres.in\");\n\nasync function main() {\n  // Send individual request using superstruct as a validation backend.\n  const res = await client\n    .get(\"/api/users\", { page: 2 })\n    .setDebug()\n    .json(\n      object({\n        total: number(),\n        data: array(\n          object({\n            id: number(),\n            email: string(),\n          })\n        ),\n      })\n    );\n  console.log(\"Masked and validated response: \", res);\n  // Notice that `res` is strongly typed! You won't make a typo.\n  console.log(\"Here is a TS strongly-typed field:\", res.data[0].email);\n}\n\nmain().catch((e) =\u003e console.error(e));\n```\n\nThe above script prints the following:\n\n```\n+++ GET https://reqres.in/api/users?page=2\n+++ Accept: application/json\n=== HTTP 200 (took 105 ms)\n=== { data:\n===    [ { id: 7,\n===        email: 'michael.lawson@reqres.in',\n===        first_name: 'Michael',\n===        last_name: 'Lawson',\n===        avatar: 'https://reqres.in/img/faces/7-image.jpg' },\n===      { id: 8,\n===        email: 'lindsay.ferguson@reqres.in',\n===        first_name: 'Lindsay',\n===        last_name: 'Ferguson',\n===        avatar: 'https://reqres.in/img/faces/8-image.jpg' },\n===      { id: 9,\n===        email: 'tobias.funke@reqres.in',\n===        first_name: 'Tobias',\n===        last_name: 'Funke',\n===        avatar: 'https://reqres.in/img/faces/9-image.jpg' },\n===      { id: 10,\n===        email: 'byron.fields@reqres.in',\n===        first_name: 'Byron',\n===        last_name: 'Fields',\n===        avatar: 'https://reqres.in/img/faces/10-image.jpg' },\n===      { id: 11,\n===        email: 'george.edwards@reqres.in',\n===        first_name: 'George',\n===        last_name: 'Edwards',\n===        avatar: 'https://reqres.in/img/faces/11-image.jpg' },\n===      { id: 12,\n===        email: 'rachel.howell@reqres.in',\n===        first_name: 'Rachel',\n===        last_name: 'Howell',\n===        avatar: 'https://reqres.in/img/faces/12-image.jpg' } ],\n===   page: 2,\n===   per_page: 6,\n===   support:\n===    { url: 'https://reqres.in/#support-heading',\n===      text: 'To keep ReqRes free, contributions!' },\n===   total: 12,\n===   total_pages: 2 }\n\nMasked and validated response:  {\n  total: 12,\n  data: [\n    { id: 7, email: 'michael.lawson@reqres.in' },\n    { id: 8, email: 'lindsay.ferguson@reqres.in' },\n    { id: 9, email: 'tobias.funke@reqres.in' },\n    { id: 10, email: 'byron.fields@reqres.in' },\n    { id: 11, email: 'george.edwards@reqres.in' },\n    { id: 12, email: 'rachel.howell@reqres.in' }\n  ]\n}\nHere is a TS strongly-typed field: michael.lawson@reqres.in\n```\n\nIf the API response doesn't match the expected shape (e.g. we expect \"other_field\" to be presented too), superstruct will throw a descriptive message:\n\n```\nStructError: At path: data.0.other_field -- Expected a number, but received: undefined\n```\n\n## Validation Backends\n\nYou can use one of the following libraries to type-enforce the response:\n- [typescript-is](https://www.npmjs.com/package/typescript-is)\n- [superstruct](https://www.npmjs.com/package/superstruct)\n- any other solution which can validate TS object shape against a JSON\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclickup%2Frest-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclickup%2Frest-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclickup%2Frest-client/lists"}