Skip to content

Latest commit

 

History

History
174 lines (121 loc) · 2.4 KB

README.md

File metadata and controls

174 lines (121 loc) · 2.4 KB

E Commerce Fake Server

Fake E Commerce server for product and user.

Tech Stack

Server: json-server, cors

Installation

To install the Busy_Buy, follow these steps:

Clone this repository using the following command:

$ git clone https://github.com/sanskar1419/E-Commerce-Server.git

Install the required dependencies for backend using the following command:

$ npm install

or

$ npm i

Start the application using the following command:

$ npm start

Backend Server will run on port 8000:

$ http://localhost:8000

Available Scripts for frontend

In the project directory, you can run:

npm start

Runs the app in the development mode.
Open http://localhost:8000 to view it in your browser.

The page will reload when you make changes.
You may also see any lint errors in the console.

Install

npm install json-server

Usage

Create a db.json or db.json5 file

{
  "posts": [
    { "id": "1", "title": "a title", "views": 100 },
    { "id": "2", "title": "another title", "views": 200 }
  ],
  "comments": [
    { "id": "1", "text": "a comment about post 1", "postId": "1" },
    { "id": "2", "text": "another comment about post 1", "postId": "1" }
  ],
  "profile": {
    "name": "typicode"
  }
}

Routes

Based on the example db.json, you'll get the following routes:

GET    /posts
GET    /posts/:id
POST   /posts
PUT    /posts/:id
PATCH  /posts/:id
DELETE /posts/:id

# Same for comments
GET   /profile
PUT   /profile
PATCH /profile

Params

Conditions

  • ==
  • lt<
  • lte<=
  • gt>
  • gte>=
  • ne!=
GET /posts?views_gt=9000

Range

  • start
  • end
  • limit
GET /posts?_start=10&_end=20
GET /posts?_start=10&_limit=10

Paginate

  • page
  • per_page (default = 10)
GET /posts?_page=1&_per_page=25

Sort

  • _sort=f1,f2
GET /posts?_sort=id,-views

Nested and array fields

  • x.y.z...
  • x.y.z[i]...
GET /foo?a.b=bar
GET /foo?x.y_lt=100
GET /foo?arr[0]=bar

Embed

GET /posts?_embed=comments
GET /comments?_embed=post

Delete

DELETE /posts/1
DELETE /posts/1?_dependent=comments

Screenshots

Home

Home