All Projects → robinhuy → fake-rest-api-nodejs

robinhuy / fake-rest-api-nodejs

Licence: other
Fake REST API using NodeJS + JSON Server

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to fake-rest-api-nodejs

json-server
Create a dummy REST API from a json file with zero coding in seconds
Stars: ✭ 34 (-24.44%)
Mutual labels:  json-server
react-native-ecommerce
E-commerce mobile application developed using React Native 👔 🎩
Stars: ✭ 60 (+33.33%)
Mutual labels:  json-server
embedio-extras
Additional Modules showing how to extend EmbedIO.
Stars: ✭ 43 (-4.44%)
Mutual labels:  json-server
json-now
$ json-now - Launch an API Server to serve data from a JSON, JS file or faker data with HTTPS support. Based on json-server.
Stars: ✭ 18 (-60%)
Mutual labels:  json-server
DummyJSON
DummyJSON provides different types of REST Endpoints filled with JSON data which you can use in developing the frontend with your favorite framework and library without worrying about writing a backend.
Stars: ✭ 213 (+373.33%)
Mutual labels:  json-server
cruise
A Continuous Integration (CI) management system homework from Thought Works
Stars: ✭ 13 (-71.11%)
Mutual labels:  json-server
vue-netflix-clone
The repository contains the clone of the application with millions of active users in real life.
Stars: ✭ 32 (-28.89%)
Mutual labels:  json-server
next-ifood
Ifood clone made with NextJS ⚛️
Stars: ✭ 68 (+51.11%)
Mutual labels:  json-server
Jarvis
APL-based web service framework supporting JSON or REST
Stars: ✭ 17 (-62.22%)
Mutual labels:  json-server
mokker
The mock does not mock you. The video: https://www.youtube.com/watch?v=gGLNJpC-Ov0
Stars: ✭ 13 (-71.11%)
Mutual labels:  json-server
MythologyOfReactJs
This repository is actually a reactjs tutorial repository. Each repository is named after a mythical god.
Stars: ✭ 13 (-71.11%)
Mutual labels:  json-server
JSONCustomLintr
Library to allow creation, running, and reporting of custom lint rules for JSON files
Stars: ✭ 19 (-57.78%)
Mutual labels:  json-server
json-server-reset
Reset middleware for json-server
Stars: ✭ 13 (-71.11%)
Mutual labels:  json-server
httpbun
A simple HTTP server with responses tuned to be useful in testing HTTP clients. Heavily inspired by httpbin, but doesn't intend to be a perfect clone.
Stars: ✭ 14 (-68.89%)
Mutual labels:  json-server
http-interceptors
The Web apps in this monorepo make HTTP requests and require uniform consistency in how they are executed and handled. This monorepo demonstrates the same app written with Angular and with Svelte. Each app uses HTTP interceptors. The Angular app uses HttpClient and its interceptors while the Svelte app uses Axios and its interceptors.
Stars: ✭ 46 (+2.22%)
Mutual labels:  json-server
dva-typescript-antd-starter-kit
A admin dashboard application demo based on antd by typescript and dva
Stars: ✭ 61 (+35.56%)
Mutual labels:  json-server
gostack-rocketshoes-react
👞 Sample store built with Redux and Redux-Saga
Stars: ✭ 35 (-22.22%)
Mutual labels:  json-server

Fake REST API NodeJS

Get a full fake REST API as soon as possible. Base on NodeJS + JSON Server.

Support more features:

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

  • Login with registered users.

  • Protect resources using JWT Bearer authentication.

  • Upload files.

Preview: https://fake-rest-api-nodejs.herokuapp.com

Getting started

1. Clone this repository

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

or fork to your account and clone the forked repo

2. Install dependencies

cd fake-rest-api-nodejs
npm install

or if you using yarn

cd fake-rest-api-nodejs
yarn install

3. Run server

  • Production mode:

    npm start

    or

    yarn start
  • Development mode (auto reload server when editing using nodemon):

    npm run dev

    or

    yarn dev
  • The server will run on http://localhost:3000. You can test with public endpoint: 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/ or similar hosting 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"]
    }
  • To register new user, using endpoint /register, method POST, request type application/json. Body request like users resources:

  • To login, using endpoint /login, method POST, request type application/json. Body request like this:

    {
      "username": "admin",
      "password": "admin"
    }

    or

    {
      "email": "[email protected]",
      "password": "admin"
    }
  • To renew AccessToken, using endpoint /renew-token, method POST, request type application/json. Body request like this:

    {
      "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEsImlhdCI6MTY1NjMyNzE4NiwiZXhwIjoxNjU2MzI4MDg2fQ.-si1n7yHpjQ2LEyYqZT6ClIFJOqLOeVXRhwjzyvEZMo",
    }
  • To upload single file, using endpoint /upload-file, method POST, request type form-data, field file. Uploaded file stored in /public/uploads/.

  • To upload multiple files, using endpoint /upload-files, method POST, request type form-data, field files. Uploaded files stored in /public/uploads/.

  • 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 or additional_routes.js.

Default Endpoints

View and modify resources in database.json.

Open Endpoints

Open endpoints require no Authentication.

User

  • Login: POST /login

  • Register: POST /register

Product

  • Get products: GET /products

  • Get product by ID: GET /products/:id

Media

  • Upload single file: POST /upload-file

  • Upload multiple files: POST /upload-files

Private Endpoints (require Authentication)

Private endpoints require a valid Token to be included in the header of the request. A Token can be acquired from the Login view above.

User

  • Get users: GET /users

  • Get user by ID: GET /users/:id

  • Create user: POST /users

  • Update user (entire information): PUT /users/:id

  • Update user (partial information) PATCH /users/:id

Product

  • Create product: POST /products

  • Update product (entire information): PUT /products/:id

  • Update product (partial information) PATCH /products/:id

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].