Skip to content

Commit 4abc8b7

Browse files
committed
feat: initialize the template with basic settings
0 parents  commit 4abc8b7

File tree

13 files changed

+1411
-0
lines changed

13 files changed

+1411
-0
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
dist
3+
.env
4+
Dockerfile
5+
docker-compose.yml

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Server Configuration
2+
PORT=3000

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Node dependencies
2+
node_modules/
3+
4+
# Production build
5+
dist/
6+
7+
# Environment variables
8+
.env
9+
10+
# Logs
11+
logs
12+
*.log
13+
npm-debug.log*
14+
pnpm-debug.log*
15+
yarn-debug.log*
16+
17+
# IDE configs
18+
.vscode/
19+
.idea/
20+
21+
# OS files
22+
.DS_Store
23+
Thumbs.db
24+
25+
# Docker artifacts
26+
docker-compose.override.yml
27+
28+
# TypeScript cache
29+
*.tsbuildinfo
30+

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Build stage
2+
FROM node:22 AS builder
3+
4+
RUN corepack enable && corepack prepare pnpm@latest --activate
5+
6+
WORKDIR /app
7+
COPY . .
8+
9+
RUN pnpm install
10+
RUN pnpm run build
11+
12+
# Production stage
13+
FROM node:22-slim
14+
15+
RUN corepack enable && corepack prepare pnpm@latest --activate
16+
17+
WORKDIR /app
18+
COPY --from=builder /app/dist ./dist
19+
COPY package.json pnpm-lock.yaml ./
20+
RUN pnpm install --prod
21+
22+
CMD ["node", "dist/server.js"]

README.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Express + TypeScript + Docker Template
2+
3+
A starter template for building modern backend applications with **Express.js**, **TypeScript**, **Docker**, and **pnpm**. Perfect for local development and production-ready deployments.
4+
5+
---
6+
7+
## 🚀 Features
8+
9+
- ⚡️ Express.js with TypeScript
10+
- 📦 pnpm as package manager
11+
- 🐳 Docker support for dev & prod
12+
- 📂 Modular folder structure
13+
- 🌱 `.env` environment configuration
14+
- 🔁 Hot-reloading with `ts-node-dev`
15+
16+
---
17+
18+
## 🧱 Project Structure
19+
20+
```
21+
22+
.
23+
├── src/
24+
│ ├── routes/
25+
│ │ └── index.ts # Sample route
26+
│ ├── app.ts # Express app config
27+
│ └── server.ts # Entry point
28+
├── .env # Environment variables
29+
├── Dockerfile # Production Docker build
30+
├── docker-compose.yml # Dev environment
31+
├── package.json # Project metadata
32+
├── tsconfig.json # TS config for dev
33+
├── tsconfig.build.json # TS config for prod build
34+
└── README.md # You're here!
35+
36+
```
37+
38+
---
39+
40+
## 🛠️ Development Setup
41+
42+
1. **Install dependencies**
43+
44+
```bash
45+
pnpm install
46+
```
47+
48+
2. **Run locally**
49+
50+
```bash
51+
pnpm run dev
52+
```
53+
54+
3. **Lint and type-check (optional)**
55+
56+
```bash
57+
pnpm run build
58+
```
59+
60+
---
61+
62+
## 🐳 Docker Usage
63+
64+
### Run in Development Mode
65+
66+
```bash
67+
docker-compose up --build
68+
```
69+
70+
### Build for Production
71+
72+
```bash
73+
docker build -t express-ts-app .
74+
```
75+
76+
### Run in Production
77+
78+
```bash
79+
docker run -p 3000:3000 --env-file .env express-ts-app
80+
```
81+
82+
---
83+
84+
## 🌐 Access the App
85+
86+
After running in any mode, open:
87+
88+
```
89+
http://localhost:3000
90+
```
91+
92+
---
93+
94+
## 📦 Built With
95+
96+
- [Express](https://expressjs.com/)
97+
- [TypeScript](https://www.typescriptlang.org/)
98+
- [pnpm](https://pnpm.io/)
99+
- [Docker](https://www.docker.com/)
100+
101+
---
102+
103+
## 📄 License
104+
105+
MIT – feel free to use and modify.

docker-compose.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: "3.8"
2+
3+
services:
4+
app:
5+
container_name: express-ts-dev
6+
build:
7+
context: .
8+
dockerfile: Dockerfile
9+
volumes:
10+
- .:/app
11+
- /app/node_modules
12+
ports:
13+
- "3000:3000"
14+
command: pnpm run dev
15+
env_file: .env

package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "express-ts-docker-template",
3+
"version": "1.0.0",
4+
"main": "dist/server.js",
5+
"scripts": {
6+
"dev": "ts-node-dev --respawn --transpile-only src/server.ts",
7+
"build": "tsc -p tsconfig.build.json",
8+
"start": "node dist/server.js"
9+
},
10+
"dependencies": {
11+
"express": "^4.18.2",
12+
"dotenv": "^16.0.3"
13+
},
14+
"devDependencies": {
15+
"@types/express": "^4.17.21",
16+
"@types/node": "^20.4.2",
17+
"ts-node-dev": "^2.0.0",
18+
"typescript": "^5.2.2"
19+
},
20+
"packageManager": "pnpm@10.12.1"
21+
}

0 commit comments

Comments
 (0)