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.
git clone <repo_url>
npm install
npm run dev
npm run dev:fake
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
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
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"
}
}