A modern server template built with Express.js, TypeScript, PostgreSQL, and Prisma, featuring hot-reloading for development.
-
Clone the repository:
git clone https://github.com/your-username/server-template.git cd server-template -
Set up environment variables:
cp .env.example .env # Update values as needed -
Build and start the services:
docker-compose up --build
- This starts:
- Express app on
http://localhost:5001 - PostgreSQL on port 5432
- Express app on
- This starts:
docker-compose up # Use `-d` to run in backgrounddocker-compose down- Edit files locally → changes auto-refresh in the container
- TypeScript compilation happens automatically
-
Generate Prisma Client:
docker-compose exec app npx prisma generate -
Run Migrations:
docker-compose exec app npx prisma migrate dev -
View Database with Prisma Studio:
docker-compose exec app npx prisma studio
- Install inside the container (updates
package.json):docker-compose exec app npm install <package-name>
- Commit the updated
package.jsonandpackage-lock.json
| Service | URL/Port |
|---|---|
| Express App | http://localhost:5001 |
| PostgreSQL | Port: 5432 |
| Prisma Studio | http://localhost:5555 |
- Strict type checking enabled
- Path aliases configured
- ESLint and Prettier integration
- No
anytype allowed
-
Pull the latest changes:
git pull origin main
-
Rebuild containers (if dependencies change):
docker-compose down && docker-compose up --build -
Branching workflow:
- Create a feature branch:
git checkout -b feat/your-feature
- Commit changes:
git add . git commit -m "Description" git push origin feat/your-feature
- Create a Pull Request (PR) on GitHub
- Create a feature branch:
-
"Module not found" error:
docker-compose down && docker-compose up --build -
Database connection issues:
- Check if PostgreSQL container is running
- Verify database credentials in
.env - Use
dbas the hostname in your connection string
-
Hot-reload not working:
- Ensure
ts-node-devis indevDependencies - Check volume mounts in
docker-compose.yml
- Ensure
-
Port conflicts:
- Stop local PostgreSQL service if running
- Modify port mappings in
docker-compose.yml
MIT License. See LICENSE for details.
Happy Coding!