This document describes the endpoints for the Vet Management API built with Node.js, Express, and MySQL.
http://localhost:5001
Retrieve a list of all clients.
Endpoint:
GET /clients
Response:
-
200 OK
{ "info": { "count": 2 }, "result": [ { "id": 1, "name": "John", "lastname": "Doe", "email": "[email protected]" }, { "id": 2, "name": "Jane", "lastname": "Smith", "email": "[email protected]" } ] }
Retrieve details of a single client by their ID.
Endpoint:
GET /clients/:id
Path Parameters:
id
(integer): ID of the client.
Responses:
-
200 OK
{ "id": 1, "name": "John", "lastname": "Doe", "email": "[email protected]" }
-
404 Not Found
{}
Add a new client to the database.
Endpoint:
POST /clients
Request Body (JSON):
{
"name": "John",
"lastname": "Doe",
"email": "[email protected]"
}
Responses:
-
201 Created
{ "id": 1, "name": "John", "lastname": "Doe", "email": "[email protected]" }
-
400 Bad Request (when a required field is missing)
{ "message": "`name` is required" }
Update the details of an existing client by their ID.
Endpoint:
PUT /clients/:id
Path Parameters:
id
(integer): ID of the client.
Request Body (JSON):
{
"name": "John",
"lastname": "Doe",
"email": "[email protected]"
}
Responses:
-
200 OK
{ "id": 1, "name": "John", "lastname": "Doe", "email": "[email protected]" }
-
400 Bad Request (when a required field is missing)
{ "message": "`lastname` is required" }
Remove a client from the database by their ID.
Endpoint:
DELETE /clients/:id
Path Parameters:
id
(integer): ID of the client.
Responses:
- 204 No Content
This API connects to a MySQL database with the following configuration (defined in .env
file):
USER_DB
: Database username.PASSWORD
: Database password.Database
:vet
.
- 400 Bad Request: Returned when required fields are missing.
- 404 Not Found: Returned when the specified client does not exist.
- 500 Internal Server Error: For unexpected server errors.
Initialize DB using files inside bd
folder.
npm install
npm run dev