Skip to content

modulo-4-evaluacion-final-bpw-sprietoviciana created by GitHub Classroom

Notifications You must be signed in to change notification settings

Adalab/modulo-4-evaluacion-final-bpw-sprietoviciana

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Documentation: Vet Management

This document describes the endpoints for the Vet Management API built with Node.js, Express, and MySQL.

  1. Base URL
  2. Endpoints
  3. Database Connection
  4. Error Handling
  5. Development

Base URL

http://localhost:5001

Endpoints

1. Get All Clients

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]"
        }
      ]
    }

2. Get Client by ID

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

    {}

3. Create a New Client

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" }

4. Update an Existing Client

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" }

5. Delete a Client

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

Database Connection

This API connects to a MySQL database with the following configuration (defined in .env file):

  • USER_DB: Database username.
  • PASSWORD: Database password.
  • Database: vet.

Error Handling

  • 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.

Development

Install DB

Initialize DB using files inside bd folder.

Install Dependencies

npm install

Run the Server

npm run dev

About

modulo-4-evaluacion-final-bpw-sprietoviciana created by GitHub Classroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published