Experiment - 6
Aim
Implement authentication and user roles with JWT
INPUT AND OUTPUT :
Backend :
A] Code :
a) Server Setup (server.js)
● Show how Express is configured, CORS setup, middleware, and database connection.
● Include .env usage with process.env.MONGO_URI to highlight security.
b) Authentication Route (routes/auth.js)
● Include login and registration endpoints, showing JWT issuance.
c) Protected Task Routes (routes/task.js)
● Show how authorization middleware is used for secure endpoints.
d) Task Model (models/task.js)
● Show Mongoose schema, especially required fields like title, priority, category, userName.
D] .env
Postman API request + response snippet
Why it’s necessary
1. Shows that your backend works:
A proof that your RESTful APIs are functional. Screenshots from Postman act as evidence.
2. Captures API input/output:
You can show the request payload (JSON sent to API) and the response (JSON returned). This
is critical for documentation.
3. Validates security features:
Testing with JWT authentication shows that only authorized users can perform actions like
creating or deleting tasks.
4. Required for report completeness:
Most experiments require code + output images. Without testing APIs, your report will be
incomplete.
30% extra :
Task enhancements: categories, priority levels, checklists, and assignments
Analytics endpoints for task statistics
Frontend integration: React + Vite with JWT token handling
Real-time updates reflected on the UI
React-Redux for state management
Environment-based config using .env
Frontend
Creation of tasks :
Delete :
Editing tasks :
Update task status :