Code Monkey home page Code Monkey logo

fake-rest-api-nodejs's Introduction

Fake REST API NodeJS

Get a full fake REST API with zero coding in less than 30 seconds (NodeJS + JSON Server + JSON Webtoken).

Support JWT Bearer authentication:

  • Register user with username & password or email & password.

  • Login with registered users.

  • Protect API by resource and request methods.

Support upload files (beta).

Vietnamese documents

Getting started

Clone this repository

git clone https://github.com/robinhuy/fake-rest-api-nodejs.git

(or fork to your account and clone the forked repo)

Install dependencies

cd fake-rest-api-nodejs
npm install

Run server

npm start

or

npm run dev

The server will run on http://localhost:3000. Public API: http://localhost:3000/products (GET method).

Modify your data

All the data was placed in database.json. Edit it to suit your purpose.

You can use https://mockaroo.com/ to mock data, and publish your code to https://heroku.com/ to get a Public API.

Note:

  • To protect resources, decleare resources and protected methods in database.json:
    "protected_resources": {
        "users": ["GET", "POST", "PUT", "PATCH", "DELETE"],
        "products": ["POST", "PUT", "PATCH", "DELETE"]
    }
  • User can login by API /login, method POST, using username & password or email & password in resource users. Body request like this:
    {
        "email": "admin",
        "password": "admin"
    }
  • Change default port, database file, jwt secret or jwt token expires in config.json.

Access & modify API

Please view detailed document in https://github.com/typicode/json-server/blob/master/README.md#table-of-contents

If you want to change logic of authentication or add more feature, please edit file server.js.

fake-rest-api-nodejs's People

Contributors

dangdinhvan avatar robinhuy avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.