{"id":13455396,"url":"https://github.com/graphql-editor/ts-api-faker","last_synced_at":"2025-04-22T23:27:15.084Z","repository":{"id":43966799,"uuid":"151925936","full_name":"graphql-editor/ts-api-faker","owner":"graphql-editor","description":"Micro api faker written in TypeScript which returns faked data from JSON queries","archived":false,"fork":false,"pushed_at":"2023-09-01T13:07:26.000Z","size":1722,"stargazers_count":44,"open_issues_count":10,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-05T16:01:44.720Z","etag":null,"topics":["api","fake","microservice","node","rest","server","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/graphql-editor.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2018-10-07T09:35:27.000Z","updated_at":"2025-03-04T13:03:09.000Z","dependencies_parsed_at":"2024-02-17T06:32:57.882Z","dependency_job_id":"ec78d2aa-2b6d-46ee-b997-e25a45a69551","html_url":"https://github.com/graphql-editor/ts-api-faker","commit_stats":null,"previous_names":["slothking-online/ts-api-faker"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-editor%2Fts-api-faker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-editor%2Fts-api-faker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-editor%2Fts-api-faker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-editor%2Fts-api-faker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphql-editor","download_url":"https://codeload.github.com/graphql-editor/ts-api-faker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249308846,"owners_count":21248704,"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":["api","fake","microservice","node","rest","server","typescript"],"created_at":"2024-07-31T08:01:04.882Z","updated_at":"2025-04-17T03:30:49.033Z","avatar_url":"https://github.com/graphql-editor.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"![](img/logo.jpg)\n\n## What is it?\n\nMinimal fake API server based on faker.js and unsplash.com\n\n## Why should you use it?\n\nTo fake backend before its made and start frontend development just after project planning.\n\n## How it works?\n\n![](img/fakerserver.gif)\n\n## How to use it?\n\nAfter making post request with json argument\n\n```json\n[\n    {\n      \"name\": \"name.firstName\",\n      \"surname\": \"name.lastName\",\n      \"mail\": \"internet.email\",\n      \"profilePhoto\": \"internet.avatar\",\n      \"animalPhoto\": \"image.dog\"\n    },\n    \"@repeat:1\"\n]\n```\n\nit returns\n\n```json\n[\n    {\n        \"animalPhoto\": \"https://source.unsplash.com/200x200/?cat\",\n        \"profilePhoto\": \"https://s3.amazonaws.com/uifaces/faces/twitter/gu5taf/128.jpg\",\n        \"mail\": \"Bernhard_Bradtke@hotmail.com\",\n        \"surname\": \"Schaefer\",\n        \"name\": \"Madelynn\"\n    },\n    {\n        \"animalPhoto\": \"https://source.unsplash.com/200x200/?dog\",\n        \"profilePhoto\": \"https://s3.amazonaws.com/uifaces/faces/twitter/Elt_n/128.jpg\",\n        \"mail\": \"Eula_Spencer24@gmail.com\",\n        \"surname\": \"Herzog\",\n        \"name\": \"Lempi\"\n    }\n]\n```\n\nAnt these 2 photos looks like\n\n![](https://source.unsplash.com/200x200/?cat)\n\n![](https://source.unsplash.com/200x200/?dog)\n\n\n### Directives are also available for use:\n`@key` - use the name from the key to generate a value from, usage:\n```\n    {\n        \"name\": \"@key\"\n    }\n\n    returns, ex:\n\n    {\n        \"name\": \"\u003cgenerated value (random method from name collection)\u003e\"\n    }\n```\n`@repeat` - only for lists, replicates the object in a specified number of times, usage:\n```\n[\n    {\n        \"name\": \"name.firstName\"\n    },\n    \"@repeat:1\"\n]\n\nreturns, ex:\n[\n    {\n        \"name\": \"Alice\"\n    },\n    {\n        \"name\": \"Dennor\"\n    }\n]\n```\n`@static` - determines that the generated value is consistent for all objects, usage:\n```\n[\n    {\n        \"name\": \"@static:name.firstName\", (or name.firstname@static)\n        \"surname\": \"name.lastName\"\n    },\n    \"@repeat:1\"\n]\n\nreturns, ex:\n[\n    {\n        \"name\": \"Connor\"\n        \"surname\": \"Json\"\n    },\n    {\n        \"name\": \"Connor\",\n        \"surname\": \"Kowalsky\"\n    }\n]\n```\n`@settings` - generation settings.\n- data - source of static data for `@data` directive\n- definitions - reusable fake definitions for `@use` direective\n- root - if `true`, value under rootValue is treated as output root\n\n`@data` - directive for static data\n\n`@use` - takes reusable definitions from `@settings\n\ncomplete example:\n```\n{\n\t\"@settings\": {\n\t\t\"data\": {\n\t\t\t\"name\": \"Michal\"\n\t\t},\n\t\t\"definitions\": {\n            \"photo\": {\n\t\t\t\t\"dateTaken\": \"@static:date.pas\",\n\t\t\t\t\"url\": \"image.girl.640.480\",\n\t\t\t\t\"placeLat\": \"addrss.latitu\",\n\t\t\t\t\"placeLong\": \"address.longitude\"\n\t\t\t}\n        },\n        \"root\": true\n\t},\n\t\"out\": [\n\t\t{\n            \"commerce\": \"@key\",\n            \"name\": \"@data:name\",\n\t\t\t\"address\": {\n\t\t\t\t\"street\": \"address.streetName\",\n\t\t\t\t\"city\": \"adess.secondyAddss\"\n            },\n            \"date\": \"date.past\",\n\t\t\t\"avatar\": \"shpe.circ\",\n\t\t\t\"photos\": [\n\t\t\t\t\"1@repeat,@use:photo\"\n            ]\n\t\t},\n\t\t\"@repeat:1\"\n    ]\n}\n\nreturns, ex:\n\n[\n    {\n        \"commerce\": \"Generic Steel Ball\",\n        \"name\": \"Michal\",\n        \"address\": {\n            \"street\": \"Bins Street\",\n            \"city\": \"Apt. 373\"\n        },\n        \"date\": \"2020-02-04T12:36:22.679Z\",\n        \"avatar\": \"\u003csvg height=\\\"98\\\" width=\\\"98\\\"\u003e\u003ccircle cx=\\\"49\\\"    cy=\\\"49\\\" r=\\\"49\\\" stroke=\\\"#00ff00\\\" stroke-width=\\\"4\\\"        fill=\\\"#00ff00\\\"/\u003e\u003c/svg\u003e\",\n        \"photos\": [\n            {\n                \"dateTaken\": \"2016-01-06T18:53:55.060Z\",\n                \"url\": \"https://source.unsplash.com/640x480/?girl\",\n                \"placeLat\": \"33.2601\",\n                \"placeLong\": \"144.7978\"\n            },\n            {\n                \"dateTaken\": \"2016-01-06T18:53:55.060Z\",\n                \"url\": \"https://source.unsplash.com/640x480/?girl\",\n                \"placeLat\": \"1.3206\",\n                \"placeLong\": \"128.1190\"\n            }\n        ]\n    },\n    {\n        \"commerce\": \"604.00\",\n        \"name\": \"Michal\",\n        \"address\": {\n            \"street\": \"Ophelia Manors\",\n            \"city\": \"Apt. 499\"\n        },\n        \"date\": \"2019-11-15T08:59:17.824Z\",\n        \"avatar\": \"\u003csvg height=\\\"166\\\" width=\\\"166\\\"\u003e\u003ccircle cx=\\\"83\\\"  cy=\\\"83\\\" r=\\\"83\\\" stroke=\\\"rgba(0, 255, 200, 0.5)\\\" stroke-width=\\\"15\\\" fill=\\\"red\\\"/\u003e\u003c/svg\u003e\",\n        \"photos\": [\n            {\n                \"dateTaken\": \"2016-01-06T18:53:55.060Z\",\n                \"url\": \"https://source.unsplash.com/640x480/?girl\",\n                \"placeLat\": \"-83.2634\",\n                \"placeLong\": \"-36.3521\"\n            },\n            {\n                \"dateTaken\": \"2016-01-06T18:53:55.060Z\",\n                \"url\": \"https://source.unsplash.com/640x480/?girl\",\n                \"placeLat\": \"22.2511\",\n                \"placeLong\": \"2.0486\"\n            }\n        ]\n    }\n]\n```\n\n### Some examples of arguments to JSON\n\n| Key                 |            Result           |\n| ---                 |             :---:           |\n| address.zipCode     | 73318                       |\n| commerce.department | Toys                        |\n| company.companyName | Grant Group                 |\n| database.type       | text                        |\n| date.future         | 2016-12-12T14:50:49.361Z    |\n| lorem.words         | itaque nostrum molestiae    |\n\nLearn more about arguments that can be passed in JSON in [Faker.js Repo](https://github.com/marak/Faker.js/).\n\n\n## Installation\n\nClone this repo and run\n\n```\nnpm install\nnpm run build\n```\n\n## Run development server\n\n```\nnpm run dev\n```\n\n## Run production server\n\n```\nnpm run start\n```\n\nor using docker image\n\n```\ndocker run -d -p 3000:3000 slothking/ts-api-faker\n```\n\n## Build\n\n```\nnpm run build\n```\n\n\n\n## Contribute\n\nFeel free to contact us and contribute. aexol@aexol.com\n\n1.  fork this repo\n2.  Create your feature branch: git checkout -b feature-name\n3.  Commit your changes: git commit -am 'Add some feature'\n4.  Push to the branch: git push origin my-new-feature\n5.  Submit a pull request\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-editor%2Fts-api-faker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphql-editor%2Fts-api-faker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-editor%2Fts-api-faker/lists"}