Skip to content

3imed-jaberi/fake-rest-json-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FAKE REST API

Fake REST API for front end testing using JSON format 🧶 ..

Prerequisites

  • ✨ Node.js v10+ (required)
  • 🧬 Git (optional)

Usage

Follow these steps to be able to run this project;

  1. Open your terminal (e.g Terminal, PowerShell, iTerm2, Git Bash).
  2. Go to the path that you want to use for the project (e.g ~/Desktop).
  3. 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>.
  4. Navigate to the cloned repository <cd fake-rest-json-api>.
  5. Install dependencies by run this command <npm i or yarn>.
  6. 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 or yarn run useJSON xxx.json>.
    • useDefaultJSON: use db.json file to create your API
      <npm run useDefaultJSON or yarn run useDefaultJSON>.
    • useModel: create your API by your specific .js file
      <npm run useModel xxx.js or yarn run useModel xxx.js>.
    • useDefaultModel: use index.js file to create your API
      <npm run useDefaultJSON or yarn run useDefaultJSON>.
  7. 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.

Guides

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;

LICENSE

MIT

About

Fake REST API for testing 🧶 ..

Resources

License

Stars

Watchers

Forks

Packages

No packages published