This project is a secure REST API built with Node.js and Express for managing student records. It implements JWT (JSON Web Token) authentication to protect endpoints and ensure that only authorized users can access and manipulate student data. The API follows RESTful principles, providing a clean and intuitive interface for CRUD (Create, Read, Update, Delete) operations on student resources.
Runtime & Core Dependencies:
- Node.js (v18 or higher recommended)
- Express.js - Web framework for routing and middleware
- JSON Web Tokens (jsonwebtoken) - For authentication
- bcryptjs - Password hashing and verification
- cors - Cross-Origin Resource Sharing support
- dotenv - Environment variable management
- SQLite (lightweight option for development/small deployments)
- nodemon (optional) - Auto-restart server during development
- Git - Version control
- Render account (free tier available)
- Environment variables configured on Render dashboard
Environment Variables Required:
PORT=3000
JWT_SECRET=your-super-secret-key-change-this
JWT_EXPIRES_IN=24h
DATABASE_URL="./data/db.sqlite"
API_KEY=your-api-key-for-endpoint-protection
NODE_ENV=productionAPI/
├── node_modules/ # Project dependencies (auto-generated, not in version control)
├── src/ # Source code directory
│ ├── controllers/ # Business logic and request handlers
│ │ └── authController.js # Handles authentication logic
│ │
│ ├── middleware/ # Custom middleware functions
│ │ └── auth.js # JWT verification middleware
│ │ └── validate.js # Input validation middleware
│ │ └── errorHandler.js # Global error handling
│ │
│ ├── models/ # Data models and schemas
│ │ └── User.js # User authentication model
│ │
│ ├── routes/ # API route definitions
│ │ └── studentRoutes.js # Student-related endpoints
│ │ └── authRoutes.js # Authentication endpoints
│ │
│ ├── services/ # Business logic and database operations
│ │ └── authService.js # Authentication services
│ │
│ └── index.js # Main application entry point
│
├── .env # Environment variables (NOT in version control)
├── .gitignore # Specifies files to ignore in version control
├── package-lock.json # Locked versions of dependencies
├── package.json # Project metadata and dependencies
└── README.md # Project documentationBefore starting the project, create a JavaScript file in an empty folder and open it with VS Code. In the terminal, run Node followed by the file name to launch it. If you don't have Node, you can install it by following this link: