A robust Node.js/TypeScript backend template with built-in support for Fastify, PostgreSQL, Docker, and comprehensive testing setup.
- 🚀 Fastify - High-performance web framework
- 🔒 JWT Authentication - Built-in JWT support
- 📝 TypeScript - Type safety and better developer experience
- 🐳 Docker - Containerization support
- 🐘 PostgreSQL - Database support using Kysely
- ✅ Testing - Vitest setup with example tests
- 🔍 ESLint - Code quality and consistency
- 🚦 Rate Limiting - Built-in API rate limiting
- 🔄 CI/CD - GitHub Actions workflow for testing and linting
- ⚡ Hot Reload - Development with tsx watch
- Node.js 20.x
- Yarn
- Docker and Docker Compose (for containerized development)
- PostgreSQL (if running locally)
Create a .env
file in the root directory with the following variables:
NODE_ENV=development
APP_PORT=8000
DATABASE_URL=postgresql://user:password@localhost:5432/myapp
JWT_SECRET=your-secret-key
- Clone the repository
- Install dependencies:
yarn install
# Start the development server with hot reload
yarn dev
# Run tests
yarn test
# Run linting
yarn lint
# Start the application and database
yarn docker:start
# Start in detached mode
yarn docker:start:detach
# Execute commands in app container
yarn docker:exec:app
# Execute commands in database container
yarn docker:exec:db
# View logs
yarn docker:logs
# Stop containers
yarn docker:stop
The project uses Kysely as the SQL query builder and PostgreSQL as the database.
# Generate TypeScript types from database
yarn codegen
# Generate new migration
yarn kysely:generate
# Run migrations
yarn kysely:migrate
# Rollback migration
yarn kysely:down
The project uses Vitest for testing. Run tests with:
yarn test
GET /app/health-check
: Check if the API is running
├── src/
│ ├── app.ts # Application entry point
│ ├── config/ # Configuration files
│ ├── controllers/ # Route controllers
│ ├── database/ # Database related files
│ ├── routes/ # API routes
│ ├── types/ # TypeScript type definitions
│ └── utils/ # Utility functions
├── tests/ # Test files
├── docker/ # Docker configuration
└── .github/ # GitHub Actions workflows
- Fork this repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.