A Node.js (Express) API scaffolded from the Atlas Node.js API Service template — pre-wired with Elastic APM, a Winston logger, a hardened multi-stage Dockerfile and a GitHub Actions CI/CD pipeline.
src/
├── index.js # bootstrap: starts APM, creates app, listens, graceful shutdown
├── app.js # Express app factory (testable without a port)
├── config/
│ ├── apm.js # Elastic APM agent (loaded first)
│ └── index.js # environment-driven config
├── lib/
│ └── logger.js # Winston logger (JSON in prod, pretty in dev)
├── middleware/
│ ├── requestContext.js # correlation id + per-request child logger
│ ├── requestLogger.js # structured access log with latency
│ ├── notFoundHandler.js # 404 -> error handler
│ └── errorHandler.js # central error responder
├── routes/
│ ├── index.js # router aggregation
│ └── health.routes.js
└── controllers/
└── health.controller.js
test/ # jest + supertest
npm install
cp .env.example .env
npm run dev # auto-reload
npm test # jest + supertest
npm run lintThe API listens on PORT (default 3000). Health check: GET /healthz.
- APM — set
ELASTIC_APM_SERVER_URL(and optionallyELASTIC_APM_SECRET_TOKEN) to enable the agent; it stays off locally when unset. - Logging — import
src/lib/logger; every request log carries arequestIdcorrelation id (also returned in theX-Request-Idheader).
docker build -t nodejs-api .
docker run -p 3000:3000 nodejs-api.github/workflows/ci.yaml runs install → lint → test on every push/PR, then
builds and (on main) publishes a container image to GitHub Container Registry.