create-ts-express-app 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +60 -58
- package/bin/cli.js +41 -43
- package/package.json +11 -20
- package/template/Readme.md +60 -59
package/Readme.md
CHANGED
@@ -1,96 +1,98 @@
|
|
1
|
-
# TypeScript
|
1
|
+
# ⚡ TypeScript Express Backend Starter
|
2
2
|
|
3
|
-
A clean, production-ready TypeScript
|
3
|
+
A clean, production-ready **TypeScript + Node.js** backend boilerplate built with modern best practices. Instant Express app generation with `npx`.
|
4
4
|
|
5
|
-
|
5
|
+
---
|
6
6
|
|
7
|
-
|
8
|
-
- ✅ Express.js web server
|
9
|
-
- ✅ Environment variable management with dotenv
|
10
|
-
- ✅ Development mode with hot reloading
|
11
|
-
- ✅ Proper project structure for scalability
|
12
|
-
- ✅ Error handling middleware
|
13
|
-
- ✅ NPM scripts for development and production
|
7
|
+
## 🚀 Quickstart
|
14
8
|
|
15
|
-
|
9
|
+
```bash
|
10
|
+
npx create-ts-express-app@latest my-project-name
|
11
|
+
cd my-project-name
|
12
|
+
npm install
|
13
|
+
npm run dev
|
14
|
+
```
|
16
15
|
|
17
|
-
|
16
|
+
You're up and running in seconds. Just ship.
|
18
17
|
|
19
|
-
|
20
|
-
- npm or yarn
|
18
|
+
---
|
21
19
|
|
22
|
-
|
20
|
+
## 🧰 Features
|
23
21
|
|
24
|
-
|
22
|
+
- ⚙️ Fully typed Express.js setup
|
23
|
+
- 🔄 Hot reloading with `ts-node-dev`
|
24
|
+
- 🔐 `.env`-based configuration
|
25
|
+
- ✅ Clean file structure built to scale
|
26
|
+
- 🧱 Error handling middleware
|
27
|
+
- 🛠️ Scripts for dev & prod workflows
|
25
28
|
|
26
|
-
|
27
|
-
cd your-folder-name
|
28
|
-
```
|
29
|
+
---
|
29
30
|
|
30
|
-
|
31
|
+
## 📦 Prerequisites
|
31
32
|
|
32
|
-
|
33
|
-
npm
|
34
|
-
```
|
33
|
+
- Node.js **18+**
|
34
|
+
- `npm` or `yarn`
|
35
35
|
|
36
|
-
|
36
|
+
---
|
37
37
|
|
38
|
-
|
39
|
-
PORT=3000
|
40
|
-
```
|
38
|
+
## 🧪 Development
|
41
39
|
|
42
|
-
|
43
|
-
|
44
|
-
Start the development server with hot reloading:
|
40
|
+
Start dev server with hot reloading:
|
45
41
|
|
46
42
|
```bash
|
47
43
|
npm run dev
|
48
44
|
```
|
49
45
|
|
50
|
-
|
46
|
+
Or watch all file changes:
|
51
47
|
|
52
48
|
```bash
|
53
49
|
npm run dev:watch
|
54
50
|
```
|
55
51
|
|
56
|
-
|
57
|
-
|
58
|
-
Build the project:
|
52
|
+
---
|
59
53
|
|
60
|
-
|
61
|
-
npm run build
|
62
|
-
```
|
54
|
+
## 🚢 Production
|
63
55
|
|
64
|
-
|
56
|
+
Build & run:
|
65
57
|
|
66
58
|
```bash
|
59
|
+
npm run build
|
67
60
|
npm start
|
68
61
|
```
|
69
62
|
|
70
|
-
|
63
|
+
---
|
64
|
+
|
65
|
+
## 🌳 Project Structure
|
71
66
|
|
72
67
|
```
|
73
|
-
|
74
|
-
├── src/
|
75
|
-
│ ├── index.ts
|
76
|
-
│ ├── routes/
|
77
|
-
│ ├── controllers/
|
78
|
-
│ ├──
|
79
|
-
│
|
80
|
-
|
81
|
-
├──
|
82
|
-
├──
|
83
|
-
|
84
|
-
└── .env # Environment variables
|
68
|
+
my-project/
|
69
|
+
├── src/
|
70
|
+
│ ├── index.ts # App entry
|
71
|
+
│ ├── routes/ # Routes
|
72
|
+
│ ├── controllers/ # Route logic
|
73
|
+
│ ├── middleware/ # Custom middleware
|
74
|
+
│ └── config/ # Config (env, db, etc.)
|
75
|
+
├── dist/ # Compiled JS (auto-generated)
|
76
|
+
├── .env # Environment variables
|
77
|
+
├── package.json
|
78
|
+
└── tsconfig.json
|
85
79
|
```
|
86
80
|
|
87
|
-
|
81
|
+
---
|
82
|
+
|
83
|
+
## 🎯 Scripts
|
84
|
+
|
85
|
+
| Command | Description |
|
86
|
+
|---------------------|-------------------------------------|
|
87
|
+
| `npm run dev` | Start dev server (hot reload) |
|
88
|
+
| `npm run dev:watch` | Dev with full file watching |
|
89
|
+
| `npm run build` | Compile TypeScript to JavaScript |
|
90
|
+
| `npm start` | Start production server |
|
91
|
+
|
92
|
+
---
|
88
93
|
|
89
|
-
|
90
|
-
- `npm start` - Starts the production server
|
91
|
-
- `npm run dev` - Starts the development server
|
92
|
-
- `npm run dev:watch` - Starts the development server with file watching
|
94
|
+
## 📄 License
|
93
95
|
|
94
|
-
|
96
|
+
MIT — Use it. Build with it. Ship something great.
|
95
97
|
|
96
|
-
|
98
|
+
---
|
package/bin/cli.js
CHANGED
@@ -1,50 +1,48 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
const fs = require('fs-extra');
|
4
|
-
const path = require('path');
|
1
|
+
const fs = require("fs-extra")
|
2
|
+
const path = require("path")
|
5
3
|
|
6
4
|
// Get project name from command line
|
7
|
-
const projectName = process.argv[2] ||
|
5
|
+
const projectName = process.argv[2] || "ts-express-app"
|
8
6
|
|
9
7
|
// Target directory (where user ran the npx command)
|
10
|
-
const targetDir = path.join(process.cwd(), projectName)
|
8
|
+
const targetDir = path.join(process.cwd(), projectName)
|
11
9
|
|
12
10
|
// Source template directory (relative to this script)
|
13
|
-
const templateDir = path.join(__dirname,
|
11
|
+
const templateDir = path.join(__dirname, "..", "template")
|
14
12
|
|
15
|
-
console.log(
|
16
|
-
console.log(`Script location: ${__dirname}`)
|
17
|
-
console.log(`Template directory: ${templateDir}`)
|
18
|
-
console.log(`Target directory: ${targetDir}`)
|
13
|
+
console.log("Debug info:")
|
14
|
+
console.log(`Script location: ${__dirname}`)
|
15
|
+
console.log(`Template directory: ${templateDir}`)
|
16
|
+
console.log(`Target directory: ${targetDir}`)
|
19
17
|
|
20
18
|
async function createProject() {
|
21
|
-
console.log(`Creating a new TypeScript Express project in ${targetDir}`)
|
22
|
-
|
19
|
+
console.log(`Creating a new TypeScript Express project in ${targetDir}`)
|
20
|
+
|
23
21
|
// Check if directory exists
|
24
22
|
if (fs.existsSync(targetDir)) {
|
25
|
-
console.error(`Error: Directory ${projectName} already exists.`)
|
26
|
-
process.exit(1)
|
23
|
+
console.error(`Error: Directory ${projectName} already exists.`)
|
24
|
+
process.exit(1)
|
27
25
|
}
|
28
|
-
|
26
|
+
|
29
27
|
// Create the target directory
|
30
|
-
fs.mkdirSync(targetDir, { recursive: true })
|
31
|
-
|
28
|
+
fs.mkdirSync(targetDir, { recursive: true })
|
29
|
+
|
32
30
|
// Check if template directory exists
|
33
31
|
if (!fs.existsSync(templateDir)) {
|
34
|
-
console.error(`Error: Template directory not found at ${templateDir}`)
|
35
|
-
console.log(
|
36
|
-
console.log(fs.readdirSync(path.join(__dirname,
|
37
|
-
process.exit(1)
|
32
|
+
console.error(`Error: Template directory not found at ${templateDir}`)
|
33
|
+
console.log("Available files in script directory:")
|
34
|
+
console.log(fs.readdirSync(path.join(__dirname, "..")))
|
35
|
+
process.exit(1)
|
38
36
|
}
|
39
|
-
|
37
|
+
|
40
38
|
// Copy template files
|
41
39
|
try {
|
42
|
-
await fs.copy(templateDir, targetDir)
|
43
|
-
console.log(
|
40
|
+
await fs.copy(templateDir, targetDir)
|
41
|
+
console.log("Template files copied successfully.")
|
44
42
|
// Add this after copying the template files:
|
45
|
-
await fs.writeFile(
|
46
|
-
|
47
|
-
|
43
|
+
await fs.writeFile(
|
44
|
+
path.join(targetDir, ".gitignore"),
|
45
|
+
`# Generated .gitignore file
|
48
46
|
node_modules/
|
49
47
|
dist/
|
50
48
|
.env
|
@@ -52,24 +50,24 @@ await fs.writeFile(
|
|
52
50
|
npm-debug.log
|
53
51
|
yarn-error.log
|
54
52
|
`
|
55
|
-
|
56
|
-
const packageJsonPath = path.join(targetDir,
|
53
|
+
)
|
54
|
+
const packageJsonPath = path.join(targetDir, "package.json")
|
57
55
|
if (fs.existsSync(packageJsonPath)) {
|
58
|
-
const packageJson = await fs.readJson(packageJsonPath)
|
59
|
-
packageJson.name = projectName
|
60
|
-
await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 })
|
56
|
+
const packageJson = await fs.readJson(packageJsonPath)
|
57
|
+
packageJson.name = projectName
|
58
|
+
await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 })
|
61
59
|
}
|
62
|
-
|
63
|
-
console.log(
|
64
|
-
console.log(
|
65
|
-
console.log(` cd ${projectName}`)
|
66
|
-
console.log(
|
67
|
-
console.log(
|
60
|
+
|
61
|
+
console.log("Project created successfully!")
|
62
|
+
console.log("\nNext steps:")
|
63
|
+
console.log(` cd ${projectName}`)
|
64
|
+
console.log(" npm install")
|
65
|
+
console.log(" npm run dev")
|
68
66
|
} catch (err) {
|
69
|
-
console.error(`Error creating project: ${err.message}`)
|
70
|
-
console.error(err.stack)
|
71
|
-
process.exit(1)
|
67
|
+
console.error(`Error creating project: ${err.message}`)
|
68
|
+
console.error(err.stack)
|
69
|
+
process.exit(1)
|
72
70
|
}
|
73
71
|
}
|
74
72
|
|
75
|
-
createProject()
|
73
|
+
createProject()
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "create-ts-express-app",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.3.1",
|
4
4
|
"main": "index.js",
|
5
5
|
"bin": {
|
6
6
|
"create-ts-express-app": "bin/cli.js"
|
@@ -11,30 +11,21 @@
|
|
11
11
|
"dev": "nodemon --exec ts-node src/index.ts",
|
12
12
|
"dev:watch": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts"
|
13
13
|
},
|
14
|
-
"keywords": [
|
14
|
+
"keywords": [
|
15
|
+
"typescript",
|
16
|
+
"express",
|
17
|
+
"boilerplate",
|
18
|
+
"create-app",
|
19
|
+
"starter",
|
20
|
+
"scaffold",
|
21
|
+
"npx",
|
22
|
+
"cli"
|
23
|
+
],
|
15
24
|
"author": "Harsh Pal",
|
16
25
|
"license": "MIT",
|
17
26
|
"description": "A simple backend starter for ts",
|
18
|
-
"devDependencies": {
|
19
|
-
"@types/node": "^22.14.1",
|
20
|
-
"@typescript-eslint/eslint-plugin": "^8.30.1",
|
21
|
-
"@typescript-eslint/parser": "^8.30.1",
|
22
|
-
"eslint": "^9.24.0",
|
23
|
-
"eslint-config-prettier": "^10.1.2",
|
24
|
-
"eslint-plugin-prettier": "^5.2.6",
|
25
|
-
"nodemon": "^3.1.9",
|
26
|
-
"prettier": "^3.5.3",
|
27
|
-
"ts-node": "^10.9.2",
|
28
|
-
"typescript": "^5.8.3"
|
29
|
-
},
|
30
27
|
"dependencies": {
|
31
|
-
"@types/express": "^5.0.1",
|
32
|
-
"dotenv": "^16.5.0",
|
33
|
-
"express": "^5.1.0",
|
34
|
-
"fs": "^0.0.1-security",
|
35
|
-
"ncp": "^2.0.0",
|
36
28
|
"path": "^0.12.7",
|
37
|
-
"chalk": "^4.1.2",
|
38
29
|
"fs-extra": "^10.1.0"
|
39
30
|
},
|
40
31
|
"repository": {
|
package/template/Readme.md
CHANGED
@@ -1,97 +1,98 @@
|
|
1
|
-
# TypeScript
|
1
|
+
# ⚡ TypeScript Express Backend Starter
|
2
2
|
|
3
|
-
A clean, production-ready TypeScript
|
3
|
+
A clean, production-ready **TypeScript + Node.js** backend boilerplate built with modern best practices. Instant Express app generation with `npx`.
|
4
4
|
|
5
|
-
|
5
|
+
---
|
6
6
|
|
7
|
-
|
8
|
-
- ✅ Express.js web server
|
9
|
-
- ✅ Environment variable management with dotenv
|
10
|
-
- ✅ Development mode with hot reloading
|
11
|
-
- ✅ Proper project structure for scalability
|
12
|
-
- ✅ Error handling middleware
|
13
|
-
- ✅ NPM scripts for development and production
|
7
|
+
## 🚀 Quickstart
|
14
8
|
|
15
|
-
|
9
|
+
```bash
|
10
|
+
npx create-ts-express-app@latest my-project-name
|
11
|
+
cd my-project-name
|
12
|
+
npm install
|
13
|
+
npm run dev
|
14
|
+
```
|
16
15
|
|
17
|
-
|
16
|
+
You're up and running in seconds. Just ship.
|
18
17
|
|
19
|
-
|
20
|
-
- npm or yarn
|
18
|
+
---
|
21
19
|
|
22
|
-
|
20
|
+
## 🧰 Features
|
23
21
|
|
24
|
-
|
22
|
+
- ⚙️ Fully typed Express.js setup
|
23
|
+
- 🔄 Hot reloading with `ts-node-dev`
|
24
|
+
- 🔐 `.env`-based configuration
|
25
|
+
- ✅ Clean file structure built to scale
|
26
|
+
- 🧱 Error handling middleware
|
27
|
+
- 🛠️ Scripts for dev & prod workflows
|
25
28
|
|
26
|
-
|
27
|
-
git clone https://github.com/harsh-dev0/ts-express.git
|
28
|
-
cd ts-express
|
29
|
-
```
|
29
|
+
---
|
30
30
|
|
31
|
-
|
31
|
+
## 📦 Prerequisites
|
32
32
|
|
33
|
-
|
34
|
-
npm
|
35
|
-
```
|
33
|
+
- Node.js **18+**
|
34
|
+
- `npm` or `yarn`
|
36
35
|
|
37
|
-
|
36
|
+
---
|
38
37
|
|
39
|
-
|
40
|
-
PORT=3000
|
41
|
-
```
|
38
|
+
## 🧪 Development
|
42
39
|
|
43
|
-
|
44
|
-
|
45
|
-
Start the development server with hot reloading:
|
40
|
+
Start dev server with hot reloading:
|
46
41
|
|
47
42
|
```bash
|
48
43
|
npm run dev
|
49
44
|
```
|
50
45
|
|
51
|
-
|
46
|
+
Or watch all file changes:
|
52
47
|
|
53
48
|
```bash
|
54
49
|
npm run dev:watch
|
55
50
|
```
|
56
51
|
|
57
|
-
|
58
|
-
|
59
|
-
Build the project:
|
52
|
+
---
|
60
53
|
|
61
|
-
|
62
|
-
npm run build
|
63
|
-
```
|
54
|
+
## 🚢 Production
|
64
55
|
|
65
|
-
|
56
|
+
Build & run:
|
66
57
|
|
67
58
|
```bash
|
59
|
+
npm run build
|
68
60
|
npm start
|
69
61
|
```
|
70
62
|
|
71
|
-
|
63
|
+
---
|
64
|
+
|
65
|
+
## 🌳 Project Structure
|
72
66
|
|
73
67
|
```
|
74
|
-
|
75
|
-
├── src/
|
76
|
-
│ ├── index.ts
|
77
|
-
│ ├── routes/
|
78
|
-
│ ├── controllers/
|
79
|
-
│ ├──
|
80
|
-
│
|
81
|
-
|
82
|
-
├──
|
83
|
-
├──
|
84
|
-
|
85
|
-
└── .env # Environment variables
|
68
|
+
my-project/
|
69
|
+
├── src/
|
70
|
+
│ ├── index.ts # App entry
|
71
|
+
│ ├── routes/ # Routes
|
72
|
+
│ ├── controllers/ # Route logic
|
73
|
+
│ ├── middleware/ # Custom middleware
|
74
|
+
│ └── config/ # Config (env, db, etc.)
|
75
|
+
├── dist/ # Compiled JS (auto-generated)
|
76
|
+
├── .env # Environment variables
|
77
|
+
├── package.json
|
78
|
+
└── tsconfig.json
|
86
79
|
```
|
87
80
|
|
88
|
-
|
81
|
+
---
|
82
|
+
|
83
|
+
## 🎯 Scripts
|
84
|
+
|
85
|
+
| Command | Description |
|
86
|
+
|---------------------|-------------------------------------|
|
87
|
+
| `npm run dev` | Start dev server (hot reload) |
|
88
|
+
| `npm run dev:watch` | Dev with full file watching |
|
89
|
+
| `npm run build` | Compile TypeScript to JavaScript |
|
90
|
+
| `npm start` | Start production server |
|
91
|
+
|
92
|
+
---
|
89
93
|
|
90
|
-
|
91
|
-
- `npm start` - Starts the production server
|
92
|
-
- `npm run dev` - Starts the development server
|
93
|
-
- `npm run dev:watch` - Starts the development server with file watching
|
94
|
+
## 📄 License
|
94
95
|
|
95
|
-
|
96
|
+
MIT — Use it. Build with it. Ship something great.
|
96
97
|
|
97
|
-
|
98
|
+
---
|