How berrouane-wafa/titanium-api works
This is a small Express/MySQL product API. A client reaches the server’s product routes, which validate requests before dispatching to controllers; controllers call the product service, which queries MySQL and returns results for HTTP responses. The server also serves the public directory and formats forwarded errors. Source excerpts establish the main request and database flow; no README capabilities were provided, and the public page’s behavior is not shown.
Main entry points: product.routes.js Product routes · product.controller.js Product controller · server.js Express server · product.service.js Product service
Components 13
HTTP application
- Express server
server.js - Static assets
public - Product routes
routes/product.routes.js - ID validation
middlewares/validateId.js - Create validation
middlewares/validationProduct.js - Update validation
middlewares/validateProductUpdate.js
Product operations
- Product controller
controllers/product.controller.js - Async wrapper
middlewares/asyncHandler.js - HTTP errors
errors/AppError.js
Persistence
- Product service
services/product.service.js - DB connection
config/database.js - MySQL products
Other components
- API client
Connections 13
- API client → Express server: sends requests
- Express server → Product routes: mounts at
server.js - Express server → Static assets: serves files
server.js - Product routes → ID validation: validates IDs
routes/product.routes.js - Product routes → Create validation: validates creates
routes/product.routes.js - Product routes → Update validation: validates updates
routes/product.routes.js - Product routes → Product controller: dispatches requests
routes/product.routes.js - Product controller → Product service: calls operations
controllers/product.controller.js - Product controller → Async wrapper: wraps handlers
controllers/product.controller.js - Product controller → HTTP errors: raises errors
controllers/product.controller.js - Product service → DB connection: awaits connection
services/product.service.js - DB connection → MySQL products: opens connection
config/database.js - Product service → MySQL products: queries products
services/product.service.js