- git clone this repository
- run
npm install
to get "fs, json-schema-faker, @faker-js/faker & json-server" dependencies - write your schema
- write your generator function
- write the scripts to run the generator function and serve your generated data in a specified port
- in order to clone this repo, enter the code below into your terminal
git clone https://github.com/Andreyhuey/mock-api.git
- To install the needed dependencies, run the code below in your terminal
npm install json-server json-schema-faker
npm install --save-dev @faker-js/faker fs jest
- write your schema, In this case we are going to write the schema for a user object containing
i) navigate to the src/schema
folder, several other sample schemas are provided in the folder
ii) locate theuserSchema.js
file
- write your generator function which uses json-schema-faker to create the data from the imported schema provided
- write the scripts provided below and run the
npm run start-users
to complete the mock-api
npm run start-users
Once the npm run start-users
is started in the terminal you can start performing CRUD functionality and enjoy your mock-api