{"id":19732008,"url":"https://github.com/devrax/butlermock","last_synced_at":"2025-04-30T02:31:37.328Z","repository":{"id":188537715,"uuid":"678678871","full_name":"Devrax/Butlermock","owner":"Devrax","description":"Tool for creating mocks objects with fake data using TypeScript types/interfaces as schema and Faker as fake data source","archived":false,"fork":false,"pushed_at":"2024-05-01T03:47:46.000Z","size":1431,"stargazers_count":51,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T21:51:10.272Z","etag":null,"topics":["faker","interface","javascript","mocking-utility","types","typescript","web"],"latest_commit_sha":null,"homepage":"https://butlermock.online/","language":"TypeScript","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/Devrax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["Devrafx"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2023-08-15T05:27:04.000Z","updated_at":"2025-02-01T07:17:15.000Z","dependencies_parsed_at":"2024-05-01T04:37:08.879Z","dependency_job_id":"62e98700-2e83-4b97-8d9b-199e9e621f7c","html_url":"https://github.com/Devrax/Butlermock","commit_stats":null,"previous_names":["devrax/butlermock"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Devrax%2FButlermock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Devrax%2FButlermock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Devrax%2FButlermock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Devrax%2FButlermock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Devrax","download_url":"https://codeload.github.com/Devrax/Butlermock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251629160,"owners_count":21618111,"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":["faker","interface","javascript","mocking-utility","types","typescript","web"],"created_at":"2024-11-12T00:24:25.502Z","updated_at":"2025-04-30T02:31:36.465Z","avatar_url":"https://github.com/Devrax.png","language":"TypeScript","readme":"# Butlermock\n\n[![Made with Fresh](https://fresh.deno.dev/fresh-badge-dark.svg)](https://fresh.deno.dev)\n\n\u003ca href=\"https://www.buymeacoffee.com/devrafx\" target=\"_blank\"\u003e\u003cimg src=\"https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png\" alt=\"Buy Me A Coffee\" style=\"height: 37px !important;width: 170px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;\" \u003e\u003c/a\u003e\n\nTool for building mocks from typescript's types/interfaces into object\nwith actual data using Fakerjs\n\n\u003e Documentation on develop, in the near future I will expose the endpoints for you to use it within your client application, so, stay on tune 🐒\n\nTable of contents\n=================\n\n\u003c!--ts--\u003e\n   * [Web usage](#web-usage)\n   * [API usage](#api-documentation)\n   * [Example as package/library](#Example-as-package/library)\n   * [FAQs](#faqs)\n   * [Limitations](#limitations)\n   * [Status](#status)\n\u003c!--te--\u003e\n\n# Web usage\n\nJust go to https://butlermock.online/ and in the left panel paste your interfaces or types, just be aware of the [current limitations](#status) ( I am working for supporting the others )\n\nWait until the monaco editor shows up and paste your interfaces to later clicking the play button and the mock shows up almost immediately.\n\n![Butlermock's landing](doc/assets/landing.png)\n\n\u003e ![button guide](doc/assets/buttons.png)\n\n\u003e The \"play\" button mocks up, \"clipboard\" copies the mock created and the \"X\" button is for cleaning the view\n\n# API documentation\n\nEasy peasy\n\n``` typescript\n\nfetch(new URL(\"/api/mock\", 'https://butlermock.online').href, {\n    method: \"POST\",\n    headers: {\n      \"content-type\": \"application/json\",\n    },\n    body: JSON.stringify({\n      value: `interface Test {\n        Hello: \"World!\";\n        }`,\n      valueForAny: \"null\", // any parseable json value, values: \"null\" | \"\\\"Whatever the text you want\\\"\" | \"{}\" | \"0\" | \"1\" | ... | \"9\"\n      mustReturn: \"\", // empty or the top-level name of the interfaces that you provided\n      quantity: 1, // if is greater than 1, the api response will be an array of the interfaces provided\n    }),\n  })\n  .then(res =\u003e res.json()).then(console.log); // should log:\n  //{\n  // \"Test\": {\n  //    \"Hello\": \"World!\"\n  //  }\n  //}\n\n```\n\n\u003e **Always remember to format your interfacer or type correctly, if you forget to add \";\" it may result in bad parsing** ![Bad format](doc/assets/Butlemock-bad-formatting.jpeg);\n\n\n### Recommedations when using the API\n\nIf you are going to consume the API I suggest that you use fetch() instead of your own HTTPS calling implementation, to avoid sending credentials which I don't store, but security reasons try to use it in the way I suggest, just for privacy reasons. **REPEATING, I DO NOT STORE ANY DATA. :)**.\n\n\n# Example as package/library 👷🏻‍♂️🚧\n\n[Check here](https://github.com/Devrax/Butlermock-package) \u003e Under construction 🚧\n\n# Guide when providing an interface or type to be mocked up\n\n```typescript\nconst mock = new Interface2Mock(`interface Greeting {\n    hello: string;\n    cursed: {\n        damn: string;\n    }[];\n  }`); // ❌ Butler mock cannot process direct objects, yet\n```\n\n```typescript\nconst mock = new Interface2Mock(`interface Greeting {\n    hello: string;\n    cursed: CursedWord[];\n  }\n\n  type CursedWord = {\n    damn: string;\n  }`); // ✅ Butler Mock can format this way\n```\n\n# FAQs\n\n### **Q: Is it using an AI?**\nA: No :)\n\n### Q: How can I tell the API or website to give me a fixed value?\nA: You just type explicitly the value you want:\n``` typescript\ninterface ThisIsSparta {\n  troops: 300;\n  leader: \"Leonidas\";\n  murderedBy: true;\n}\n\ninterface mightBeSparta {\n  troops: 200 | 594 | 2893 | 39;\n  leader: \"Trump\" | \"Me\" | \"You?\";\n  murderedBy: true; // fixed Booleans can not be multiples values, for that use explicitly 'boolean'\n}\n```\n\n### Q: Can I copy full code snippet and it will detect the interfaces?\nA: Yes :)\n![Can I copy full code snippet and it will detect the interfaces?](doc/assets/IlustrationQuestion.png)\n\n# Limitations\n\nThis section is for known limitations that Butlermocks has, but in the future might be able to recognize and mock:\n\n|type| casting | description |\n|----|---------|-------------|\n|Array| Array\u003cstring \\| boolean \\| number \\| any\u003e| This casting is not supported, use (string \\| boolean \\| number \\| any)[] instead|\n|fixed string | When fixed string includes \";\" or \":\" |  When providing a fixed string value with a semicolon in it, you must use escape for that semicolon inside the string for correct json representation; Example: `interface Example { fixedString: \"I am using a semicolon '\\\\;' so I used escaping '\\\\' :)\"; }`|\n\n# Status\n\n- [x] *Interfaces*\n```typescript\ninterface NonMockeableInterface {} // ❌ empty interface\n\ninterface MockeableInterface {\n  somethingToMock: any;\n} // ✅ Mockeable\n\nexport interface AnotherMockeableInterface {\n  anotherThingToMock: any;\n} // ✅ Mockeable, 'export' is ignored\n```\n\n\u003cbr /\u003e\n\n- [x] Interfaces with nested interfaces/types\n```typescript\ntype mockeableType = {\n  name: string;\n} // ✅ Mockeable\n\ninterface MockeableInterface {\n  somethingToMock: any;\n  nestedInterface: AnotherMockeableInterface;\n  extraNestedInterface: AnotherMockeableInterface[];\n} // ✅ Mockeable\n\nexport interface AnotherMockeableInterface {\n  anotherThingToMock: any;\n} // ✅ Mockeable, 'export' is ignored\n```\n\n\u003cbr /\u003e\n\n\n- [x] Interfaces that extends from other interfaces/types\n``` typescript\ninterface That { ... }\n\ninterface This extends That {} // ✅ Mockeable\n```\n\n\u003cbr /\u003e\n\n- [ ] Generic Interfaces\n``` typescript\n// Not mockeable yet\ninterface This\u003cT\u003e {\n  here: T;\n} // ❌\n```\n\n\u003cbr /\u003e\n\n- [ ] Generic Interfaces that extends from other interfaces/types\n```Typescript\n// Not mockeable yet\ninterface Evnt\u003cT\u003e {\n  name: T;\n}\n\ninterface IPropertiesToAdd\u003cT\u003e extends Evnt\u003cT\u003e {\n  on(): void;\n  off(): void;\n} // ❌\n```\n\n\u003cbr /\u003e\n\n- [x] Primitive Type\n``` typescript\n// Not mockeable yet\ntype justString = string; // ✅ Mockeable\n```\n\n\u003cbr /\u003e\n\n- [x] Type object\n``` typescript\ntype justString = {\n  yes: 'you can';\n}; // ✅ Mockeable\n```\n\n\u003cbr /\u003e\n\n- [x] Type with nested interfaces/types\n``` typescript\n\ntype mockeableType = {\n  nestedObject: MockeableInterface;\n} // ✅ Mockeable\n\ninterface MockeableInterface {\n  somethingToMock: any;\n} // ✅ Mockeable\n```\n\n\u003cbr /\u003e\n\n- [ ] Generic Type\n``` typescript\n// Not mockeable yet\ntype IPropertiesToAdd\u003cT extends {}\u003e = T \u0026 {\n    on(): void\n    off(): void\n}; // ❌\n```\n","funding_links":["https://github.com/sponsors/Devrafx","https://www.buymeacoffee.com/devrafx"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevrax%2Fbutlermock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevrax%2Fbutlermock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevrax%2Fbutlermock/lists"}