This API is used to manage employee check-ins and check-outs at ABC School, tracking attendance and calculating the duration of each work period.
- Create new employees
- Retrieve a list of employees with optional filters by date of creation
- Check-in employees to track attendance start
- Check-out employees to track attendance end and calculate the duration
Additionally, the API is fully documented using OpenAPI and Swagger UI. This documentation provides a clear and interactive way of understanding the available endpoints, their required parameters, and the structure of the expected responses.
To access the interactive API documentation:
- Start the API server on your local machine.
- Open a web browser and navigate to
http://localhost:3000/api
. - The Swagger UI will be displayed, allowing you to test endpoints directly through the browser.
By using Swagger UI, you can:
- Explore the list of available endpoints.
- Send test requests to the API and view the responses.
- Review the request models and response schemas.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Nodejs version v16.19.0 or higher (we recommend using nvm).
- Git.
- Docker (optional, for running the database in a container).
- Nestjs.
Clone the repository:
git clone https://github.com/abderrahmaneMustapha/abc-school-attendance.git
cd abc-school-attendance
Install dependencies:
npm install
To facilitate a consistent development environment and simplify the production deployment process, this project is configured to run with Docker.
For local development, we run only the database service in Docker, while the application runs on the host machine.
Create a .env.dev
file with the necessary environment variables:
NODE_ENV=development
DB_TYPE=postgres
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=ABC-test-user
DB_PASSWORD=test123
DB_DATABASE=ABC-test
TYPEORM_SYNCHRONIZE=true
TYPEORM_LOGGING=true
TYPEORM_AUTO_LOAD_ENTITIES=true
POSTGRES_DB=dev-db
POSTGRES_USER=dev-user
POSTGRES_PASSWORD=dev-pass
Start the database with Docker Compose:
docker-compose -f docker-compose.dev.yml up -d
Start the application on your local machine with:
npm run start:dev
In production, both the application and the database run in Docker containers.
Create a .env.prod
file with the production environment variables:
NODE_ENV=production
DB_TYPE=postgres
DB_HOST=db
DB_PORT=5432
DB_USERNAME=ABC-test-user
DB_PASSWORD=test123
DB_DATABASE=ABC-test
TYPEORM_SYNCHRONIZE=false
TYPEORM_LOGGING=true
TYPEORM_AUTO_LOAD_ENTITIES=true
POSTGRES_DB=ABC-test
POSTGRES_USER=ABC-test-user
POSTGRES_PASSWORD=test123
Build and start the production containers with Docker Compose:
docker-compose up --build -d
Configure your database connection settings in .env.dev
for developement and
.env.prod
or directly in the TypeORM configuration in src/app.module.ts
.
Run the unit tests for this system using:
npm run test
For integration tests you first need to prepare a new .env.test
file:
NODE_ENV=test
DB_TYPE=postgres
DB_HOST=localhost
DB_PORT=5433
DB_USERNAME=test-user
DB_PASSWORD=test123
DB_DATABASE=test-db
TYPEORM_SYNCHRONIZE=true
TYPEORM_LOGGING=true
TYPEORM_AUTO_LOAD_ENTITIES=true
POSTGRES_DB=test-db
POSTGRES_USER=test-user
POSTGRES_PASSWORD=test123
After this you build and start the production containers with Docker Compose:
docker-compose -f docker-compose.spec.yml up -d
And then you can run your integration tests by doing:
npm run test:e2e
- Abderahmane Toumi - abderrahmaneMustapha