This project focuses on importing a dump file containing employee, department, salary, donation, and rate data into a PostgreSQL database. It also includes the implementation of an API endpoint that calculates rewards for employees who have donated more than $100 to charity.
- Node+PostgreSQL
- .env: Environment variables configuration file.
- package.json: Node.js package configuration file.
- src/
- app.ts: Main application file.
- config/
- database.ts: Database connection configuration file.
- databaseSetup.ts: Database initialization setup.
- controllers/
- calcuationController.ts: Controller for calculating donation rewards.
- employeeController.ts: Controller for importing dump data into the database.
- data/
- dump.txt: Sample dump file containing employee, department, salary, donation, and rate data.
- index.ts: Main entry point of the application.
- models/
- department.ts: Department model definition.
- donation.ts: Donation model definition.
- employee.ts: Employee model definition.
- index.ts: Index file for exporting all models.
- rates.ts: Rate model definition.
- salary.ts: Salary model definition.
- routes/
- index.ts: Defines API routes.
- services/
- parseText.ts: Service for parsing dump file text.
- Clone the repository.
- Install dependencies using
npm install
. - Set up the PostgreSQL database and configure the connection in the
.env
file. - Run the database initialization script using
npm run db:init
. - Start the application using
npm start
.
- GET /: Import dump data into the database.
- GET /calculate-reward: Calculate rewards for employees who donated more than $100 to charity.
- Import dump data by making a GET request to
http://localhost:3000/
. - Calculate rewards by making a GET request to
http://localhost:3000/calculate-reward
. - Ensure the dump file is correctly formatted with the specified hierarchy and indentation.
- Node.js
- Express
- Sequelize
- PostgreSQL
- Postman