Endpoint: /auth/login
Method: POST
Description: Authenticates a user and returns a JWT token note: only employees with HR group can access the rest of api endpoints and you must include auth headers and use Bearer auth in rest of api endpoints.
Request Body:
{
"email": "string",
"password": "string"
}
Response:
- 200 OK:
{ "access_token": "string" }
- 401 Unauthorized: Invalid credentials.
Endpoint: /auth/register
Method: POST
Description: Registers a new user.
Request Body:
{
"name": "string",
"password": "string",
"email": "string",
"group": "string",
}
Response:
- 201 Created:
{ "message": "User registered successfully" }
- 400 Bad Request: Validation errors.
Endpoint: /employees
Method: POST
Description: Adds a new employee to the system .
Request Body:
{
"name": "string",
"email": "string",
"group": "string"
}
Response:
- 201 Created:
{ "id": "string", "name": "string", "email": "string", "role": "string" }
- 400 Bad Request: Validation errors.
Endpoint: /employees
Method: GET
Description: Retrieves a list of all employees.
Response:
- 200 OK:
[ { "id": "string", "name": "string", "email": "string", "group": "string" } ]
Endpoint: /employees/:id
Method: GET
Description: Retrieves details of a specific employee by ID.
Response:
- 200 OK:
{ "id": "string", "name": "string", "email": "string", "group": "string" }
- 404 Not Found: Employee not found.
Endpoint: /employees/:id
Method: PUT
Description: Updates an employee's details.
Request Body:
{
"name": "string",
"email": "string",
"group": "string"
}
Response:
- 200 OK:
{ "id": "string", "name": "string", "email": "string", "group": "string" }
- 404 Not Found: Employee not found.
Endpoint: /employees/:id
Method: DELETE
Description: Deletes an employee by ID.
Response:
- 200 OK:
{ "message": "Employee deleted successfully" }
- 404 Not Found: Employee not found.
Endpoint: /attendance
Method: POST
Description: Records attendance for an employee.
Request Body:
{
"employeeId": "string",
"date": "YYYY-MM-DD",
"status": "Present/Absent" // ignore this
}
Response:
- 201 Created:
{ "id": "string", "employeeId": "string", "date": "YYYY-MM-DD", "status": "Present/Absent" // planned so ignore it }
- 400 Bad Request: Validation errors.
Endpoint: /attendance
Method: GET
Description: Retrieves all attendance records.
Response:
- 200 OK:
[ { "id": "string", "employeeId": "string", "date": "YYYY-MM-DD", "status": "Present/Absent" // planned } ]
Endpoint: /attendance/employee/:id
Method: GET
Description: Retrieves attendance records for a specific employee.
Response:
- 200 OK:
[ { "id": "string", "employeeId": "string", "date": "YYYY-MM-DD", "status": "Present/Absent" // planned } ]
- 404 Not Found: Employee not found.
Base URL: http://localhost:3006
Status: Running