This is a Node.js-based Attendance API with MySQL, Redis, and Elasticsearch support.
- Node.js (v18 or later)
- Docker (if using Docker setup)
- Make (if using Makefile setup)
- Postman (for API testing)
-
Clone the repository:
git clone https://github.com/anasabdur/attendance-api.git cd attendance-api
-
Create a
.env
file: (modify as needed)cp .env.example .env
-
Start the services:
docker-compose up -d
-
Generate JWT Secret
docker exec -it attendance-api-app node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
- Copy the generated key.
- Open the
.env
file in the project root directory. - Find the
JWT_SECRET
variable and paste the copied key like this:
JWT_SECRET=your_generated_secret_here
-
Access Bash:
docker exec -it attendance-api-app bash
-
Access the MySQL CLI:
docker exec -it attendance-api-mysql mysql -u default -psecret
-
Stop the services:
docker-compose down
-
Clone the repository:
git clone https://github.com/anasabdur/attendance-api.git cd attendance-api
-
Create a
.env
file:cp .env.example .env
-
Start the services:
make start-build
if already built, just run:
make start
-
Generate JWT Secret
docker exec -it attendance-api-app node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
- Copy the generated key.
- Open the
.env
file in the project root directory. - Find the
JWT_SECRET
variable and paste the copied key like this:
JWT_SECRET=your_generated_secret_here
-
Access Bash:
make bash
-
Access the MySQL CLI:
make mysql-cli
-
Stop the services:
make stop
To test the API using Postman, follow these steps:
-
Check the Postman Collection and Environment:
- Navigate to the
./postman
directory inside the project. - Locate the
attendance-api.postman_collection.json
file. - Locate the
attendance.postman_environment.json
file.
- Navigate to the
-
Import into Postman:
- Open Postman.
- Click on the Import button.
- Select Upload Files.
- Choose both
./postman/attendance-api.postman_collection.json
and./postman/attendance.postman_environment.json
. - Click Import.
-
Select the Environment:
- Click on the Environment dropdown in the top-right corner of Postman.
- Select Attendance API Environment.
-
Run API Requests:
- Open the Collections tab in Postman.
- Find Attendance API.
- Select any endpoint and click Send to test the API.
- API:
http://localhost:3000
- MySQL:
localhost:3306
(user:default
, password:secret
)