This repository contains a Node.js application using Express and PostgreSQL to manage students, courses, and their related data, including scores and modules. It provides a set of API endpoints to perform CRUD operations and various other functionalities.
Ensure you have the following installed:
- Node.js
- PostgreSQL
- npm (Node Package Manager)
- URL:
/students
- Method:
GET
- Description: Retrieves all students from the database.
- Response: JSON array of student objects.
- URL:
/students
- Method:
POST
- Description: Inserts a new student into the database.
- Request Body: JSON object representing the new student.
- Response: JSON object confirming the insertion status.
- URL:
/students
- Method:
PUT
- Description: Updates a student's last name in the database.
- Request Body: JSON object containing updated student details.
- Response: JSON object confirming the update status.
- URL:
/students/:id
- Method:
DELETE
- Description: Deletes a student from the database by ID.
- Path Parameter:
id
: ID of the student to delete.
- Response: JSON object confirming the deletion status.
- URL:
/courses
- Method:
GET
- Description: Retrieves all courses from the database.
- Response: JSON array of course objects.
- URL:
/courses
- Method:
POST
- Description: Inserts a new course into the database.
- Request Body: JSON object representing the new course.
- Response: JSON object confirming the insertion status.
- URL:
/courses/:id
- Method:
PUT
- Description: Updates a course in the database by ID.
- Path Parameter:
id
: ID of the course to update.
- Request Body: JSON object containing updated course details.
- Response: JSON object confirming the update status.
- URL:
/courses/:id
- Method:
DELETE
- Description: Deletes a course from the database by ID.
- Path Parameter:
id
: ID of the course to delete.
- Response: JSON object confirming the deletion status.
- URL:
/studentcourse
- Method:
GET
- Description: Retrieves data joining students and courses.
- Response: JSON array of student-course pairs.
- URL:
/modules
- Method:
GET
- Description: Retrieves all modules from the database.
- Response: JSON array of module objects.
- URL:
/modules
- Method:
POST
- Description: Inserts a new module into the database.
- Request Body: JSON object representing the new module.
- Response: JSON object confirming the insertion status.
- URL:
/modules/:id
- Method:
PUT
- Description: Updates a module in the database by ID.
- Path Parameter:
id
: ID of the module to update.
- Request Body: JSON object containing updated module details.
- Response: JSON object confirming the update status.
- URL:
/modules/:id
- Method:
DELETE
- Description: Deletes a module from the database by ID.
- Path Parameter:
id
: ID of the module to delete.
- Response: JSON object confirming the deletion status.
- URL:
/studentscore
- Method:
GET
- Description: Calculates and returns total scores for all students across all modules.
- Response: JSON array of student scores.
- URL:
/reset-password
- Method:
POST
- Description: Resets a student's password in the database.
- Request Body: JSON object containing student ID and new password.
- Response: JSON object confirming the password reset status.
- URL:
/update-score
- Method:
POST
- Description: Updates a student's score for a specific module in the database.
- Request Body: JSON object containing student ID, module ID, and new score.
- Response: JSON object confirming the score update status.
- URL:
/students/total-score/:id
- Method:
GET
- Description: Calculates and returns the total score for all modules of a specific student.
- Path Parameter:
id
: ID of the student.
- Response: JSON object with the total score.
- URL:
/students/module/:id
- Method:
GET
- Description: Retrieves module scores for a specific student from the database.
- Path Parameter:
id
: ID of the student.
- Response: JSON array of module scores.
This documentation provides an overview of the available API endpoints for managing students, courses, modules, and related functionalities using Node.js, Express, and PostgreSQL. Adjust the descriptions and examples as per your specific API implementation.
- Clone the repository:
git clone https://github.com/KislayKashyap-hub/Node.js-Express-PostgreSQL-APIs.git
- Clone the repository:
git clone https://github.com/your-username/your-repository.git
- Install dependencies:
npm install
- Set up your PostgreSQL database and configure
.env
file with database credentials. - Run the application:
npm start
- Use the provided API endpoints to manage students, courses, modules, and scores.
- Restore .tar backup file to get all database.
This project is licensed under the MIT License - see the LICENSE file for details.