All Projects → graphql-editor → ts-api-faker

graphql-editor / ts-api-faker

Licence: GPL-3.0 license
Micro api faker written in TypeScript which returns faked data from JSON queries

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to ts-api-faker

Fake Useragent
A wide variety of random useragents
Stars: ✭ 253 (+462.22%)
Mutual labels:  fake
FakeSms
一个短信作弊器,可以在没有接受到短信时在收件箱中伪造短信
Stars: ✭ 28 (-37.78%)
Mutual labels:  fake
FakeNewsBlocker
Get a notification if a website is known to publish fake news
Stars: ✭ 15 (-66.67%)
Mutual labels:  fake
Http Fake Backend
Build a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 253 (+462.22%)
Mutual labels:  fake
webvalve
Betterment's framework for locally developing and testing service-oriented apps in isolation with WebMock and Sinatra-based fakes
Stars: ✭ 111 (+146.67%)
Mutual labels:  fake
react-fake-tweet
React renderer for tweets.
Stars: ✭ 33 (-26.67%)
Mutual labels:  fake
Faker
A library for generating fake data such as names, addresses, and phone numbers.
Stars: ✭ 231 (+413.33%)
Mutual labels:  fake
FakerDotNet
A .NET port of the Ruby faker gem
Stars: ✭ 15 (-66.67%)
Mutual labels:  fake
EasyFake
🤹‍♀️ Fake data generation in Swift
Stars: ✭ 54 (+20%)
Mutual labels:  fake
moq.ts
Moq for Typescript
Stars: ✭ 107 (+137.78%)
Mutual labels:  fake
bs-faker
Faker.js bindings for BuckleScript in Reason
Stars: ✭ 18 (-60%)
Mutual labels:  fake
fakesudo
sudo almost as fake as your ma
Stars: ✭ 15 (-66.67%)
Mutual labels:  fake
ts-mock-imports
Intuitive mocking library for Typescript class imports
Stars: ✭ 103 (+128.89%)
Mutual labels:  fake
Log Fake
A drop in fake logger for testing with the Laravel framework.
Stars: ✭ 254 (+464.44%)
Mutual labels:  fake
legitbot
🤔 Is this Web request from a real search engine🕷 or from an impersonating agent 🕵️‍♀️?
Stars: ✭ 18 (-60%)
Mutual labels:  fake
Fakerpress
A WordPress plugin that implements an easy way to create fake data inside WordPress.
Stars: ✭ 250 (+455.56%)
Mutual labels:  fake
FakePlayer
Specter but targeting PocketMine-MP API 4.0.0
Stars: ✭ 46 (+2.22%)
Mutual labels:  fake
talltale
A Clojure/ClojureScript Fake Data Generator Library
Stars: ✭ 62 (+37.78%)
Mutual labels:  fake
jest-ts-auto-mock
Jest test utility with automatic mock creation for interfaces and classes
Stars: ✭ 150 (+233.33%)
Mutual labels:  fake
useragent-generator
Easily generate correct user-agent strings for popular browsers
Stars: ✭ 62 (+37.78%)
Mutual labels:  fake

What is it?

Minimal fake API server based on faker.js and unsplash.com

Why should you use it?

To fake backend before its made and start frontend development just after project planning.

How it works?

How to use it?

After making post request with json argument

[
    {
      "name": "name.firstName",
      "surname": "name.lastName",
      "mail": "internet.email",
      "profilePhoto": "internet.avatar",
      "animalPhoto": "image.dog"
    },
    "@repeat:1"
]

it returns

[
    {
        "animalPhoto": "https://source.unsplash.com/200x200/?cat",
        "profilePhoto": "https://s3.amazonaws.com/uifaces/faces/twitter/gu5taf/128.jpg",
        "mail": "[email protected]",
        "surname": "Schaefer",
        "name": "Madelynn"
    },
    {
        "animalPhoto": "https://source.unsplash.com/200x200/?dog",
        "profilePhoto": "https://s3.amazonaws.com/uifaces/faces/twitter/Elt_n/128.jpg",
        "mail": "[email protected]",
        "surname": "Herzog",
        "name": "Lempi"
    }
]

Ant these 2 photos looks like

Directives are also available for use:

