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 ioryarn>. - Now, you can run one of this scripts (
useJSON,useDefaultJSON,useModel,useDefaultModel).- useJSON: create your API by your specific
.jsonfile
<npm run useJSON xxx.jsonoryarn run useJSON xxx.json>. - useDefaultJSON: use
db.jsonfile to create your API
<npm run useDefaultJSONoryarn run useDefaultJSON>. - useModel: create your API by your specific
.jsfile
<npm run useModel xxx.jsoryarn run useModel xxx.js>. - useDefaultModel: use
index.jsfile to create your API
<npm run useDefaultJSONoryarn 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;