Fake REST API for front end testing using JSON format 🧶 ..
- ✨ Node.js v10+ (required)
- 🧬 Git (optional)
Follow these steps to be able to run this project;
- Open your terminal (e.g
Terminal
,PowerShell
,iTerm2
,Git Bash
). - Go to the path that you want to use for the project (e.g
~/Desktop
). - I prefer to use Git to clone this module but you can click the
download button
<git clone https://github.com/3imed-jaberi/fake-rest-json-api.git
>. - Navigate to the cloned repository <
cd fake-rest-json-api
>. - Install dependencies by run this command <
npm i
oryarn
>. - Now, you can run one of this scripts (
useJSON
,useDefaultJSON
,useModel
,useDefaultModel
).- useJSON: create your API by your specific
.json
file
<npm run useJSON xxx.json
oryarn run useJSON xxx.json
>. - useDefaultJSON: use
db.json
file to create your API
<npm run useDefaultJSON
oryarn run useDefaultJSON
>. - useModel: create your API by your specific
.js
file
<npm run useModel xxx.js
oryarn run useModel xxx.js
>. - useDefaultModel: use
index.js
file to create your API
<npm run useDefaultJSON
oryarn run useDefaultJSON
>.
- useJSON: create your API by your specific
- If you have cURL or Postman, you can use them to test the endpoint.
Or simply open your browser and copy the path from the text shown at the terminal.
👀 See Here For more options.
JSON Guide
{ "entrypoint": [ // --> /entrypoint { "data": "xxxx" }, ... // other data ], "home": [ // --> /home { "name": "xxxx" }, ... // other data ], ... // other entrypoints }
JS Guide
function generateModel() { // --> /entrypoint // use your logic here .. // you can use 'faker' module .. const entrypoint = [ ...entrypoint, { // data } ];return { entrypoint }; } module.exports = generateModel;