create-ts-express-app 1.0.0

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 ADDED
@@ -0,0 +1,97 @@
1
+ # TypeScript Node.js Backend Template
2
+
3
+ A clean, production-ready TypeScript backend template for Node.js applications with modern best practices.
4
+
5
+ ## Features
6
+
7
+ - ✅ TypeScript configuration optimized for backend development
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
14
+
15
+ ## Getting Started
16
+
17
+ ### Prerequisites
18
+
19
+ - Node.js 18.x or higher
20
+ - npm or yarn
21
+
22
+ ### Installation
23
+
24
+ 1. Clone this repository:
25
+
26
+ ```bash
27
+ git clone https://github.com/harsh-dev0/ts-express.git
28
+ cd ts-express
29
+ ```
30
+
31
+ 2. Install dependencies:
32
+
33
+ ```bash
34
+ npm install
35
+ ```
36
+
37
+ 3. Create a `.env` file in the root directory:
38
+
39
+ ```
40
+ PORT=3000
41
+ ```
42
+
43
+ ### Development
44
+
45
+ Start the development server with hot reloading:
46
+
47
+ ```bash
48
+ npm run dev
49
+ ```
50
+
51
+ For watching file changes:
52
+
53
+ ```bash
54
+ npm run dev:watch
55
+ ```
56
+
57
+ ### Production
58
+
59
+ Build the project:
60
+
61
+ ```bash
62
+ npm run build
63
+ ```
64
+
65
+ Start the production server:
66
+
67
+ ```bash
68
+ npm start
69
+ ```
70
+
71
+ ## Project Structure
72
+
73
+ ```
74
+ ts-express/
75
+ ├── src/ # Source code
76
+ │ ├── index.ts # Application entry point
77
+ │ ├── routes/ # API routes
78
+ │ ├── controllers/ # Route controllers
79
+ │ ├── models/ # Data models
80
+ │ ├── middleware/ # Express middleware
81
+ │ └── config/ # Configuration files
82
+ ├── dist/ # Compiled output (generated)
83
+ ├── tsconfig.json # TypeScript configuration
84
+ ├── package.json # Project dependencies
85
+ └── .env # Environment variables
86
+ ```
87
+
88
+ ## Scripts
89
+
90
+ - `npm run build` - Compiles TypeScript to JavaScript
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
+
95
+ ## License
96
+
97
+ MIT
package/bin/cli.js ADDED
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs-extra');
4
+ const path = require('path');
5
+ const chalk = require('chalk');
6
+
7
+ // Get project name from command line
8
+ const projectName = process.argv[2] || 'ts-express-app';
9
+
10
+ // Target directory
11
+ const targetDir = path.join(process.cwd(), projectName);
12
+
13
+ // Source template directory
14
+ const templateDir = path.join(__dirname, '..', 'templates');
15
+
16
+ async function createProject() {
17
+ console.log(chalk.blue(`Creating a new TypeScript Express project in ${targetDir}`));
18
+
19
+ // Check if directory exists
20
+ if (fs.existsSync(targetDir)) {
21
+ console.error(chalk.red(`Error: Directory ${projectName} already exists.`));
22
+ process.exit(1);
23
+ }
24
+
25
+ // Copy template files
26
+ try {
27
+ await fs.copy(templateDir, targetDir);
28
+ console.log(chalk.green('Template files copied successfully.'));
29
+
30
+ // Update package.json with project name
31
+ const packageJsonPath = path.join(targetDir, 'package.json');
32
+ const packageJson = await fs.readJson(packageJsonPath);
33
+ packageJson.name = projectName;
34
+ await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
35
+
36
+ console.log(chalk.green('Project created successfully!'));
37
+ console.log(chalk.blue('\nNext steps:'));
38
+ console.log(` cd ${projectName}`);
39
+ console.log(' npm install');
40
+ console.log(' npm run dev');
41
+ } catch (err) {
42
+ console.error(chalk.red(`Error creating project: ${err.message}`));
43
+ process.exit(1);
44
+ }
45
+ }
46
+
47
+ createProject();
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "create-ts-express-app",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "bin": {
6
+ "create-ts-express-app": "bin/cli.js"
7
+ },
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "start": "node dist/index.js",
11
+ "dev": "nodemon --exec ts-node src/index.ts",
12
+ "dev:watch": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts"
13
+ },
14
+ "keywords": ["typescript", "express", "template", "starter"],
15
+ "author": "Harsh Pal",
16
+ "license": "MIT",
17
+ "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
+ "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
+ "path": "^0.12.7"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/harsh-dev0/ts-express.git"
41
+ },
42
+ "bugs": {
43
+ "url": "https://github.com/harsh-dev0/ts-express/issues"
44
+ },
45
+ "homepage": "https://github.com/harsh-dev0/ts-express#readme"
46
+ }
@@ -0,0 +1 @@
1
+ PORT=3000
@@ -0,0 +1,12 @@
1
+ module.exports = {
2
+ parser: "@typescript-eslint/parser",
3
+ plugins: ["@typescript-eslint", "prettier"],
4
+ extends: [
5
+ "eslint:recommended",
6
+ "plugin:@typescript-eslint/recommended",
7
+ "prettier",
8
+ ],
9
+ rules: {
10
+ "prettier/prettier": "error",
11
+ },
12
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "semi": true,
3
+ "singleQuote": true,
4
+ "printWidth": 80,
5
+ "tabWidth": 2
6
+ }
@@ -0,0 +1,97 @@
1
+ # TypeScript Node.js Backend Template
2
+
3
+ A clean, production-ready TypeScript backend template for Node.js applications with modern best practices.
4
+
5
+ ## Features
6
+
7
+ - ✅ TypeScript configuration optimized for backend development
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
14
+
15
+ ## Getting Started
16
+
17
+ ### Prerequisites
18
+
19
+ - Node.js 18.x or higher
20
+ - npm or yarn
21
+
22
+ ### Installation
23
+
24
+ 1. Clone this repository:
25
+
26
+ ```bash
27
+ git clone https://github.com/harsh-dev0/ts-express.git
28
+ cd ts-express
29
+ ```
30
+
31
+ 2. Install dependencies:
32
+
33
+ ```bash
34
+ npm install
35
+ ```
36
+
37
+ 3. Create a `.env` file in the root directory:
38
+
39
+ ```
40
+ PORT=3000
41
+ ```
42
+
43
+ ### Development
44
+
45
+ Start the development server with hot reloading:
46
+
47
+ ```bash
48
+ npm run dev
49
+ ```
50
+
51
+ For watching file changes:
52
+
53
+ ```bash
54
+ npm run dev:watch
55
+ ```
56
+
57
+ ### Production
58
+
59
+ Build the project:
60
+
61
+ ```bash
62
+ npm run build
63
+ ```
64
+
65
+ Start the production server:
66
+
67
+ ```bash
68
+ npm start
69
+ ```
70
+
71
+ ## Project Structure
72
+
73
+ ```
74
+ ts-express/
75
+ ├── src/ # Source code
76
+ │ ├── index.ts # Application entry point
77
+ │ ├── routes/ # API routes
78
+ │ ├── controllers/ # Route controllers
79
+ │ ├── models/ # Data models
80
+ │ ├── middleware/ # Express middleware
81
+ │ └── config/ # Configuration files
82
+ ├── dist/ # Compiled output (generated)
83
+ ├── tsconfig.json # TypeScript configuration
84
+ ├── package.json # Project dependencies
85
+ └── .env # Environment variables
86
+ ```
87
+
88
+ ## Scripts
89
+
90
+ - `npm run build` - Compiles TypeScript to JavaScript
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
+
95
+ ## License
96
+
97
+ MIT