RESTful API built with TypeScript, Express, and Mongoose, following a clean MVC architecture.
Includes authentication, authorization, and integration testing using Vitest and Supertest.
- ๐งฉ Question Management โ Create, edit, delete, and retrieve questions.
- ๐ Collections System โ Group questions into collections.
- ๐ค User Authentication โ Register, login, and manage users securely.
- ๏ฟฝ๏ฟฝ๏ฟฝ JWT Tokens โ Stateless authentication for users.
- ๐ก๏ธ Role-Based Permissions โ Admin and standard user access control.
- ๐งช Integration Testing โ Powered by Vitest, Supertest, and mongodb-memory-server.
- โ๏ธ Clean Architecture (MVC + OOP) โ Modular and scalable project structure.
- ๐ API Documentation โ Auto-generated using Swagger UI.
- ๐ชต Structured Logging โ Using Pino and Morgan for detailed request logs.
- ๐งฐ Validation & Security โ Helmet, Rate Limiting, HPP, Express Validator, and CORS.
| Category | Libraries |
|---|---|
| Framework | Express 5 |
| Language | TypeScript |
| Database | Mongoose |
| Auth | JWT, bcrypt |
| Security | Helmet, CORS, Rate Limiter, HPP |
| Logging | Pino, Morgan |
| Testing | Vitest, Supertest, MongoDB Memory Server |
| Docs | Swagger JSDoc + Swagger UI |
| DI | tsyringe |
src/
โโโ main.ts ๐๏ธ
โโโ configs/ ๐
โโโ controllers/ ๐ฎ
โโโ databases/ ๐๏ธ
โ โโโ mongoose.ts ๐งบ
โโโ dtos/
โโโ interfaces/
โโโ middlewares/ โ๏ธ
โโโ models/ ๐๏ธ
โโโ routes/ ๐ฃ๏ธ
โโโ utils/ ๐ ๏ธ
โโโ constants.ts
โโโ .env.test ๐งช
โโโ .env.production ๐
โโโ .env.example
โโโ .env ๐๏ธ
-
Controllers โ Handle HTTP requests/responses.
-
Services / Modules โ Business logic, injected via tsyringe.
-
Models โ Mongoose schemas.
-
DTOs & Interfaces โ Define TypeScript types and contracts.
-
Middlewares โ Validation, Auth, Logging, Error handling.
-
Utils โ Helpers (e.g., token generation, formatting).
Follows Clean Architecture principles with OOP and dependency injection.
| Command | Description |
|---|---|
npm run dev |
Run development server with live reload |
npm run build |
Compile TypeScript to dist |
npm start |
Run compiled production server |
npm test |
Run integration tests |
npm run test:watch |
Run tests in watch mode |
npm run prettier |
Format codebase |
npm run clean |
Remove compiled files (dist/) |
- Run tests once
npm run test
- Run tests in watch mode
npm run test:watch
Swagger UI is available at: http://localhost:8080/api/docs
Automatically generated from JSDoc annotations using:
-
swagger-jsdoc
-
swagger-ui-express
-
User registers (/api/v1/auth/register)
-
User logs in and receives JWT token
-
Token must be included in headers:
- Authorization: Bearer
-
Middleware verifies token and applies role-based access (e.g. EDIT_COLLECTION, DELETE_QUESTION)
Contributions, issues, and feature requests are welcome!
Feel free to open a pull request or issue.
- Fork the repo
- Create a new branch (
feature/my-feature) - Commit your changes
- Push to your branch
- Open a Pull Request ๐
MIT ยฉ 2025 @Garkatron
