{"id":22096501,"url":"https://github.com/uphold/request-logger","last_synced_at":"2025-07-24T22:32:02.630Z","repository":{"id":64331130,"uuid":"77702387","full_name":"uphold/request-logger","owner":"uphold","description":"A wrapper for the request module that logs all request events.","archived":false,"fork":false,"pushed_at":"2024-12-05T22:50:30.000Z","size":297,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":64,"default_branch":"master","last_synced_at":"2025-06-20T03:52:49.257Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"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/uphold.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-12-30T18:08:23.000Z","updated_at":"2025-06-06T15:14:50.000Z","dependencies_parsed_at":"2024-04-05T12:31:06.948Z","dependency_job_id":"380c125c-3d5d-42ae-9fee-cd22fa4d9614","html_url":"https://github.com/uphold/request-logger","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/uphold/request-logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uphold%2Frequest-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uphold%2Frequest-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uphold%2Frequest-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uphold%2Frequest-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uphold","download_url":"https://codeload.github.com/uphold/request-logger/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uphold%2Frequest-logger/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266204534,"owners_count":23892364,"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":[],"created_at":"2024-12-01T04:11:20.647Z","updated_at":"2025-07-24T22:32:02.286Z","avatar_url":"https://github.com/uphold.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# request-logger\n\nA wrapper for the [request](https://github.com/cypress-io/request) module that logs all request events.\n\n## Status\n\n[![npm version][npm-image]][npm-url] [![build status][travis-image]][travis-url]\n\n## Installation\n\nInstall the package via **yarn**:\n\n```shell\n❯ yarn add '@uphold/request-logger'\n```\n\nOr via **npm**:\n\n```shell\n❯ npm install '@uphold/request-logger' --save\n```\n\n## Usage\n\nWrap the `request` module using `@uphold/request-logger`. By default, all events will be logged to `stdout`.\n\n```javascript\nconst logger = require('@uphold/request-logger');\nconst request = logger(require('@cypress/request'));\n\nrequest.get('https://www.github.com');\n\n// { headers: …,\n//   id: '6bfc21a0-0dad-48b2-8378-762e5f85f014',\n//   method: 'GET',\n//   type: 'request',\n//   uri: 'https://www.github.com/' }\n// { headers: …,\n//   id: '6bfc21a0-0dad-48b2-8378-762e5f85f014',\n//   statusCode: 301,\n//   type: 'redirect',\n//   uri: 'https://github.com/' }\n// { headers: …,\n//   id: '6bfc21a0-0dad-48b2-8378-762e5f85f014',\n//   method: 'GET',\n//   type: 'request',\n//   uri: 'https://github.com/' }\n// { headers: …,\n//   id: '6bfc21a0-0dad-48b2-8378-762e5f85f014',\n//   statusCode: 200,\n//   type: 'response',\n//   uri: 'https://github.com/' }\n```\n\nYou can optionally define a custom logging function which receives the request object (`data`) and the `request` instance:\n\n```javascript\nconst logger = require('@uphold/request-logger');\nconst request = logger(require('@cypress/request'), data =\u003e console.log(`${data.id} ${data.type}: ${data.uri}${data.statusCode ? ` (${data.statusCode})` : ''} ${(data.body ? `${data.body}` : '').length} bytes`));\n\nrequest.get('https://www.github.com', () =\u003e {});\n\n// 8a3600f9-0995-4a89-951f-caf7c0a79a69 request: https://www.github.com/ 0 bytes\n// 8a3600f9-0995-4a89-951f-caf7c0a79a69 redirect: https://github.com/ (301) 0 bytes\n// 8a3600f9-0995-4a89-951f-caf7c0a79a69 request: https://github.com/ 0 bytes\n// 8a3600f9-0995-4a89-951f-caf7c0a79a69 response: https://github.com/ (200) 25562 bytes\n```\n\nEach `data` object contains a `type` property indicating the type of event:\n\n- **error** - the request has failed due to an error (e.g. a timeout). `data.error` is defined.\n\n- **request** - the request succeeded. `data.body` may be defined for POST requests.\n\n- **response** - the request returned a response. Note that `request` only buffers the response body if a callback was given, so only in that case will `data.body` be defined.\n\n- **redirect** - the request received a redirect status code (_HTTP 3xx_). `data.uri` will point to the URI of the next request.\n\n- **complete** - the request has been completed. This event is only dispatched on POST requests.\n\nIn every event, a `data.id` parameter is defined to allow matching it to the request it originated from.\n\n## Compatibility\n\nThe recommended node.js version is `\u003e= 6` as it ships with native [ES2015 Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) support. This module supports node.js `4` by means of a polyfill that is loaded under the hood. As usual, keep in mind that polyfills are not as performant as their native counterpart.\n\nThe minimum required `request` version is `2.27.0`, although `2.54.0` is a particularly troubled version which is best avoided.\n\n## Release process\n\nThe release of a version is automated via the [release](https://github.com/uphold/request-logger/.github/workflows/release.yaml) GitHub workflow.\nRun it by clicking the \"Run workflow\" button.\n\n## License\n\nMIT\n\n[npm-image]: https://img.shields.io/npm/v/@uphold/request-logger.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/@uphold/request-logger\n[travis-image]: https://img.shields.io/travis/uphold/request-logger.svg?style=flat-square\n[travis-url]: https://travis-ci.org/uphold/request-logger\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuphold%2Frequest-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuphold%2Frequest-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuphold%2Frequest-logger/lists"}