{"id":20532590,"url":"https://github.com/cimpress-mcp/request-middleware-framework","last_synced_at":"2025-04-14T06:31:55.988Z","repository":{"id":57354080,"uuid":"67716254","full_name":"Cimpress-MCP/request-middleware-framework","owner":"Cimpress-MCP","description":"A framework to intercept HTTP calls made via the request HTTP client.","archived":false,"fork":false,"pushed_at":"2016-10-19T19:45:37.000Z","size":15,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-11T16:34:06.750Z","etag":null,"topics":["request-middleware"],"latest_commit_sha":null,"homepage":"","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/Cimpress-MCP.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}},"created_at":"2016-09-08T15:35:06.000Z","updated_at":"2021-02-03T01:02:17.000Z","dependencies_parsed_at":"2022-09-05T11:20:59.144Z","dependency_job_id":null,"html_url":"https://github.com/Cimpress-MCP/request-middleware-framework","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cimpress-MCP%2Frequest-middleware-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cimpress-MCP%2Frequest-middleware-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cimpress-MCP%2Frequest-middleware-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cimpress-MCP%2Frequest-middleware-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cimpress-MCP","download_url":"https://codeload.github.com/Cimpress-MCP/request-middleware-framework/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248833582,"owners_count":21168887,"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":["request-middleware"],"created_at":"2024-11-16T00:15:47.801Z","updated_at":"2025-04-14T06:31:55.948Z","avatar_url":"https://github.com/Cimpress-MCP.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# request-middleware-framework\n\nA framework to intercept HTTP calls made via the request HTTP client.\n\n## Installation\n\n    npm install request-middleware-framework\n\n## Middleware Definition\n\nThe framework simply expects any middleware to be a function of form:\n```\nfunction(options, callback, next) {\n  // Add custom logic here.\n  next(options, callback);\n}\n```\n\nThe ``next()`` call will call the next middleware in the chain. To add any logic on the response, you can modify the callback as follows:\n```\nfunction(options, callback, next) {\n  var _callback = function(err, response, body) {\n    // Add custom response logic here.\n    callback(err, response, body);\n  };\n  next(options, _callback);\n}\n```\n\nIf instead you want to completely short-circuit the HTTP call, you can simply call the callback and provide your own error or response:\n```\nfunction(options, callback, next) {\n  var body = \"Everything's fine.\"\n  callback(null, { statusCode: 200, body: body }, body);\n}\n```\n\n## Examples\n\nOnce you've defined your middleware, you can simply register it by creating a new framework object, and then getting the request object:\n```\nvar requestMiddlewareFramework = new RequestMiddlewareFramework(require(\"request\"), middleware);\nvar request = requestMiddlewareFramework.getMiddlewareEnabledRequest();\n```\n\nYou can then use returned ``request`` object just like you normally would.\n\nFor a full example inside an express app, see the [sample](sample) directory within this repository.\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcimpress-mcp%2Frequest-middleware-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcimpress-mcp%2Frequest-middleware-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcimpress-mcp%2Frequest-middleware-framework/lists"}