How hescobarmx/api-miniblog works
This is an Express REST API for CRUD operations on authors and posts, with a one-to-many author–post relationship. Clients send requests through the server and resource routes; validation and controllers handle requests, services perform PostgreSQL queries, and JSON responses return to clients. The README documents the endpoints and Swagger UI. The graph follows the sampled wiring and README; SQL schema details and unsampled bootstrap behavior are represented only where documented or indicated by the source index.
Main entry points: server.js Express server · index.js Route aggregator · authors.routes.js Author routes · authors.controller.js Author controller
Components 18
API entry
- Startup
index.js - Express server
src/server.js - Route aggregator
src/routes/index.js - API specification
openapi.yaml
Author API
- Author routes
src/routes/authors.routes.js - Author validation
src/validations/authors.validation.js - Author controller
src/controllers/authors.controller.js - Author queries
src/services/authors.service.js
Post API
- Post routes
src/routes/posts.routes.js - Post validation
src/validations/posts.validation.js - Post controller
src/controllers/posts.controller.js - Post queries
src/services/posts.service.js
Shared runtime
- Async wrapper
src/middlewares/asyncHandler.js - Error handler
src/middlewares/errorhandler.js - Not-found handler
src/middlewares/notFoundHandler.js - PostgreSQL pool
src/config/db.js
Other components
- API client
- PostgreSQL
db/setup.sql
Connections 19
- API client → Express server: sends requests
README.md - Startup → Express server: starts
index.js - Express server → Route aggregator: mounts routes
src/server.js - Express server → API specification: loads specification
README.md - Express server → Not-found handler: registers fallback
src/server.js - Express server → Error handler: registers errors
src/server.js - Route aggregator → Author routes: routes authors
src/routes/index.js - Route aggregator → Post routes: routes posts
src/routes/index.js - Author routes → Author validation: validates input
src/routes/authors.routes.js - Author routes → Author controller: dispatches requests
src/routes/authors.routes.js - Author controller → Author queries: calls queries
src/controllers/authors.controller.js - Author controller → Async wrapper: wraps handlers
src/controllers/authors.controller.js - Author queries → PostgreSQL pool: queries through
src/services/authors.service.js - Post routes → Post validation: validates input
src/routes/posts.routes.js - Post routes → Post controller: dispatches requests
src/routes/posts.routes.js - Post controller → Post queries: calls queries
src/controllers/posts.controller.js - Post controller → Async wrapper: wraps handlers
src/controllers/posts.controller.js - Post queries → PostgreSQL pool: queries through
src/services/posts.service.js - PostgreSQL pool → PostgreSQL: connects to
README.md