A Task Manager REST API with Authentication, Role-Based Access, Analytics, Logging, and File-Based JSON Storage — built entirely with Node.js core modules (http, fs, crypto, events, url, path) and no external frameworks.
✅ Authentication – Register, login, hashed passwords, token-based auth.
✅ Role-Based Access – User and Admin roles with different permissions.
✅ Task Management – Create, update, delete, and view tasks.
✅ Analytics – Track requests, errors, and response times in analytics.json.
✅ Logging – Store request and error logs in /logs.
✅ File-Based JSON Storage – All data (users, tasks, analytics) stored in JSON files.
✅ Error Handling – Global error handler and middleware-based validation.
✅ Pure Node.js – Built with only core modules, no frameworks.
- controllers/ – Request handlers for users, tasks, analytics, and health.
- data/ – JSON file storage (
users.json,tasks.json,analytics.json). - middleware/ – Auth, role checks, logging, error handling.
- routes/ – API route definitions.
- types/ – TypeScript type definitions.
- utils/ – Helper utilities for tokens, password hashing, JSON parsing, validation.
- server.ts – Entry point.
- config.json – Configurable server settings.
- Register – Create account → password hashed → saved to
users.json. - Login – Verify credentials → return token.
- Token Validation – Protect routes with
Authorization: Bearer <token>. - Role-Based Access – Admins can manage all; Users can only manage their own tasks.
- Admin
- Manage all users and tasks.
- Access analytics and system endpoints.
- User
- Manage only their own tasks.
- No access to global analytics or system logs.
Analytics are stored in analytics.json.
Register
POST /register
Content-Type: application/json
{
"username": "john",
"password": "Secure@123",
"role": "user"
}login
POST /login
Content-Type: application/json
{
"username": "john",
"password": "Secure@123"
}getCurrentUser
GET /me
Authorization: Bearer <token>
Content-Type: application/json
createTask
POST /tasks
Authorization: Bearer <token>
Content-Type: application/json
{
"title": "Finish API",
"description": "Write controllers and test with Postman",
}getAllTasks
GET /tasks
Authorization: Bearer <token>
Content-Type: application/json
getTaskById
GET /tasks/:id
Authorization: Bearer <token>
Content-Type: application/json
updateTask
PUT /tasks/:id
Authorization: Bearer <token>
Content-Type: application/json
{
"title": "Finish API",
"description": "Write controllers and test with Postman",
"status": "done",
"priority": "high"
}
deleteTask
DELETE /tasks/:id
Authorization: Bearer <token>
Content-Type: application/json
- Node.js (Core Modules Only) – Built entirely without frameworks like Express.
- TypeScript – Strong typing, cleaner code, and better scalability.
- JSON File Storage – Lightweight, file-based storage instead of a database.









