{"id":28903451,"url":"https://github.com/s2thend/express-http-client","last_synced_at":"2026-03-02T13:13:12.989Z","repository":{"id":299395161,"uuid":"978591336","full_name":"S2thend/express-http-client","owner":"S2thend","description":"A light-weight javascript http request library built in conscious of middleware design pattern. (requires fetch api)","archived":false,"fork":false,"pushed_at":"2025-05-14T05:11:47.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-16T10:56:34.962Z","etag":null,"topics":["auth0","authentication","axios","expressjs","http-client","http-requests","httpclient","imperative-programming","interceptor-http","logger-middleware","middleware","refresh-token","token"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/express-http-client","language":"JavaScript","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/S2thend.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,"zenodo":null}},"created_at":"2025-05-06T08:14:16.000Z","updated_at":"2025-05-14T05:18:25.000Z","dependencies_parsed_at":"2025-06-16T10:56:56.480Z","dependency_job_id":"59c16f54-b1ef-4b65-af12-d06959ee630e","html_url":"https://github.com/S2thend/express-http-client","commit_stats":null,"previous_names":["s2thend/express-http-client"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/S2thend/express-http-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S2thend%2Fexpress-http-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S2thend%2Fexpress-http-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S2thend%2Fexpress-http-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S2thend%2Fexpress-http-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/S2thend","download_url":"https://codeload.github.com/S2thend/express-http-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S2thend%2Fexpress-http-client/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261119541,"owners_count":23112206,"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":["auth0","authentication","axios","expressjs","http-client","http-requests","httpclient","imperative-programming","interceptor-http","logger-middleware","middleware","refresh-token","token"],"created_at":"2025-06-21T12:02:36.777Z","updated_at":"2026-03-02T13:13:12.977Z","avatar_url":"https://github.com/S2thend.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Express Http Client\n[![npm badge](https://img.shields.io/badge/npm-0.3.6-blue.svg)](https://www.npmjs.com/package/express-http-client)\n[![compatibility badge](https://img.shields.io/badge/compatibility-\u003e=ES6-blue.svg)](https://shields.io/)\n[![gzipped_size badge](https://img.shields.io/badge/gzip-1.3_kB-red.svg)](https://shields.io/)\n[![production_size badge](https://img.shields.io/badge/prod-3.7_kB-red.svg)](https://shields.io/)\n[![License badge](https://img.shields.io/badge/License-MIT-\u003cCOLOR\u003e.svg)](https://shields.io/)\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](code_of_conduct.md)\n\nA light-weight javascript http request library built in conscious of middleware design pattern.\n(requires fetch api)\n\nThis project aims to reduce user mental effort and give user more control over the request process by provide only minimal features.\n\nThe middleware usage is as intuitive as using expressjs server middleware by using next() to pass control to the next middleware.\n\nIt will minimize effort to migrate from fetch to this library and work out of the box by just simply rename fetch to request in your project.\n\n## Quick Start\n### one time request\n\n```js\nimport { request } from 'express-http-client';\n\nawait request(\n    \"https://example.com/api/v1/posts\",\n    {\n        method: 'GET',\n        headers: {\n            'Authorization': 'Bearer ' + refresh\n        }\n    },\n    // response interceptors\n    [\n        //example response interceptor middleware\n        (data, next) =\u003e {\n            data.response.json().then(json =\u003e {\n                console.log(json);\n                next();\n            }).catch(error =\u003e {\n                next(error);\n            });\n        }\n    ],\n    // request interceptors\n    []\n);\n```\n\n### httpClient\n\n```js\nimport {httpClient as expressHttpClient, logger, mockResponse} from 'express-http-client';\n\n//create a new http client instance, you can create multiple http client instance for different purpose\nlet httpClient = expressHttpClient();\n\n//add request interceptor middleware: example to add authorization header\nhttpClient.addRequestInterceptor(async (data, next) =\u003e {\n    data.request = new Request(data.request, {\n        // You can override any request properties here\n        headers: new Headers({\n            ...Object.fromEntries(data.request.headers.entries()),\n            'Authorization': `Bearer token`\n        }),\n    });\n    next();\n});\n\n//add response interceptor middleware: example\nhttpClient.addResponseInterceptor(\n    //use built in logger interceptor middleware to log the request and response\n    logger(),\n);\n\nhttpClient = httpClient.create(\"replace with your base url\");\n\nlet response = await httpClient.send(`/api/v1/posts`);\n```\n\n## Api\n\n### interceptor function\n\n#### parameters\n\n- `data`: the data object\n    - `request`: the request object\n    - `response`: the response object\n    - `store`: a map store for data persistence between interceptors\n- `next`: the next function\n\n\n## built in interceptor functions\n\n### logger\n\n### mockResponse\n\n```js\nimport {httpClient as expressHttpClient, logger, mockResponse} from 'express-http-client';\n\nlet httpClient = expressHttpClient();\n\nhttpClient.addResponseInterceptor(\n    mockResponse(\n        true,\n        // supply the mock response mapping object here(url.method -\u003e response)\n        {\n            \"http://example.com/api/v1/posts\": {\n                //mock response for GET request\n                \"GET\": ()=\u003e new Response(JSON.stringify(\n                    //mock response data\n                ))\n            },\n            \"http://example.com/api/v1/posts\": {\n                //mock response for all request\n                \"ALL\": ()=\u003e new Response(JSON.stringify(\n                    //mock response data\n                ))\n            },\n        }\n    )\n)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs2thend%2Fexpress-http-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs2thend%2Fexpress-http-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs2thend%2Fexpress-http-client/lists"}