A RESTful API built with Node.js for managing college information with MongoDB integration.
college-api-nodejs/
├── assets/ # Static assets (images, files, etc.)
├── models/ # MongoDB models
│ └── collegeModel.js # College schema definition
├── routes/ # API route handlers
│ └── collegeRoute.js # College CRUD endpoints
├── node_modules/ # Dependencies
├── .gitattributes # Git attributes configuration
├── .gitignore # Git ignore rules
├── config.js # Configuration settings
├── index.js # Main application entry point
├── package-lock.json # Locked dependencies
├── package.json # Project dependencies and scripts
└── README.md # Project documentation
- Node.js (v14 or higher)
- MongoDB (local or cloud instance)
- npm or yarn package manager
-
Clone the repository
git clone <repository-url> cd college-api-nodejs
-
Install dependencies
npm install
-
Configure environment variables
Create a
.envfile in the root directory:PORT=3000 MONGODB_URI=mongodb://localhost:27017/college-db NODE_ENV=development
-
Start the server
npm start
For development with auto-reload:
npm run dev
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/college |
Get all colleges |
| GET | /api/college/:id |
Get college by ID |
| POST | /api/college |
Create new college(s) |
| PUT | /api/college/:id |
Update college by ID |
| DELETE | /api/college/:id |
Delete college by ID |
Create a College
POST /api/college
Content-Type: application/json
{
"colleges": ["Indian Institute of Technology Delhi"]
}Get All Colleges
GET /api/collegeUpdate a College
PUT /api/college/:id
Content-Type: application/json
{
"oldCollegeName": "IIT Delhi",
"newCollegeName": "Indian Institute of Technology Delhi"
}Delete a College
DELETE /api/college/:id{
collegeName: String (required, unique),
collegeCode: String (auto-generated),
createdAt: Date (default: Date.now),
updatedAt: Date
}- Node.js - JavaScript runtime
- Express.js - Web framework
- MongoDB - NoSQL database
- Mongoose - MongoDB ODM
{
"start": "node index.js",
"dev": "nodemon index.js",
"test": "jest"
}The config.js file contains application configuration settings:
- Database connection settings
- Server port configuration
- Environment-specific settings
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License.
Your Name - GitHub Profile
- Ensure MongoDB is running before starting the server
- Check environment variables are properly configured
For support, email bipanshukm@gmail.com or open an issue in the repository.