How bohdanzadoienko/nodejs-auth works
This repository is a Node.js/Express user-authentication and user-management API. Clients register or log in, then use the session cookie to access protected user listing and owner-restricted update/delete routes. Authentication checks and route handlers use the user persistence layer, which stores account and session data in MongoDB. The application also exposes Swagger UI documentation. The README gives no capability details; the graph follows the sampled routes and source, with the user-list handler represented by its tree path only.
Main entry points: db/users.ts User model and queries · router/users.ts User routes · src/index.ts Express server · router/index.ts Route assembly
Components 17
API application
- Express server
src/index.ts - Route assembly
src/router/index.ts - Swagger UI
src/index.ts - Swagger specification
src/swagger_output.json
Authentication
- Auth routes
src/router/authentication.ts - Register
src/controllers/auth/register.ts - Login
src/controllers/auth/login.ts - Credential helpers
src/helpers/index.ts
User management
- User routes
src/router/users.ts - Session check
src/middlewares/index.ts - Owner check
src/middlewares/index.ts - List users
src/controllers/users/getAllUsers.ts - Update user
src/controllers/users/updateUser.ts - Delete user
src/controllers/users/deleteUserById.ts
Persistence
- User model and queries
src/db/users.ts
Other components
- API client
- MongoDB
Connections 22
- API client → Express server: sends requests
- Express server → Route assembly: mounts routes
- Route assembly → Auth routes: registers routes
- Route assembly → User routes: registers routes
- Auth routes → Register: dispatches
- Auth routes → Login: dispatches
- Register → User model and queries: checks and creates
- Register → Credential helpers: generates salt
- Login → User model and queries: looks up and saves
- Login → Credential helpers: hashes credentials
- User routes → Session check: checks session
- User routes → Owner check: checks ownership
- User routes → List users: dispatches
- User routes → Update user: dispatches
- User routes → Delete user: dispatches
- Session check → User model and queries: looks up session
- Update user → User model and queries: reads and saves
- Delete user → User model and queries: deletes by id
- List users → User model and queries: unknown access
- User model and queries → MongoDB: queries and writes
- Express server → Swagger UI: serves docs
- Swagger UI → Swagger specification: loads specification