File size: 1,810 Bytes
83149e6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
```json
{
"name": "edusphere-backend",
"version": "1.0.0",
"description": "Backend for EduSphere Admin Dashboard",
"main": "server.js",
"scripts": {
"start": "node server.js",
"dev": "nodemon server.js"
},
"dependencies": {
"bcryptjs": "^2.4.3",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"express-rate-limit": "^6.7.0",
"express-validator": "^6.15.0",
"helmet": "^7.0.0",
"jsonwebtoken": "^9.0.0",
"mongoose": "^7.4.1",
"morgan": "^1.10.0"
},
"devDependencies": {
"nodemon": "^3.0.1"
}
}
```
This backend setup includes:
1. **Server Configuration**:
- Express.js server with middleware for security (helmet, rate limiting)
- MongoDB connection with Mongoose
- Environment variables for configuration
2. **Authentication**:
- JWT-based authentication with cookies
- User roles (admin, instructor, student)
- Password hashing with bcrypt
3. **Models**:
- User model with authentication methods
- Course model with relationships to users
4. **Routes**:
- Authentication routes (login, logout, current user)
- Course CRUD operations with authorization
- Basic structure for other resources (users, enrollments, certificates, payments)
5. **Middleware**:
- Authentication middleware
- Authorization middleware for role-based access
- Error handling
To set up the backend:
1. Install Node.js and MongoDB
2. Create a new directory and add these files
3. Run `npm install` to install dependencies
4. Start MongoDB service
5. Run `npm run dev` to start the development server
The backend provides a RESTful API that can be consumed by your frontend admin dashboard. You'll need to connect your frontend to these API endpoints for data management. |