Case study
Node.js Auth API
Backend authentication/security project.
Overview
A from-scratch JWT authentication and authorization API — the access/refresh token, password hashing and role-based access control layer that most "add auth" tutorials skip over.
Architecture
Express 5 with Mongoose for the data layer, bcrypt for password hashing, jsonwebtoken for access and refresh tokens. Auth is enforced through composable middleware — protect for authentication, allowRoles for role checks — so a route can require login, a specific role, or several roles at once.
What it does
Register, login, get-current-user, refresh-token, and both single-device and all-device logout. Role-gated admin routes (list/delete users), plus multi-role and single-role route guards built on the same middleware.