{"id":25044677,"url":"https://github.com/blad/mockingjays","last_synced_at":"2025-04-14T02:00:20.983Z","repository":{"id":57300188,"uuid":"46161886","full_name":"blad/mockingjays","owner":"blad","description":"Mockingjays is a proxying tool that observes and mimics http interactions. ","archived":false,"fork":false,"pushed_at":"2018-12-27T14:14:31.000Z","size":742,"stargazers_count":12,"open_issues_count":13,"forks_count":4,"subscribers_count":5,"default_branch":"develop","last_synced_at":"2025-03-27T15:55:54.359Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.mockingjays.io/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blad.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}},"created_at":"2015-11-14T04:50:22.000Z","updated_at":"2024-06-23T23:00:23.000Z","dependencies_parsed_at":"2022-09-09T15:03:02.183Z","dependency_job_id":null,"html_url":"https://github.com/blad/mockingjays","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blad%2Fmockingjays","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blad%2Fmockingjays/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blad%2Fmockingjays/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blad%2Fmockingjays/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blad","download_url":"https://codeload.github.com/blad/mockingjays/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248809032,"owners_count":21164895,"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-02-06T05:19:00.844Z","updated_at":"2025-04-14T02:00:20.958Z","avatar_url":"https://github.com/blad.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Mockingjays\n========================\n\n[![Circle CI Build Status](https://circleci.com/gh/blad/mockingjays.png?circle-token=a4bd29bc70058220eb8e663e848ff4448231d79a)](https://circleci.com/gh/blad/mockingjays)\n[![npm version](https://badge.fury.io/js/mockingjays.svg)](https://www.npmjs.com/package/mockingjays)\n[![Gitter](https://badges.gitter.im/blad/mockingjays.svg)](https://gitter.im/blad/mockingjays?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n\n*Mockingjays* is a proxying tool that responds to requests with responses that have been previously observed.\n\n\u003ccenter\u003e\n![Mockingjays](http://www.mockingjays.io/dist/images/mockingjays-logo.png)\n\u003c/center\u003e\n\n*Mockingjays* acts as a mock server for previously seen requests and captures new request for future use.\n\n## Install Mockingjays\n\n```bash\nnpm install -g mockingjays\n```\n\n## CLI Use\n\n```bash\nmockingjays serve\\\n  --cacheDir=/var/app/fixtures \\ # Required\n  --serverBaseUrl='http://swapi.co' \\ # Required\n  --cacheHeader='authorization,content-length'\n  --ignoreContentType='image/*,text/html' \\\n  --port=9000 \\\n  --refresh=true \\\n```\n\n### Subcommands\n\nThere are two subcommands that will indicate to Mockingjays what should be done.\nThese modes are `serve` and `rehash`.\n\n`serve` starts up the proxy server that observes and responds to requests.\n\n`rehash` is a process in which the provided options will be parsed, and then applied\nto the existing cache. The `rehash` command is useful for updating the url of the\nsource server, removing headers from the response and request data.\n\n## Javascript API\n\n```javascript\nvar Mockingjays = require('mockingjays');\n\nnew Mockingjays().start({\n  cacheDir: '/var/app/fixtures', // Required\n  serverBaseUrl: 'http://swapi.co', // Required\n  cacheHeader: 'authorization,content-length',\n  ignoreContentType: 'image/*,text/html',\n  port: 9000,\n  refresh: true\n});\n```\n\n### Methods\n\n`start` - Start creates a Mockingjays server and starts proxying or mocking\n          responses based on previous training.\n`stop` - Stops an existing Mockingjays server.\n`rehash` - Processes the existing cache with a new set of options.\n\n## Options\n\n- **serverBaseUrl** -Place where an unseen request can be learned.   \n  - ***Required***\n- **cacheDir** - Directory where request/response data should be stored.\n  - ***Required***\n- **cacheHeader** - Headers that should be considered as part of the cache signature. By default all headers are ignored in the cache signature.\n  - *Default: ''*\n- **logLevel** - The Level of Logging information that should be displayed to the console.\n  - The available options are ranked from least info to most info:\n    * `none` - Nothing is logged.\n    * `error` - Only errors are logged.\n    * `warn` - Errors and warnings are logged.\n    * `info` - Errors, warnings, and info are logged.\n    * `debug` - Everything is logged.\n  - *Default: info*\n- **port** - Port that the proxy server should bind to.\n  - *Default: 9000*\n- **ignoreContentType** - Comma separated list of content-types that should be skipped. This can include a `*` which will be a wildcard match equivalent to the `.*` RegEx. No File Types Ignored by default.\n  - *Default: []*\n- **refresh** - Indicates if the request/response cache should be updated unconditionally.\n  - *Default: false*\n- **passthrough** - Indicates if the request/response cache should be ignored. Each request will passthrough the proxy, but not read/write to any cache files.\n  - *Default: false*\n-  **queryParameterBlacklist** - Comma separated list of query parameters that should not be cached.\n  - *Default: ''*\n- **responseHeaderBlacklist** - Indicates headers that should not be recorded to the cache file. Things like date or fields that may change the file during refreshes are ideal candidates.\n  - *Default: []* (Record all headers)\n- **transitionConfig** - Path or Object to the transition config Object. The transition config defined a mapping between requests that cause state changes, and the requests that are affected. [See Feature File for Example](features/stateful_requests.feature)\n  - *Default: {}* (Consider All Operations Non-Stateful)\n- **whiteLabel** - When set to true, the hostname and port number are not included as part of the request hash.\n  - *Default: false* (Consider hostname and port for cache)\n- *ignoreJsonBodyPath* - The path of a JSON request body to ignore in uniqueness signature. By default no paths will be ignored. eg: `a.b.c` to ignore property `c` inside nested objects `a` and `b`.\n  - CLI: Comma separated list of paths to ignore.\n  - JS: Use Array of paths to ignore.\n\n## Cached Responses\n\nThe root of cached responses specified by the `cacheDir` option. Each response\nis then stored in a subdirectory that matches the path for the request.\n\nFor example, a request to the path: `/api/` when the `cacheDir` option has the value of `/var/app/fixtures`\nwill be stored in `/var/app/fixtures/api/{sha1_request_hash}` where `sha1_request_hash` is a\nhash value of the http request.\n\nRequest with deeper paths such as `/api/people/1/` will create a deep directory structure\ninside the root of the `cacheDir`.\n\n### Cached Responses\n\nEach cached response has the following format:\n```javascript\n{\n  \"request\": { /* Request Being Proxied */ }\n  \"status\": 200, /* Response Status Code */\n  \"type\": \"application/json\", /* Response Content Type */\n  \"headers\": { /* Response Headers */ }\n  \"data\": { /* Response Payload */ }  // Can be object or string base on content type\n}\n```\n\nExample Response:\n```json\n{\n  \"request\": {\n    \"hostname\": \"swapi.co\",\n    \"port\": 80,\n    \"path\": \"/api/\",\n    \"method\": \"GET\",\n    \"headers\": {},\n    \"body\": \"\",\n    \"transaction\": \"\"\n  },\n  \"status\": 200,\n  \"type\": \"application/json\",\n  \"headers\": {\n    \"content-type\": \"application/json\",\n    \"allow\": \"GET, HEAD, OPTIONS\",\n    \"x-frame-options\": \"SAMEORIGIN\"\n  },\n  \"data\": {\n    \"people\": \"http://swapi.co/api/people/\",\n    \"planets\": \"http://swapi.co/api/planets/\",\n    \"films\": \"http://swapi.co/api/films/\",\n    \"species\": \"http://swapi.co/api/species/\",\n    \"vehicles\": \"http://swapi.co/api/vehicles/\",\n    \"starships\": \"http://swapi.co/api/starships/\"\n  }\n}\n```\n\n# Contribute\n\nContributions are welcome to the repository. There are a number of outstanding [issues](https://github.com/blad/mockingjays/issues), which we hope will enhance existing functionality, fix bugs, or add new functionality.\n\nPlease add an issue to propose new features, report bugs, and propose improvements.\n\n[Git Hub Issues for Mockingjays](https://github.com/blad/mockingjays/issues)\n\n# Questions\n\nIf you have questions about the use of Mockingjays please leave a message in the project's Gitter Chat Room.\n\n[![Gitter](https://badges.gitter.im/blad/mockingjays.svg)](https://gitter.im/blad/mockingjays?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n\n# ChangeLog\n\nFor a list of changes between versions please see the [CHANGELOG](./CHANGELOG.md) file.\n\n# License: Apache 2.0\nCopyright 2018 Bladymir Tellez\\\u003cbtellez@gmail.com\\\u003e\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n     http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblad%2Fmockingjays","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblad%2Fmockingjays","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblad%2Fmockingjays/lists"}