Based on a boilerplate with focus on best practices and painless developer experience:
- Spin it up with single command 🌀
- TypeScript first
- RESTful APIs
- JWT authentication with role based authorization
- Add comprehensive tests
- Decouple View layer from Entity layer and user adapters to map them
- Add more validations
- Add Pagination
Easily set up a local development environment with single command!
- clone the repo
npm run docker:dev
🚀
Visit localhost:4000 or if using Postman grab config.
Containers created:
- Postgres database container seeded with 💊 Breaking Bad characters in
Users
table (default credentialsuser=walter
,password=white
in .env file) - Node (v16 Alpine) container with running boilerplate RESTful API service
- and one Node container instance to run tests locally or in CI
- Express framework
- TypeScript v4 codebase
- TypeORM using Data Mapper pattern
- Docker environment:
- Easily start local development using Docker Compose with single command
npm run docker:dev
- Connect to different staging or production environments
npm run docker:[stage|prod]
- Ready for microservices development and deployment.
Once API changes are made, just build and push new docker image with your favourite CI/CD tool
docker build -t <username>/api-boilerplate:latest .
docker push <username>/api-boilerplate:latest
- Run unit, integration (or setup with your frontend E2E) tests as
docker exec -ti be_boilerplate_test sh
andnpm run test
- Easily start local development using Docker Compose with single command
- Contract first REST API design:
- never break API again with HTTP responses and requests payloads using type definitions
- Consistent schema error response. Your frontend will always know how to handle errors thrown in
try...catch
statements 💪
- JWT authentication and role based authorization using custom middleware
- Set local, stage or production environmental variables with type definitions
- Logging with morgan
- Unit and integration tests with Mocha and Chai
- Linting with ESLint
- Prettier code formatter
- Git hooks with Husky and lint-staged
- Automated npm & Docker dependency updates with Renovate (set to patch version only)
- Commit messages must meet conventional commits format.