Skip to content

anasark/attendance-api

Repository files navigation

Attendance API

This is a Node.js-based Attendance API with MySQL, Redis, and Elasticsearch support.

Prerequisites


Setup with Docker

  1. Clone the repository:

    git clone https://github.com/anasabdur/attendance-api.git
    cd attendance-api
  2. Create a .env file: (modify as needed)

    cp .env.example .env
  3. Start the services:

    docker-compose up -d
  4. 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
  5. Access Bash:

    docker exec -it attendance-api-app bash
  6. Access the MySQL CLI:

    docker exec -it attendance-api-mysql mysql -u default -psecret
  7. Stop the services:

    docker-compose down

Setup with Makefile (if supported)

  1. Clone the repository:

    git clone https://github.com/anasabdur/attendance-api.git
    cd attendance-api
  2. Create a .env file:

    cp .env.example .env
  3. Start the services:

    make start-build

    if already built, just run:

    make start
  4. 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
  5. Access Bash:

    make bash
  6. Access the MySQL CLI:

    make mysql-cli
  7. Stop the services:

    make stop

Import Postman Collection and Environment

To test the API using Postman, follow these steps:

  1. 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.
  2. 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.
  3. Select the Environment:

    • Click on the Environment dropdown in the top-right corner of Postman.
    • Select Attendance API Environment.
  4. Run API Requests:

    • Open the Collections tab in Postman.
    • Find Attendance API.
    • Select any endpoint and click Send to test the API.

Access the application

  • API: http://localhost:3000
  • MySQL: localhost:3306 (user: default, password: secret)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published