create-nodets-app-nish 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,161 @@
1
+ # create-nodets-app-nish
2
+
3
+ 🚀 A command-line tool to create a new **Node.js + Express + MongoDB + TypeScript** project with best practices and sensible defaults.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm create nodets-app-nish
9
+ ```
10
+
11
+ Or with a project name:
12
+
13
+ ```bash
14
+ npm create nodets-app-nish my-app
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ### Interactive Mode
20
+
21
+ ```bash
22
+ npm create nodets-app-nish
23
+ ```
24
+
25
+ You'll be prompted to enter your project name.
26
+
27
+ ### With Project Name
28
+
29
+ ```bash
30
+ npm create nodets-app-nish my-awesome-app
31
+ cd my-awesome-app
32
+ npm install
33
+ npm run dev
34
+ ```
35
+
36
+ ## What's Included
37
+
38
+ The generated project includes:
39
+
40
+ - ✨ **TypeScript** - Full TypeScript support out of the box
41
+ - 🚀 **Express.js** - Fast and lightweight web framework
42
+ - 🗄️ **MongoDB** - Document database with Mongoose ODM
43
+ - 🔐 **Authentication** - JWT tokens with bcrypt password hashing
44
+ - 📧 **Email Integration** - Nodemailer for email sending
45
+ - 🏗️ **Clean Architecture** - Well-organized folder structure
46
+ - ♻️ **Hot Reload** - Nodemon for development
47
+ - 🏭 **Production Ready** - Build scripts for compilation
48
+
49
+ ## Package Contents
50
+
51
+ ```
52
+ templates/
53
+ └── nodejs-typescript/
54
+ ├── src/
55
+ │ ├── index.ts # Entry point
56
+ │ ├── app.ts # Express app config
57
+ │ ├── admin/ # Admin module
58
+ │ │ └── model.register.ts
59
+ │ ├── controllers/ # Route controllers
60
+ │ ├── db/ # Database setup
61
+ │ ├── interface/ # TypeScript interfaces
62
+ │ ├── middlewares/ # Custom middlewares
63
+ │ ├── models/ # Mongoose models
64
+ │ ├── routers/ # API routes
65
+ │ └── utils/ # Helper functions
66
+ ├── package.json
67
+ ├── tsconfig.json
68
+ ├── .env.example
69
+ └── .gitignore
70
+
71
+ bin/
72
+ └── index.js # CLI entry point
73
+ ```
74
+
75
+ ## Getting Started with Generated Project
76
+
77
+ ```bash
78
+ cd my-app
79
+ npm install
80
+ cp .env.example .env
81
+ # Edit .env with your configuration
82
+ npm run dev
83
+ ```
84
+
85
+ ### Available Scripts
86
+
87
+ ```bash
88
+ npm run dev # Start development server with hot reload
89
+ npm run build # Build TypeScript to JavaScript
90
+ npm start # Run compiled application
91
+ ```
92
+
93
+ ## Configuration
94
+
95
+ The generated project includes a `.env.example` file. Copy it to `.env` and configure:
96
+
97
+ ```env
98
+ PORT=3000
99
+ MONGODB_URI=mongodb://localhost:27017/your-app
100
+ JWT_SECRET=your-secret-key
101
+ CORS_ORIGIN=http://localhost:3000
102
+
103
+ # Email Configuration
104
+ SMTP_HOST=smtp.gmail.com
105
+ SMTP_PORT=587
106
+ SMTP_USER=your-email@gmail.com
107
+ SMTP_PASS=your-app-password
108
+ SMTP_FROM=noreply@example.com
109
+ ```
110
+
111
+ ## Features
112
+
113
+ ### Admin Model with Authentication
114
+ - User registration with password hashing (bcrypt)
115
+ - JWT token generation
116
+ - Password verification
117
+ - MongoDB/Mongoose integration
118
+
119
+ ### Utility Functions
120
+ - **apiResponse** - Standardized API response formatter
121
+ - **asyncHandler** - Express async/await error handling
122
+ - **login** - Login utility for different models
123
+ - **sendMail** - Email sending via SMTP
124
+
125
+ ### Production Ready
126
+ - TypeScript strict mode enabled
127
+ - ESM modules support
128
+ - Comprehensive tsconfig setup
129
+ - Security best practices included
130
+
131
+ ## How It Works
132
+
133
+ 1. User runs `npm create nodets-app my-app`
134
+ 2. CLI prompts for project name
135
+ 3. Creates project directory
136
+ 4. Copies template files
137
+ 5. Updates package.json with project name
138
+ 6. Ready to install and develop!
139
+
140
+ ## Publishing to npm
141
+
142
+ 1. Create npm account at [npmjs.com](https://www.npmjs.com)
143
+ 2. Login locally: `npm login`
144
+ 3. Publish: `npm publish`
145
+
146
+ After publishing, users can use your template:
147
+ ```bash
148
+ npx create-nodets-app my-project
149
+ ```
150
+
151
+ ## License
152
+
153
+ ISC
154
+
155
+ ## Author
156
+
157
+ krish112407
158
+
159
+ ---
160
+
161
+ Made with ❤️ for Node.js developers | Based on professional backend architecture
package/bin/index.js ADDED
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from 'fs-extra';
4
+ import path from 'path';
5
+ import { fileURLToPath } from 'url';
6
+ import { stdin as input, stdout as output } from 'process';
7
+ import readline from 'readline';
8
+
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = path.dirname(__filename);
11
+ const templatesDir = path.join(__dirname, '..', 'templates');
12
+
13
+ const rl = readline.createInterface({ input, output });
14
+
15
+ function question(query) {
16
+ return new Promise((resolve) => {
17
+ rl.question(query, resolve);
18
+ });
19
+ }
20
+
21
+ async function main() {
22
+ try {
23
+ console.log('\n🚀 Welcome to create-nodets-app!\n');
24
+
25
+ // Get project name
26
+ let projectName = process.argv[2];
27
+ if (!projectName) {
28
+ projectName = await question('📁 Enter project name: ');
29
+ }
30
+
31
+ if (!projectName || projectName.trim() === '') {
32
+ console.error('❌ Project name is required!');
33
+ process.exit(1);
34
+ }
35
+
36
+ projectName = projectName.trim();
37
+
38
+ // Check if directory already exists
39
+ if (fs.existsSync(projectName)) {
40
+ console.error(`❌ Directory "${projectName}" already exists!`);
41
+ process.exit(1);
42
+ }
43
+
44
+ console.log(`\n✨ Creating project: ${projectName}`);
45
+
46
+ // Create project directory
47
+ fs.mkdirSync(projectName, { recursive: true });
48
+
49
+ // Copy template files
50
+ const templatePath = path.join(templatesDir, 'nodejs-typescript');
51
+ if (!fs.existsSync(templatePath)) {
52
+ console.error('❌ Template not found!');
53
+ process.exit(1);
54
+ }
55
+
56
+ fs.copySync(templatePath, projectName, { overwrite: false });
57
+
58
+ // Update package.json with project name
59
+ const packageJsonPath = path.join(projectName, 'package.json');
60
+ const packageJson = fs.readJsonSync(packageJsonPath);
61
+ packageJson.name = projectName;
62
+ packageJson.author = 'krish112407';
63
+ fs.writeJsonSync(packageJsonPath, packageJson, { spaces: 2 });
64
+
65
+ console.log(`\n✅ Project created successfully!\n`);
66
+ console.log(`📂 Project directory: ${projectName}`);
67
+ console.log(`\n🎯 Next steps:`);
68
+ console.log(` 1. cd ${projectName}`);
69
+ console.log(` 2. npm install`);
70
+ console.log(` 3. npm run dev\n`);
71
+
72
+ rl.close();
73
+ } catch (error) {
74
+ console.error('Error:', error.message);
75
+ rl.close();
76
+ process.exit(1);
77
+ }
78
+ }
79
+
80
+ main();
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "create-nodets-app-nish",
3
+ "version": "1.0.0",
4
+ "description": "Command line tool to create a new Node.js + Express + MongoDB + TypeScript project template",
5
+ "license": "ISC",
6
+ "author": "krish112407",
7
+ "type": "module",
8
+ "bin": {
9
+ "create-nodets-app-nish": "bin/index.js"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.js"
14
+ }
15
+ },
16
+ "engines": {
17
+ "node": ">=16.0.0"
18
+ },
19
+ "keywords": [
20
+ "cli",
21
+ "create-app",
22
+ "node",
23
+ "typescript",
24
+ "template",
25
+ "generator",
26
+ "boilerplate",
27
+ "express",
28
+ "mongodb"
29
+ ],
30
+ "scripts": {
31
+ "dev": "node bin/index.js",
32
+ "build": "tsc",
33
+ "test": "echo \"Error: no test specified\" && exit 1"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/krish112407/create-nodets-app.git"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/krish112407/create-nodets-app/issues"
41
+ },
42
+ "homepage": "https://github.com/krish112407/create-nodets-app#readme",
43
+ "devDependencies": {
44
+ "@types/node": "^25.0.10",
45
+ "typescript": "^5.9.3"
46
+ },
47
+ "dependencies": {
48
+ "fs-extra": "^11.2.0"
49
+ }
50
+ }
@@ -0,0 +1,156 @@
1
+ # Node.js + Express + MongoDB + TypeScript Application
2
+
3
+ A production-ready Node.js backend application built with Express, MongoDB, and TypeScript.
4
+
5
+ ## Features
6
+
7
+ - ✨ **TypeScript** - Full type safety
8
+ - 🚀 **Express.js** - Fast and lightweight web framework
9
+ - 🗄️ **MongoDB** - NoSQL database with Mongoose ODM
10
+ - 🔐 **Authentication** - JWT-based auth with bcrypt password hashing
11
+ - 📧 **Email Service** - Nodemailer integration for sending emails
12
+ - 🏗️ **Clean Architecture** - Well-organized folder structure
13
+ - 🔥 **Hot Reload** - Nodemon for development
14
+
15
+ ## Prerequisites
16
+
17
+ - Node.js 16+
18
+ - MongoDB (local or cloud)
19
+ - SMTP server credentials (Gmail, SendGrid, etc.)
20
+
21
+ ## Getting Started
22
+
23
+ ### Installation
24
+
25
+ ```bash
26
+ npm install
27
+ ```
28
+
29
+ ### Setup Environment
30
+
31
+ Copy `.env.example` to `.env` and configure your variables:
32
+
33
+ ```bash
34
+ cp .env.example .env
35
+ ```
36
+
37
+ Edit `.env` with your settings:
38
+ - `MONGODB_URI` - MongoDB connection string
39
+ - `JWT_SECRET` - Secret key for JWT tokens
40
+ - `SMTP_*` - Email service credentials
41
+
42
+ ### Development
43
+
44
+ Start the development server with hot reload:
45
+
46
+ ```bash
47
+ npm run dev
48
+ ```
49
+
50
+ The server will run on `http://localhost:3000`
51
+
52
+ ### Build
53
+
54
+ Compile TypeScript to JavaScript:
55
+
56
+ ```bash
57
+ npm run build
58
+ ```
59
+
60
+ ### Production
61
+
62
+ Build and run in production:
63
+
64
+ ```bash
65
+ npm run build
66
+ npm start
67
+ ```
68
+
69
+ ## Project Structure
70
+
71
+ ```
72
+ src/
73
+ ├── index.ts # Entry point
74
+ ├── app.ts # Express app setup
75
+ ├── admin/ # Admin model registration
76
+ │ └── model.register.ts
77
+ ├── controllers/ # Route controllers
78
+ │ ├── admin/
79
+ │ └── user/
80
+ ├── db/ # Database setup
81
+ │ └── index.ts
82
+ ├── interface/ # TypeScript interfaces
83
+ │ └── admin.interface.ts
84
+ ├── middlewares/ # Custom middlewares
85
+ ├── models/ # Mongoose models
86
+ │ └── admin.models.ts
87
+ ├── routers/ # API routes
88
+ └── utils/ # Helper functions
89
+ ├── apiResponse.ts # Response formatting
90
+ ├── asyncHandler.ts # Async error handling
91
+ ├── login.ts # Login logic
92
+ └── sendMail.ts # Email sending
93
+ ```
94
+
95
+ ## Available Scripts
96
+
97
+ ```bash
98
+ npm run dev # Start development server with hot reload
99
+ npm run build # Build TypeScript to JavaScript
100
+ npm start # Run production build
101
+ ```
102
+
103
+ ## Key Utilities
104
+
105
+ ### apiResponse - Format consistent API responses
106
+ ```typescript
107
+ import { returnResponse } from "./utils/apiResponse.js";
108
+ returnResponse(res, 200, "Success", { data: "your data" });
109
+ ```
110
+
111
+ ### asyncHandler - Wrap async route handlers
112
+ ```typescript
113
+ import { asyncHandler } from "./utils/asyncHandler.js";
114
+ router.get("/", asyncHandler(async (req, res) => {
115
+ // Your async code
116
+ }));
117
+ ```
118
+
119
+ ### login - Authenticate users
120
+ ```typescript
121
+ import { login } from "./utils/login.js";
122
+ const token = await login("Admin", { email }, password);
123
+ ```
124
+
125
+ ### sendMail - Send emails
126
+ ```typescript
127
+ import { sendMail } from "./utils/sendMail.js";
128
+ await sendMail({
129
+ to: "user@example.com",
130
+ subject: "Welcome",
131
+ html: "<h1>Welcome!</h1>"
132
+ });
133
+ ```
134
+
135
+ ## Environment Variables
136
+
137
+ ```env
138
+ PORT=3000
139
+ MONGODB_URI=mongodb://localhost:27017/app-name
140
+ JWT_SECRET=your-secret-key
141
+ CORS_ORIGIN=http://localhost:3000
142
+
143
+ SMTP_HOST=smtp.gmail.com
144
+ SMTP_PORT=587
145
+ SMTP_USER=your-email@gmail.com
146
+ SMTP_PASS=your-app-password
147
+ SMTP_FROM=noreply@example.com
148
+ ```
149
+
150
+ ## License
151
+
152
+ ISC
153
+
154
+ ---
155
+
156
+ Created with [create-nodets-app](https://github.com/krish112407/create-nodets-app)
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "my-nodejs-app",
3
+ "version": "1.0.0",
4
+ "description": "A Node.js + Express + MongoDB + TypeScript application",
5
+ "license": "ISC",
6
+ "author": "Your Name",
7
+ "type": "module",
8
+ "main": "dist/index.js",
9
+ "scripts": {
10
+ "dev": "nodemon --exec tsx src/index.ts",
11
+ "build": "tsc -p tsconfig.build.json",
12
+ "start": "node dist/index.js",
13
+ "test": "echo \"Error: no test specified\" && exit 1"
14
+ },
15
+ "devDependencies": {
16
+ "@types/node": "^25.0.10",
17
+ "nodemon": "^3.1.11",
18
+ "ts-node": "^10.9.2",
19
+ "tsx": "^4.21.0",
20
+ "typescript": "^5.9.3"
21
+ },
22
+ "dependencies": {
23
+ "@types/bcrypt": "^6.0.0",
24
+ "@types/cookie-parser": "^1.4.10",
25
+ "@types/cors": "^2.8.19",
26
+ "@types/express": "^5.0.6",
27
+ "@types/jsonwebtoken": "^9.0.10",
28
+ "@types/mongoose": "^5.11.96",
29
+ "@types/nodemailer": "^7.0.9",
30
+ "bcrypt": "^6.0.0",
31
+ "cookie-parser": "^1.4.7",
32
+ "cors": "^2.8.6",
33
+ "dotenv": "^17.3.1",
34
+ "express": "^5.2.1",
35
+ "jsonwebtoken": "^9.0.3",
36
+ "mongoose": "^9.1.5",
37
+ "nodemailer": "^7.0.13"
38
+ }
39
+ }
@@ -0,0 +1,3 @@
1
+ # Public Assets
2
+
3
+ Store static files here (CSS, images, etc.)
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "exclude": ["node_modules"]
4
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "rootDir": "./src",
4
+ "outDir": "./dist",
5
+ "module": "nodenext",
6
+ "target": "esnext",
7
+ "types": [],
8
+ "sourceMap": true,
9
+ "declaration": true,
10
+ "declarationMap": true,
11
+ "emitDeclarationOnly": false,
12
+ "noUncheckedIndexedAccess": true,
13
+ "exactOptionalPropertyTypes": true,
14
+ "strict": true,
15
+ "jsx": "react-jsx",
16
+ "verbatimModuleSyntax": true,
17
+ "isolatedModules": true,
18
+ "noUncheckedSideEffectImports": true,
19
+ "moduleDetection": "force",
20
+ "skipLibCheck": true
21
+ },
22
+ "include": ["src/**/*"],
23
+ "exclude": ["node_modules", "dist"]
24
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "lib": ["ES2020"],
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "resolveJsonModule": true
13
+ },
14
+ "include": ["src/**/*"],
15
+ "exclude": ["node_modules"]
16
+ }