{"id":25729480,"url":"https://github.com/zeucxb/dymock","last_synced_at":"2025-05-07T13:27:18.177Z","repository":{"id":57217563,"uuid":"135373899","full_name":"zeucxb/dymock","owner":"zeucxb","description":"A CLI to simplify the way you create dynamics mocks.","archived":false,"fork":false,"pushed_at":"2022-12-08T05:43:24.000Z","size":58,"stargazers_count":12,"open_issues_count":8,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-14T09:35:26.389Z","etag":null,"topics":["cli","javascript","mocks","mockserver","nodejs","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/dymock","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/zeucxb.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":"2018-05-30T01:55:35.000Z","updated_at":"2023-10-18T18:40:28.000Z","dependencies_parsed_at":"2023-01-24T18:18:10.731Z","dependency_job_id":null,"html_url":"https://github.com/zeucxb/dymock","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeucxb%2Fdymock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeucxb%2Fdymock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeucxb%2Fdymock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeucxb%2Fdymock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zeucxb","download_url":"https://codeload.github.com/zeucxb/dymock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240774341,"owners_count":19855381,"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":["cli","javascript","mocks","mockserver","nodejs","typescript"],"created_at":"2025-02-26T01:26:01.830Z","updated_at":"2025-02-26T01:26:03.058Z","avatar_url":"https://github.com/zeucxb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dymock :alien: :boom:\n[![NPM version](https://badge.fury.io/js/dymock.svg)](https://npmjs.org/package/dymock)\n\n\u003e A CLI to simplify the way you create mocks, dynamic REST APIs mocks. :boom:\n\nDymock allows you to build **a mock server in a simple way**, without programing, focusing on configuration files.\n\nIt gives you the power to **dynamically define witch response send back, based on params match.**\n\n### Proposal\n\nCreate a tool that help us to unblock the mobile or frontend, API integration process. Making possible work in teams without API dependences at the development time.\n\nSo, Dymock should be a way to organize and define APIs contracts together (front/mobile | backend) and enable a simulation of the real API.\n\n##### _Summary_\n\n\u003e Basically, we allows you to **build and run** a server, just with config files, that can send back **different responses based on the params received** in the request.\n\n\n### Installation\n\nWe recommend install dymock globally using [npm](http://npmjs.org):\n\n```bash\nnpm install -g dymock\n```\n\n### Usage\n\nBy default dymock will try to find a `.config` file in a dir based on the request url.\n\ne.g.\n```\nGET /user/login\nDIR ./url/user/login/(.config.js OR .config.json)\n```\n\n---\n\n\nThe config file need to be named as `.config` and is responsible to define two things:\n\n - **options:** a list (array) of:\n \t- **params:** the params that we can match in. `You don't need to set all the request, just params that you wanna match.`\n \t- **response:** the object we'll return if match the params.\n\n- **default:** a default response if nothing match.\n\n\u003e This config file can be a **json** or a **js** file, we recommend **js** to simplify the organization using `require` to import the response file.\n\ne.g.\n\n```json\n// JSON File\n\n{\n  \"options\": [\n    {\n      \"params\": {\n        \"cpf\": 12345\n      },\n      \"response\": {\n        \"message\": \"client\"\n      }\n    },\n    {\n      \"params\": {\n        \"cpf\": 43210\n      },\n      \"response\": {\n        \"message\": \"not client\"\n      }\n    },\n    {\n      \"params\": {}, // GET\n      \"response\": {\n        \"message\": \"Login page\"\n      }\n    }\n  ],\n  \"default\": {\n    \"error\": {\n      \"message\": \"Invalid params\"\n    }\n  }\n}\n```\n\n```javascript\n// JS File\n\nmodule.exports = {\n  options: [\n    {\n      params: {\n        cpf: 12345\n      },\n      response: require('./client.json'),\n    },\n    {\n      params: {\n        cpf: 43210\n      },\n      response: require('./not-client.json'),\n    },\n    {\n      params: {}, // GET\n      response: {\n        message: 'Login page'\n      }\n    }\n  ],\n  default: {\n    error: {\n      message: 'Invalid params'\n    }\n  }\n};\n```\n\nTo run the server defining the port you can do:\n\u003e The default port is: 3000\n```bash\ndymock -p 5000\n```\n\nYou can get help running:\n```bash\ndymock -h\n```\n\nand the version:\n```bash\ndymock -v\n```\n\n### Configuration\n\nIf you want to change the dir structure, you can define were each path will look for the config file.\n\nTo do that you need to create a `.url-config.json` file in your project root.\n\ne.g.\n```json\n[\n  {\n    \"url\": \"user/login/password/forget\",\n    \"path\": \"./remember-password\"\n  },\n  {\n    \"url\": \"post/create/new\",\n    \"path\": \"./post\"\n  }\n]\n```\n\u003e Remember: **If you create this config file, the default mechanism will be disabled.**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeucxb%2Fdymock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzeucxb%2Fdymock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeucxb%2Fdymock/lists"}