Simple NestJS API with MongoDB. Includes products CRUD, Swagger docs, and basic error handling.
npm install
npm run start:devYou'll need MongoDB. Use MongoDB Atlas (free cloud) or install locally.
Create a .env file in the root:
NODE_ENV=development
PORT=3000
MONGODB_URI=mongodb://localhost:27017/products
SWAGGER_ENABLED=true
CORS_ORIGIN=http://localhost:3000npm run start:dev # development with hot reload
npm run build # build for production
npm run start:prod # run production buildOr with Docker:
docker-compose up -dSwagger docs available at http://localhost:3000/api/docs
Main endpoints:
GET /api/products- list allGET /api/products/:id- get onePOST /api/products- createPUT /api/products/:id- updateDELETE /api/products/:id- delete
- Swagger UI: http://localhost:3000/api/docs
- Redoc: http://localhost:3000/redoc
- OpenAPI JSON: http://localhost:3000/openapi.json
npm run test
npm run test:e2e