How andresdelossantos99/apirest-libros works
ApiRest-Libros is an Express REST API for managing authors and their book posts. Clients send requests through the server and mounted API routes; route middleware validates input before controllers delegate CRUD and author-post lookups to services, which query PostgreSQL. The API also provides health status, filtering and pagination for posts, and centralized error responses. The README describes an earlier in-memory mock alongside the current PostgreSQL-backed behavior; the mock is shown as a separate, unverified option because the sampled runtime does not wire it in.
Main entry points: app.js Express app · db.js PostgreSQL access · indexRoutes.js API route index · authorRoutes.js Author routes
Components 15
API runtime
- Server startup
server.js - Express app
app.js - API route index
source/routes/indexRoutes.js
Author resources
- Author routes
source/routes/authorRoutes.js - Request validation
source/middlewares/validators.js - Author controller
source/controllers/authorController.js - Author service
source/services/authorService.js
Post resources
- Post routes
source/routes/postRoutes.js - Post controller
source/controllers/postController.js - Post service
source/services/postService.js
Persistence and errors
- Error handler
source/middlewares/errorHandler.js - PostgreSQL access
source/dbConfig/db.js - PostgreSQL
- In-memory mock
source/services/dbMock.js
Other components
- API client
Connections 18
- API client → Express app: sends requests
README.md - Server startup → Express app: starts
server.js - Server startup → PostgreSQL access: tests connection
server.js - Express app → API route index: mounts API
app.js - Express app → Error handler: registers errors
app.js - API route index → Author routes: mounts authors
source/routes/indexRoutes.js - API route index → Post routes: mounts posts
source/routes/indexRoutes.js - Author routes → Request validation: validates requests
source/routes/authorRoutes.js - Author routes → Author controller: dispatches
source/routes/authorRoutes.js - Author controller → Author service: calls
source/controllers/authorController.js - Author controller → Post service: gets author posts
source/controllers/authorController.js - Post routes → Request validation: validates requests
source/routes/postRoutes.js - Post routes → Post controller: dispatches
source/routes/postRoutes.js - Post controller → Post service: calls
source/controllers/postController.js - Author service → PostgreSQL access: queries
source/services/authorService.js - Post service → PostgreSQL access: queries
source/services/postService.js - PostgreSQL access → PostgreSQL: executes SQL
source/dbConfig/db.js - In-memory mock → Author service: optional alternative