Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/manjushsh/mock-data-provider-express
Dummy data generation API
https://github.com/manjushsh/mock-data-provider-express
api dummy-data fakerjs
Last synced: 4 days ago
JSON representation
Dummy data generation API
- Host: GitHub
- URL: https://github.com/manjushsh/mock-data-provider-express
- Owner: manjushsh
- License: mit
- Created: 2022-01-07T11:17:14.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-11T23:10:37.000Z (almost 2 years ago)
- Last Synced: 2023-03-06T05:42:09.008Z (over 1 year ago)
- Topics: api, dummy-data, fakerjs
- Language: TypeScript
- Homepage: https://mock-data-provider.herokuapp.com/
- Size: 581 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![CodeQL](https://github.com/manjushsh/mock-data-provider-express/actions/workflows/main.yml/badge.svg)](https://github.com/manjushsh/mock-data-provider-express/actions/workflows/main.yml)
# Mock Data Generator
Easy dummy data generation using Faker.js [https://www.npmjs.com/package/faker/v/5.5.3]
## API Reference
#### Get all options
```https
GET /available-options
```
cURL:
```bash
curl --location --request GET 'https://mock-data-provider.herokuapp.com/available-options' \
--header 'Content-Type: application/json'
```
Returns object of languages and keys available to customize Data response.#### Get data by type
```https
GET /api/:type
```
cURL:
```bash
curl --location --request GET 'https://mock-data-provider.herokuapp.com/api/name' \
--header 'Content-Type: application/json'
```
Takes Faker key and returns data as per key. If not passed, all data will be returned.| Parameter | Type | Description |
| :-------- | :------- | :-------------------------- |
| `type` | `string` | *Optional*. type to fetch |#### Get data by type and language
```https
GET /api/:type/:locale
```
cURL - both present:
```bash
curl --location --request GET 'https://mock-data-provider.herokuapp.com/api/name/es' \
--header 'Content-Type: application/json'
```
cURL - Only locale:
```bash
curl --location --request GET 'https://mock-data-provider.herokuapp.com/api/es' \
--header 'Content-Type: application/json'
```
Takes Faker key and language to return data as per key and locale. If type not passed, all data will be returned in that locale.| Parameter | Type | Description |
| :-------- | :------- | :------------------------------ |
| `type` | `string` | *Optional*. type to fetch |
| `locale` | `string` | *Optional*. language to fetch |#### Get Placeholder Image
```https
POST /api/placeholder
```With given body parameters, returns base64 image. Pass JSON parameters in request body.
| Parameter | Type | Description |
| :---------------- | :------- | :--------------------------------- |
| `text` | `string` | _Optional_. Text to display |
| `width` | `number` | _Optional_. Image width |
| `height` | `number` | _Optional_. Image height |
| `fontSize` | `string` | _Optional_. Image text size in px |
| `backgroundColor` | `string` | _Optional_. Image background color |
| `textColor` | `string` | _Optional_. Image text color |Example body of request:
```json
{
"text": "Placeholder Text",
"width": 1920,
"height": 1080,
"fontSize": "24px",
"backgroundColor": "#ACACAC",
"textColor": "#FEFEFF"
}
```
cURL:
```bash
curl --location --request POST 'https://mock-data-provider.herokuapp.com/api/placeholder' \
--header 'Content-Type: application/json' \
--data-raw '{
"text": "Placeholder",
"width": 1920,
"height": 1080,
"fontSize": "24px",
"backgroundColor": "#ACACAC",
"textColor": "#FEFEFF"
}'
```# How to run locally:
- Clone the repository
```bash
git clone https://github.com/manjushsh/fake-data-provider.git
```- Start Server
```bash
cd fake-data-provider
npm install
npm run start
```