A production-ready RESTful API built with Node.js, Express, and Sequelize ORM, featuring authentication, authorization, session handling, and configurable settings.
- 👤 User Management: CRUD, upsert, bulk upsert, pagination & filtering
- 🔑 Authentication: JWT-based login, token verification, unblock users
- 📊 Session Management: Track and manage active sessions
- 📋 Menu Management: CRUD + filter menus
- ⚙️ Configuration Management: Manage app settings (e.g., max login attempts)
- 🛡️ Security: Middleware-based auth & error handling
- 📖 Swagger UI for live API documentation
project/
│
├─ app.js # Entry point
├─ package.json
├─ .env
│
└─ src/
├─ api-docs/ # Swagger spec (swagger.yaml)
├─ config/ # DB config
├─ constants/ # Enums, messages
├─ controllers/ # Request handlers
├─ middlewares/ # Auth & error handlers
├─ models/ # Sequelize models
├─ repository/ # Data access layer
├─ routes/ # Express routes
├─ services/ # Business logic
└─ utils/ # Helpers (JWT, hash, errors, responses)
GET /users→ Get all usersGET /users/:id→ Get user by IDPOST /users→ Create userPUT /users/:id→ Update userDELETE /users/:id→ Delete userPUT /users/upsert→ Upsert userPUT /users/bulk-upsert→ Bulk upsert usersPOST /users/filter→ Paginated & filtered list
GET /sessions→ Get all sessionsGET /sessions/:id→ Get session by IDPOST /sessions→ Create sessionPUT /sessions/:id→ Update sessionDELETE /sessions/:id→ Delete session
GET /menus→ Get all menusGET /menus/:id→ Get menu by IDPOST /menus→ Create menuPUT /menus/:id→ Update menuDELETE /menus/:id→ Delete menuPOST /menus/filter→ Filter menus
PUT /config/max-login-attempts→ Set max login attempts
POST /auth/login→ LoginPOST /auth/unblock→ Unblock userGET /auth/verify→ Verify token
This project includes Swagger UI to explore and test APIs.
👉 Open in browser:
[http://localhost:3000/api-docs](http://localhost:3000/api-docs)
- Login via
POST /auth/login - Copy JWT token
- Click Authorize in Swagger UI
- Enter token as:
Bearer \<your_token>
Now you can access secured routes 🎉
# Clone the repository
git clone https://github.com/yourusername/user-api.git
# Install dependencies
npm install
# Run in dev mode
node app.jsCreate a .env file:
PORT=3000
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=yourpassword
DB_NAME=yourdbname
JWT_SECRET=your_jwt_secret
- Node.js & Express.js
- Sequelize ORM
- PostgreSQL
- JWT Authentication
- Swagger (OpenAPI)
- dotenv for config
- Fork the repo
- Create a branch
feature/your-feature - Commit changes
- Push branch
- Create Pull Request
Licensed under the MIT License.
- Express & Sequelize communities 🙌
- Swagger for API docs