This README provides documentation for the Employee API, including its controllers and routes.
Preview of the api in Swagger UI
git clone [email protected]:sagiweizmann/EmployeeAPI.git
cd EmployeeAPI
npm install
cp .env.example .env
Run the server in development mode:
npm run dev
Build the server for production:
npm run build
Start the server in production mode:
npm run start
Run Unit Tests:
npm run test:unit
Run Unit Tests:
npm run test:integration
- Description: Retrieves a specific employee by their ID.
- Parameters:
req
: The request object.res
: The response object.next
: The next middleware function.
- Response:
- HTTP Status Code: 200 OK if successful, 404 Not Found if employee not found.
- JSON Response:
employee
: The retrieved employee object.
- Description: Retrieves all employees of a specific recipient.
- Parameters:
req
: The request object.res
: The response object.next
: The next middleware function.
- Response:
- HTTP Status Code: 200 OK if successful, 200 OK with an empty array if no employees found.
- JSON Response:
employees
: An array of employee objects.
- Description: Creates a new employee.
- Parameters:
req
: The request object containing the employee data.res
: The response object.next
: The next middleware function.
- Response:
- HTTP Status Code: 201 Created if successful.
- JSON Response:
employee
: The newly created employee object.
- Description: Deletes an employee by their ID.
- Parameters:
req
: The request object.res
: The response object.next
: The next middleware function.
- Response:
- HTTP Status Code: 200 OK if successful, 404 Not Found if employee not found.
- JSON Response:
message
: "Employee deleted."
- Description: Updates an employee by their ID with the fields provided in the request body.
- Parameters:
req
: The request object containing the employee data to update.res
: The response object.next
: The next middleware function.
- Response:
- HTTP Status Code: 200 OK if successful, 404 Not Found if employee not found.
- JSON Response:
employee
: The updated employee object.
- URL:
/v1/employee/:id
- Method: GET
- Description: Retrieves a specific employee by their ID.
- Parameters:
id
(URL Parameter): Employee ID.
- Response:
- HTTP Status Code: 200 OK if successful, 404 Not Found if employee not found.
- JSON Response:
employee
: The retrieved employee object.
- URL:
/v1/employee
- Method: GET
- Description: Retrieves all employees of a specific recipient.
- Parameters:
recipient
(Query Parameter): Employee recipient.
- Response:
- HTTP Status Code: 200 OK if successful, 200 OK with an empty array if no employees found.
- JSON Response:
employees
: An array of employee objects.
- URL:
/v1/employee
- Method: POST
- Description: Creates a new employee.
- Request Body:
recipient
: Employee recipient.employee
: Employee content.sender
: Employee sender.
- Response:
- HTTP Status Code: 201 Created if successful.
- JSON Response:
employee
: The newly created employee object.
- URL:
/v1/employee/:id
- Method: DELETE
- Description: Deletes an employee by their ID.
- Parameters:
id
(URL Parameter): Employee ID.
- Response:
- HTTP Status Code: 200 OK if successful, 404 Not Found if employee not found.
- JSON Response:
message
: "Employee deleted."
- URL:
/v1/employee/:id
- Method: PATCH
- Description: Updates an employee by their ID with the fields provided in the request body.
- Parameters:
id
(URL Parameter): Employee ID.
- Request Body: The fields of the employee to update.
- Response:
- HTTP Status Code: 200 OK if successful, 404 Not Found if employee not found.
- JSON Response:
employee
: The updated employee object.
This API provides basic CRUD (Create, Read, Update, Delete) operations for managing employee data. Ensure that you have appropriate error handling and validation in place as per your application's requirements.