This project is a RESTful API for managing payroll and attendance using Node.js, Express.js, MySQL, and JWT for authentication. It includes features for managing employees, attendance records, and payroll information.
- Node.js
- MySQL
- VSCode with REST Client extension (for testing API)
Clone this repository to your local machine using Git Bash or any other terminal:
git clone https://github.com/abdisetiakawan/restAPI-ManagePayrollandAttendance
Navigate into the project directory and run the following command to install the required packages:
npm install
Create a MySQL database and configure the connection in the .env
file. Rename the .env.example
file to .env
and update it with your database credentials:
DB_HOST=localhost
DB_USER=root
DB_PASS=your_password
DB_NAME=managepayrollattendance
# JWT Configuration
ACCESS_TOKEN_SECRET=your_access_token_secret
REFRESH_TOKEN_SECRET=your_refresh_token_secret
Ensure your MySQL database is up and running, then run the following command to apply database migrations (if any):
npm run migrate
Run the following command to start the server:
npm start
The server will be running on http://localhost:3000
.
To test the API, follow these steps:
- Open the
./testing/test.http
file in VSCode. - Install the REST Client extension in VSCode if you haven’t already.
- Click on the
Send Request
button next to each API request in thetest.http
file to test the corresponding endpoints.
The API includes endpoints for managing employees, attendance, and payroll. You can find the full list of available routes in the routes
directory.
DB_HOST
: Hostname for your MySQL database.DB_USER
: Your MySQL username.DB_PASS
: Your MySQL password.DB_NAME
: The database name.ACCESS_TOKEN_SECRET
: Secret for generating JWT access tokens.REFRESH_TOKEN_SECRET
: Secret for generating JWT refresh tokens.
This project is licensed under the MIT License. See the LICENSE file for details.