How rizky-iqbal36/testgooglepubsubwithnodejs works
This small Node.js service accepts birthday-related payloads over HTTP, publishes them to Google Pub/Sub, and runs separate age and year subscribers. The shared subscriber handler derives an age or birth year, then delegates persistence to Sequelize models. The excerpts establish the main calls and message handling; database configuration and migration details were not sampled, so the database link is shown as unverified.
Main entry points: pubSub-repo.js Pub/Sub handler · birthDayService.js Birth data service · server.js HTTP server · router.js Create route
Components 13
HTTP API
- HTTP server
server.js - Create route
src/routes/router.js - Publish controller
src/controller/topic-controller.js
Pub/Sub Messaging
- Pub/Sub handler
src/repositories/pubSub-repo.js - Google Pub/Sub
- Age subscriber
src/pubsub/subscribers/ageSub.js - Year subscriber
src/pubsub/subscribers/yearSub.js
Message Processing
- Birth data service
src/services/birthDayService.js
Persistence
- Model loader
models/index.js - Age model
models/agetable.js - Birth model
models/birthtable.js - SQL database
Other components
- API caller
Connections 14
- API caller → HTTP server: sends request
server.js - HTTP server → Create route: mounts routes
server.js - Create route → Publish controller: routes create
src/routes/router.js - Publish controller → Pub/Sub handler: publishes payload
src/controller/topic-controller.js - Pub/Sub handler → Google Pub/Sub: publishes message
src/repositories/pubSub-repo.js - Age subscriber → Pub/Sub handler: starts listener
src/pubsub/subscribers/ageSub.js - Year subscriber → Pub/Sub handler: starts listener
src/pubsub/subscribers/yearSub.js - Google Pub/Sub → Pub/Sub handler: delivers messages
src/repositories/pubSub-repo.js - Pub/Sub handler → Birth data service: stores parsed message
src/repositories/pubSub-repo.js - Birth data service → Model loader: loads models
src/services/birthDayService.js - Birth data service → Age model: creates age record
src/services/birthDayService.js - Birth data service → Birth model: creates year record
src/services/birthDayService.js - Age model → SQL database: persists records
- Birth model → SQL database: persists records