{"id":25526151,"url":"https://github.com/exbotanical/http-factory","last_synced_at":"2025-10-14T07:39:19.545Z","repository":{"id":40524543,"uuid":"343245347","full_name":"exbotanical/http-factory","owner":"exbotanical","description":"Declarative http clients and serial requests","archived":false,"fork":false,"pushed_at":"2023-05-01T03:07:18.000Z","size":601,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-10T09:37:28.472Z","etag":null,"topics":["axios","factory","rest","rest-api","rest-client"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/http-factory","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/exbotanical.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":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-01T00:16:19.000Z","updated_at":"2022-01-02T04:12:34.000Z","dependencies_parsed_at":"2024-10-22T22:05:15.951Z","dependency_job_id":null,"html_url":"https://github.com/exbotanical/http-factory","commit_stats":{"total_commits":39,"total_committers":2,"mean_commits":19.5,"dds":0.1282051282051282,"last_synced_commit":"e0b337ca677b497a5dee7ba15a72274090c867f6"},"previous_names":["matthewzito/http-factory"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exbotanical%2Fhttp-factory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exbotanical%2Fhttp-factory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exbotanical%2Fhttp-factory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exbotanical%2Fhttp-factory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/exbotanical","download_url":"https://codeload.github.com/exbotanical/http-factory/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239735258,"owners_count":19688262,"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":["axios","factory","rest","rest-api","rest-client"],"created_at":"2025-02-19T21:16:51.243Z","updated_at":"2025-10-14T07:39:14.507Z","avatar_url":"https://github.com/exbotanical.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# http-factory\n\n[![Coverage Status](https://coveralls.io/repos/github/MatthewZito/http-factory/badge.svg?branch=master)](https://coveralls.io/github/MatthewZito/http-factory?branch=master)\n[![Continuous Deployment](https://github.com/MatthewZito/http-factory/actions/workflows/cd.yml/badge.svg)](https://github.com/MatthewZito/http-factory/actions/workflows/cd.yml)\n[![Continuous Integration](https://github.com/MatthewZito/http-factory/actions/workflows/ci.yml/badge.svg)](https://github.com/MatthewZito/http-factory/actions/workflows/ci.yml)\n[![npm version](https://badge.fury.io/js/http-factory.svg)](https://badge.fury.io/js/http-factory)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`http-factory` lets you build declarative, strongly-typed http interfaces\n\n- [Install](#install)\n- [Supported Environments](#support)\n- [Documentation / API](#docs)\n\n```ts\nconst client = new HttpClient({ ...options })\n  // transform the outbound request / inbound response\n  .transforms({ request: fn, response: fn })\n  // intercept the outbound request / inbound response or error\n  .intercepts({ request: fn, response: fn, error: fn })\n  // log the outbound request / inbound response\n  .logs({ request: isDev, response: isDev })\n  // set the base url for the client instance\n  .setBaseUrl('...');\n\n// make a serial request\nconst data = [];\n\nfor await (const rs of client.serialGet(urls)) {\n  if (rs.status === 200) data.push({ data: rs.data });\n...\n```\n\nBy default, requests are sent with a Content-Type header of application/json. UTF-8 encoding is set by default, and all request bodies will be serialized.\n\nTo change this behavior, you can provide your own Axios options to the constructor.\n\nEach request method accepts an optional callback to which the response or error will be piped. This affords the use of continuation-passing using callbacks:\n\n```ts\n...\nclient.intercepts({\n  request: ({ data }) =\u003e ({ ok: true, data }),\n  error: (err) =\u003e ({ ok: false, data: null, message: err.response.data.msg || 'something went wrong' }),\n});\n\nasync function getData () {\n  await client.getTheData({ url }, ({ ok, data }) =\u003e {\n    if (ok) {\n      // didn't have to do a bunch of response normalization in my component, yay\n    } else {\n      // handle\n    }\n  });\n}\n```\n\nContinuations can likewise be passed to serial requests:\n\n```ts\n...\nconst callback = ({ data }) =\u003e results.push(data);\n\nasync function fetchAll () {\n  try {\n    for await (const _ of client.serialGet(urls, callback));\n  } catch(ex) { ... }\n}\n...\n```\n\nSee the API docs below for instantiating clients, dev logging, and making iterable requests.\n\nFor client options see [Axios docs](https://github.com/axios/axios).\n\n## \u003ca name=\"install\"\u003e\u003c/a\u003e Installation\n\n```bash\nnpm install http-factory\n```\n\nOR\n\n```bash\nyarn add http-factory\n```\n\n## \u003ca name=\"support\"\u003e\u003c/a\u003e  Supported Environments\n\n`http-factory` currently supports UMD, CommonJS (node versions \u003e= 10), and ESM build-targets\n\nCommonjs:\n\n```ts\nconst { HttpClient } = require('http-factory');\n```\n\nESM:\n\n```ts\nimport { HttpClient } from 'http-factory';\n```\n\n## \u003ca name=\"docs\"\u003e\u003c/a\u003e Documentation\n\nFull documentation can be found [here](https://matthewzito.github.io/http-factory/http-factory.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexbotanical%2Fhttp-factory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexbotanical%2Fhttp-factory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexbotanical%2Fhttp-factory/lists"}