abdelhak002 / demo

A demo repository for My JSON Server (Alpha)

Home Page:https://my-json-server.typicode.com/abdelhak002/demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PFE Backend

This is the backend for the PFE project. It is a REST API that is used to store and retrieve data from the database. built with JSON Server.

Getting Started

Installation

Clone the repository

git clone <repo_url>

Install dependencies

npm install

Usage

Start the server

npm run dev

Start the server with fake data

npm run dev:fake

API

Endpoints

for all endpoints, the base url is http://localhost:3004, and the resources are stored in db.json file. All endpoints accepts the resources in plural form, and the response is in JSON format. Available resources are:

  • customers
  • products
  • suppliers
  • companies
  • orders

Returns a list of all resources

GET /api/<resources>

Returns a resource by id

GET /api/<resources>/:id

Creates a new resource

POST /api/<resources>

Updates a resource by id

PUT /api/<resources>/:id

Deletes a resource by id

DELETE /api/<resources>/:id

Authentication

Register

Data to use for register

{
  "name": "Admin",
  "email": "admin@gmail.com",
  "password": "admin"
}

Endpoint, returns a token that is used to authenticate the user

POST /api/register

Login

Data to use for login

{
  "email": "admin@gmail.com",
  "password": "admin"
}

Endpoint, returns a token that is used to authenticate the user

POST /api/login

Response example for login and register

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "id": 1,
    "name": "Admin",
    "email": "admin@gmail.com"
  }
}

About

A demo repository for My JSON Server (Alpha)

https://my-json-server.typicode.com/abdelhak002/demo

License:MIT License