{"id":27147322,"url":"https://github.com/http-party/registry-mock","last_synced_at":"2025-07-08T07:38:53.472Z","repository":{"id":63291352,"uuid":"46466907","full_name":"http-party/registry-mock","owner":"http-party","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-28T19:34:18.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-28T12:23:02.981Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/http-party.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":"2015-11-19T04:10:28.000Z","updated_at":"2025-03-26T13:32:20.000Z","dependencies_parsed_at":"2022-11-16T12:31:14.675Z","dependency_job_id":null,"html_url":"https://github.com/http-party/registry-mock","commit_stats":null,"previous_names":["http-party/registry-mock","jcrugzz/registry-mock"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/http-party/registry-mock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/http-party%2Fregistry-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/http-party%2Fregistry-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/http-party%2Fregistry-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/http-party%2Fregistry-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/http-party","download_url":"https://codeload.github.com/http-party/registry-mock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/http-party%2Fregistry-mock/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262435287,"owners_count":23310628,"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":"2025-04-08T11:23:36.124Z","updated_at":"2025-07-08T07:38:53.465Z","avatar_url":"https://github.com/http-party.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# registry-mock\n\nA simple mock npm registry.\n\n## Usage\n\n``` js\nvar registryMock = require('registry-mock');\nregistryMock({ http: 8080 }, (err, registry) =\u003e {\n  if (err) { /* handle me */ }\n\n  console.log('Mock npm registry listening on 8080');\n});\n```\n\n`registry-mock` is designed to be a generic caching HTTP server for asserting that proxied\n`npm` registry HTTP calls send the correct payloads and/or headers to the target registry.\nIn order to test some npm-specific routes (such as publish) it is necessary to cache tarballs\nand later serve them.\n\n### HTTP \u0026 cache conventions\n\nThe response to incoming requests can be summarized based on a few simple rules:\n\n1. All requests to `/.*tgz` or those with the `X-FETCH-CACHE` header\nrespond with the last request body received for that route.\n  - If there is no cache for that route a `404` is served.\n  - If `X-CLEAR-CACHE` is provided to a cache hit request, then\n    the cache is cleared for that route.\n\n- All other requests are cached for future assertion\n  and the response is given from the JSON parsed\n  `X-SEND-RESPONSE` header:\n``` js\n   {\n     \"body\": { an: 'unstringified JSON object' },\n     \"status\": 200\n   }\n```\n  - npm publish `PUT /:pkg` splits out the tarball and makes\n    the cache for `/:pkg/-/:pkg-:version.tgz` available for\n    download.\n\n### Using `npm-registry-echo`\n\nThis package also ships a binary named `npm-registry-echo` this program runs a simple\n`registry-mock` server and then fetches the cache immediately after all requests. This\nallows for simple introspection of the payloads that are sent from the `npm` CLI.\n\ne.g. **Viewing `npm publish` payloads**\n\n#### 1. Running `npm-registry-echo`\n```\n$ npm i -g registry-mock\n$ npm-registry-echo\nnpm-registry-echo listening on 3676\n```\n\n#### 2. Add garbage nerf darts to your `~/.npmrc`\n```\n//localhost:3676/:_password=garbage!!password\n//localhost:3676/:username=garbage!!user\n//localhost:3676/:email=anyvalid@email.com\n//localhost:3676/:always-auth=false\n```\n\n#### 3. Run `npm publish` against your echo\n```\nnpm publish --reg=http://localhost:3676 --loglevel=http\nnpm http request PUT http://localhost:3676/test-publish03\nnpm http 201 http://localhost:3676/test-publish03\n+ test-publish03@1.0.0\n```\n\n#### 4. See the output\n```\nPUT /test-publish03 {\"_id\":\"test-publish03\",\"name\":\"test-publish03\",\"description\":\"Just a\ntest\",\"dist-tags\":{\"latest\":\"1.0.0\"},\"versions\":{\"1.0.0\":{\"name\":\"test-publish03\",\"version\":\n\"1.0.0\",\"description\":\"Just a test\",\"main\":\"index.js\",\"scripts\":{\"test\":\"echo \\\"Error: no test\nspecified\\\" \u0026\u0026 exit 1\"},\"author\":\"\",\"license\":\"ISC\",\"readme\":\"ERROR: No README data found!\",\n\"_id\":\"test-publish03@1.0.0\",\"_shasum\":\"6e78734fff0347a9596abb5d3b0360fda6f1a899\",\"_from\":\".\",\n\"_npmVersion\":\"3.7.1\",\"_nodeVersion\":\"4.2.2\",\"_npmUser\":{\"name\":\"garbage!!user\",\"email\":\n\"anyvalid@email.com\"},\"maintainers\":[{\"name\":\"garbage!!user\",\"email\":\"anyvalid@email.com\"}],\n\"dist\":{\"shasum\":\"6e78734fff0347a9596abb5d3b0360fda6f1a899\",\"tarball\":\n\"http://localhost:3676/test-publish03/-/test-publish03-1.0.0.tgz\"}}},\"readme\":\"ERROR:\nNo README data found!\",\"maintainers\":[{\"name\":\"garbage!!user\",\"email\":\"anyvalid@email.com\"}],\n\"_attachments\":{\"test-publish03-1.0.0.tgz\":{\"content_type\":\"application/octet-stream\",\n\"data\":\"{{BIG-BASE64-TARBALL}}\",\"length\":568}}}\n```\n\n##### License MIT\n##### Authors: [Charlie Robbins](https://github.com/indexzero), [Jarrett Cruger](https://github.com/jcrugzz)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhttp-party%2Fregistry-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhttp-party%2Fregistry-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhttp-party%2Fregistry-mock/lists"}