@key - use the name from the key to generate a value from, usage:

    {
        "name": "@key"
    }

    returns, ex:

    {
        "name": "<generated value (random method from name collection)>"
    }

@repeat - only for lists, replicates the object in a specified number of times, usage:

[
    {
        "name": "name.firstName"
    },
    "@repeat:1"
]

returns, ex:
[
    {
        "name": "Alice"
    },
    {
        "name": "Dennor"
    }
]

@static - determines that the generated value is consistent for all objects, usage:

[
    {
        "name": "@static:name.firstName", (or name.firstname@static)
        "surname": "name.lastName"
    },
    "@repeat:1"
]

returns, ex:
[
    {
        "name": "Connor"
        "surname": "Json"
    },
    {
        "name": "Connor",
        "surname": "Kowalsky"
    }
]

@settings - generation settings.

  • data - source of static data for @data directive
  • definitions - reusable fake definitions for @use direective
  • root - if true, value under rootValue is treated as output root

@data - directive for static data

@use - takes reusable definitions from `@settings

complete example:

{
	"@settings": {
		"data": {
			"name": "Michal"
		},
		"definitions": {
            "photo": {
				"dateTaken": "@static:date.pas",
				"url": "image.girl.640.480",
				"placeLat": "addrss.latitu",
				"placeLong": "address.longitude"
			}
        },
        "root": true
	},
	"out": [
		{
            "commerce": "@key",
            "name": "@data:name",
			"address": {
				"street": "address.streetName",
				"city": "adess.secondyAddss"
            },
            "date": "date.past",
			"avatar": "shpe.circ",
			"photos": [
				"1@repeat,@use:photo"
            ]
		},
		"@repeat:1"
    ]
}

returns, ex:

[
    {
        "commerce": "Generic Steel Ball",
        "name": "Michal",
        "address": {
            "street": "Bins Street",
            "city": "Apt. 373"
        },
        "date": "2020-02-04T12:36:22.679Z",
        "avatar": "<svg height=\"98\" width=\"98\"><circle cx=\"49\"    cy=\"49\" r=\"49\" stroke=\"#00ff00\" stroke-width=\"4\"        fill=\"#00ff00\"/></svg>",
        "photos": [
            {
                "dateTaken": "2016-01-06T18:53:55.060Z",
                "url": "https://source.unsplash.com/640x480/?girl",
                "placeLat": "33.2601",
                "placeLong": "144.7978"
            },
            {
                "dateTaken": "2016-01-06T18:53:55.060Z",
                "url": "https://source.unsplash.com/640x480/?girl",
                "placeLat": "1.3206",
                "placeLong": "128.1190"
            }
        ]
    },
    {
        "commerce": "604.00",
        "name": "Michal",
        "address": {
            "street": "Ophelia Manors",
            "city": "Apt. 499"
        },
        "date": "2019-11-15T08:59:17.824Z",
        "avatar": "<svg height=\"166\" width=\"166\"><circle cx=\"83\"  cy=\"83\" r=\"83\" stroke=\"rgba(0, 255, 200, 0.5)\" stroke-width=\"15\" fill=\"red\"/></svg>",
        "photos": [
            {
                "dateTaken": "2016-01-06T18:53:55.060Z",
                "url": "https://source.unsplash.com/640x480/?girl",
                "placeLat": "-83.2634",
                "placeLong": "-36.3521"
            },
            {
                "dateTaken": "2016-01-06T18:53:55.060Z",
                "url": "https://source.unsplash.com/640x480/?girl",
                "placeLat": "22.2511",
                "placeLong": "2.0486"
            }
        ]
    }
]

Some examples of arguments to JSON

Key Result
address.zipCode 73318
commerce.department Toys
company.companyName Grant Group
database.type text
date.future 2016-12-12T14:50:49.361Z
lorem.words itaque nostrum molestiae

Learn more about arguments that can be passed in JSON in Faker.js Repo.

Installation

Clone this repo and run

npm install
npm run build

Run development server

npm run dev

Run production server

npm run start

or using docker image

docker run -d -p 3000:3000 slothking/ts-api-faker

Build

npm run build

Contribute

Feel free to contact us and contribute. [email protected]

  1. fork this repo
  2. Create your feature branch: git checkout -b feature-name
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].