{"id":21095491,"url":"https://github.com/faebeee/lord-fakealot","last_synced_at":"2025-03-14T07:13:04.694Z","repository":{"id":148246153,"uuid":"159784124","full_name":"faebeee/lord-fakealot","owner":"faebeee","description":"Mock data generator for your next project","archived":false,"fork":false,"pushed_at":"2018-12-14T10:36:36.000Z","size":226,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-21T01:44:17.757Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://faebeee.github.io/lord-fakealot/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/faebeee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2018-11-30T07:19:04.000Z","updated_at":"2018-12-14T10:36:23.000Z","dependencies_parsed_at":"2023-05-25T05:45:35.110Z","dependency_job_id":null,"html_url":"https://github.com/faebeee/lord-fakealot","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faebeee%2Flord-fakealot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faebeee%2Flord-fakealot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faebeee%2Flord-fakealot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faebeee%2Flord-fakealot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/faebeee","download_url":"https://codeload.github.com/faebeee/lord-fakealot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243538135,"owners_count":20307104,"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-11-19T22:26:41.301Z","updated_at":"2025-03-14T07:13:04.674Z","avatar_url":"https://github.com/faebeee.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lord-fakealot\n\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a6989f4384e0440394870f22ad1c0f8f)](https://app.codacy.com/app/faebeee/lord-fakealot?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=faebeee/lord-fakealot\u0026utm_campaign=Badge_Grade_Dashboard)\n\n`lord-fakealot` is a utility to generate mocked data based on typescript interfaces.\nIt loads all interfaces from a given directory and can either expose an HTTP api or\ngenerate `json` files with mocked data in it\n\n## Install\n`npm i -g lord-fakealot`\nThis will then expose `fakealot` as a CLI entrypoint for this app\n\n## Data population\nUnder the hood, `lord-fakealot` uses faker. You can use any [faker API Method](https://github.com/marak/Faker.js/#api-methods) \nin your annotations by writing `@faker \u003capi method\u003e`.\n\n__Example__\n```typescript\nexport interface FakerInterface {\n    /**\n     * @faker lorem.word\n     */\n    word: string;\n    \n    /**\n     * @faker lorem.paragraphs\n     */\n    paragraphs: string;\n    \n    /**\n     * @faker finance.amount\n     */\n    finance: string;\n    \n}\n```\n \n\n## Commands\n\n|command | description |\n|---|---|\n|help | prints the help text|\n|api| exposes an HTTP API on a given port|\n|file| generate a file containing all populated interfaces|\n|files| generating a folder, containing JSON a json file for each interface |\n\n### `help`\nPrints the help info to the CLI\n\n```bash\nfakealot -h\n```\n\n\n### `files`\nThis commands create a jsonfile for every interface found in the `dir` directory. The name of each file\nis the interfacename.\n\n```bash\nfakealot files --out ./out --dir ./test [--tsconfig ./tsconfig.json]\n```\n\n#### Options\n\n| Name | Type | Description |\n|---|---|---|\n| --dir | string | Directory path where all the interfaces are stored in. Dir will be searched recursive|\n| --out | string | Folder where all files will be created |\n| --tsconfig | string - optional | Path to the tsconfig file\n\nCreate a directory `out` with files in it. \nEach file then contains directly the interface data like this:\n\n__ComplexInterface.ts__\n```typescript\nexport default interface ComplexInterface {\n    type: string;\n    \n    /**\n     * @minimum 2\n     * @maximum 2\n     */\n    items: IItem[];\n    \n}\n\nexport interface IItem {\n    name: string;\n    \n    /**\n     * @minimum 0\n     * @type integer\n     */\n    position: number;\n}\n```\n\n___ComplexInterface.json___\n```json\n{\n    \"items\": [\n        {\n            \"name\": \"dolore in qui et\",\n            \"position\": 70112329\n        },\n        {\n            \"name\": \"tempor anim irure laborum\",\n            \"position\": 77636896\n        }\n    ],\n    \"type\": \"aute dolor id enim culpa\"\n}\n```\n\n\n### `file`\nThe `file` command will create a file, which stores a a collection with fake data for all interfaces found in the `dir`\n\nThe command\n\n```bash\nfakealot file --file ./mock.json --dir ./interfaces --tsconfig ./tsconfig.json\n```\n\n#### Options\n\n| Name | Type |Description |\n|---|---|---|\n| --dir | string | Directory path where all the interfaces are stored in. Dir will be searched recursive|\n| --file | string | Path to file where the data will be dumped |\n| --tsconfig | string - optional | Path to the tsconfig file\n\nwill create a new file name `mock.json`\n\nwith the content\n\n```json\n{\n    \"ComplexInterface\": {\n        \"items\": [\n            {\n                \"name\": \"laboris ut\",\n                \"position\": 76655555\n            },\n            {\n                \"name\": \"ullamco officia esse\",\n                \"position\": 82465766\n            }\n        ],\n        \"type\": \"occaecat do\"\n    },\n    \"FakerInterface\": {\n        \"finance\": \"696.47\",\n        \"paragraphs\": \"Molestiae tempora eligendi omnis quisquam. Quos nihil dolor voluptatibus velit nobis culpa deleniti. Reprehenderit in nisi et. Quia odio et inventore eligendi in deserunt id. Sit odio quia vitae provident quo provident molestiae.\\n \\rPariatur quos est quod laborum. Quisquam esse quia expedita commodi. Tempora ut exercitationem doloribus harum. Sunt omnis et accusantium et quia quos sequi molestiae. Enim necessitatibus molestiae.\\n \\rEligendi rerum excepturi et laudantium fuga similique fugit corporis voluptatem. Esse nobis et sint magnam aut. Dolores maiores incidunt occaecati iusto laborum. Quia deleniti dolorem quibusdam id veniam perspiciatis et nisi. Corporis laboriosam esse. Soluta accusamus officiis ut excepturi blanditiis libero ut.\",\n        \"word\": \"qui\"\n    },\n    \"LangSwitch\": {\n        \"isActive\": \"yes\",\n        \"languages\": [\n            {\n                \"label\": \"velit Excepteur consectetur eiusmod\",\n                \"path\": \"ad\"\n            },\n            {\n                \"label\": \"sunt\",\n                \"path\": \"est\"\n            },\n            {\n                \"label\": \"eu nulla mollit\",\n                \"path\": \"ut dolore amet\"\n            },\n            {\n                \"label\": \"commodo\",\n                \"path\": \"cillum \"\n            }\n        ],\n        \"type\": \"Enim tempore non voluptas quia vitae ipsam. Necessitatibus et dolor adipisci dolores sunt non explicabo occaecati. Nesciunt et sint est asperiores sit voluptatum mollitia enim iste. Nesciunt minima sequi voluptas optio aut voluptatem. Eligendi voluptates iste eius iure commodi molestiae. Voluptas quo ex reprehenderit ipsa incidunt corporis vel in.\"\n    },\n    \"MultiFileInterface\": {\n        ...\n    }\n}\n```\n\n### `api`\nThis command creates a server which then can be accessed from you App. By passing the interface name to the route,\ndata with the same structure as the interface is served.\n\n```bash\n    fakealot api --port 3000 --dir ./SRC --tsconfig ./tsconfig.json\n```\nnow by visting `http://localhost:3000/api/schema/{INTERFACENAME}` you'll get some mocked data.\n\n#### Options\n\n| Name | Type |Description |\n|---|---|---|\n| --dir | string | Directory path where all the interfaces are stored in. Dir will be searched recursive|\n| --port | number | Port number\n| --tsconfig | string - optional | Path to the tsconfig file\n\n\n\n__Interface__\n```typescript\nexport default interface LangSwitch {\n    /**\n     * Type definition\n     * @faker lorem.paragraph\n     */\n    type: string;\n\n    /**\n     * Type definition\n     * @pattern yes|no\n     */\n    isActive: string;\n    \n    languages: ILink[];\n}\n\nexport interface ILink {\n    path: string;\n    label: string;\n    external?: boolean;\n    icon?: IIcon;\n}\n\nexport interface IIcon {\n    symbol: string;\n    size: string;\n    dynamicSize?: boolean;\n}\n\n```\n\n__HTTP Response__\n```json\n{\n    \"isActive\": \"no\",\n    \"languages\": [\n        {\n            \"label\": \"irure Exce\",\n            \"path\": \"Excepteur\"\n        },\n        {\n            \"label\": \"minim incididunt proident\",\n            \"path\": \"elit exercitation\"\n        },\n        {\n            \"label\": \"Lorem commodo\",\n            \"path\": \"exercitation occaecat laborum\"\n        },\n        {\n            \"label\": \"ea sit nostrud aute\",\n            \"path\": \"aute\"\n        }\n    ],\n    \"type\": \"Culpa nihil quia quis porro voluptatem vel. Libero fugiat doloremque deserunt quidem totam aperiam tempore. Reprehenderit rem cumque quia delectus perspiciatis sunt et. Et officia repellat. Assumenda excepturi sunt et aut corporis cumque quos distinctio. Ab quia autem consectetur occaecati nemo molestiae nisi temporibus soluta.\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaebeee%2Flord-fakealot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffaebeee%2Flord-fakealot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaebeee%2Flord-fakealot/lists"}