Fastify HTTP server template with a MongoDB connection managed through Mongoose.
- Node.js and npm
- Docker with Docker Compose support
npm installThis project ships with Docker Compose files that start MongoDB and mongo-express for local development.
npm run startServices exposed locally:
- MongoDB:
mongodb://admin:password@localhost:27017/default?authSource=admin - mongo-express:
http://localhost:8081
To stop the containers and remove local volumes created by the stack:
npm run stopThe app reads local environment variables from env/local.env and starts Fastify on port 3000.
npm run start:devOnce started, the API is available at http://localhost:3000.
GET /- Returns a simple confirmation message that the Fastify server is running.
GET /heartbeat- Liveness-style endpoint for confirming that the web server process is up.
- Expected response:
200 OK
GET /health- Health-style endpoint that reports application status and current MongoDB connection state.
- Returns
200 OKwhen MongoDB is connected and503when the app is up but the database is not healthy.
- Fastify docs: https://fastify.dev/docs/latest/
- Mongoose docs: https://mongoosejs.com/docs/