nodejs-quickstart-structure 1.9.1 → 1.9.2

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/CHANGELOG.md CHANGED
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.9.2] - 2026-02-23
9
+ ### Fixed
10
+ - Fixed an issue where the generator output misleading instructions (`DATABASE_URL`) for standalone `docker run` executions. The CLI success commands and `README.md` now conditionally include dynamic compose network bindings (`--network`) and accurate environment variables matching the user's selected DB stack.
11
+ - Fixed a bug where `DB_PASSWORD` in `database.ts.ejs` and `database.js.ejs` defaulted to `postgres` instead of `root` for PostgreSQL configurations, causing standalone Node local servers (`npm run dev`) to fail connection handshakes with default `docker-compose` clusters.
12
+
8
13
  ## [1.9.1] - 2026-02-22
9
14
  ### Added
10
15
  - Implemented **Daily Template Vulnerability Audit** via GitHub Actions (`.github/workflows/daily-audit.yml`). A custom script now parses `package.json.ejs` daily to proactively scan for high-severity vulnerabilities in generated dependencies, ensuring generated projects are eternally secure.
package/bin/index.js CHANGED
@@ -51,7 +51,23 @@ program
51
51
  await generateProject(answers);
52
52
 
53
53
  console.log(chalk.green('\nāœ” Project generated successfully!'));
54
- console.log(chalk.cyan(`\nNext steps:\n cd ${answers.projectName}\n npm install\n docker-compose up\n-----------------------\nStart the app manually:\n cd ${answers.projectName}\n npm install\n npm run dev`));
54
+
55
+ let manualStartInstructions = `\nStart the app manually:\n cd ${answers.projectName}\n npm install`;
56
+
57
+ const needsInfrastructure = answers.database !== 'None' || answers.caching === 'Redis' || answers.communication === 'Kafka';
58
+
59
+ if (needsInfrastructure) {
60
+ let servicesToStart = '';
61
+ if (answers.database !== 'None') servicesToStart += ' db';
62
+ if (answers.caching === 'Redis') servicesToStart += ' redis';
63
+ if (answers.communication === 'Kafka') servicesToStart += ' zookeeper kafka';
64
+
65
+ manualStartInstructions += `\n docker-compose up -d${servicesToStart} # Start infrastructure first\n npm run dev`;
66
+ } else {
67
+ manualStartInstructions += `\n npm run dev`;
68
+ }
69
+
70
+ console.log(chalk.cyan(`\nNext steps:\n cd ${answers.projectName}\n npm install\n docker-compose up\n-----------------------${manualStartInstructions}`));
55
71
 
56
72
  } catch (error) {
57
73
  console.error(chalk.red('Error generating project:'), error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodejs-quickstart-structure",
3
- "version": "1.9.1",
3
+ "version": "1.9.2",
4
4
  "type": "module",
5
5
  "description": "A CLI to scaffold Node.js microservices with MVC or Clean Architecture",
6
6
  "main": "bin/index.js",
@@ -111,13 +111,50 @@ This project uses **Winston** for structured logging.
111
111
  ## 🐳 Docker Deployment
112
112
  This project uses a **Multi-Stage Dockerfile** for optimized production images.
113
113
 
114
+ <% if (database !== 'None' || caching === 'Redis' || communication === 'Kafka') { -%>
115
+ ### 1. Running Locally (Development)
116
+ To run the Node.js application locally while using Docker for the infrastructure (Database, Redis, Kafka, etc.):
117
+
118
+ ```bash
119
+ # Start infrastructure
120
+ docker-compose up -d<% if (database !== 'None') { %> db<% } %><% if (caching === 'Redis') { %> redis<% } %><% if (communication === 'Kafka') { %> zookeeper kafka<% } %>
121
+
122
+ # Start the application
123
+ npm run dev
124
+ ```
125
+
126
+ ### 2. Running the App Container with Compose Infrastructure
127
+ If you want to run the application itself inside a Docker container while connecting to the infrastructure managed by your `docker-compose.yml`:
128
+
129
+ ```bash
130
+ # First, ensure your infrastructure is running
131
+ docker-compose up -d
132
+
133
+ # Build Production Image
134
+ docker build -t <%= projectName %> .
135
+
136
+ # Run Container (attached to the compose network)
137
+ docker run -p 3000:3000 --network <%= projectName %>_default \
138
+ <% if (database !== 'None') { -%>
139
+ -e DB_HOST=db \
140
+ <% } -%>
141
+ <% if (caching === 'Redis') { -%>
142
+ -e REDIS_HOST=redis \
143
+ <% } -%>
144
+ <% if (communication === 'Kafka') { -%>
145
+ -e KAFKA_BROKER=kafka:29092 \
146
+ <% } -%>
147
+ <%= projectName %>
148
+ ```
149
+ <% } else { -%>
114
150
  ```bash
115
151
  # Build Production Image
116
152
  docker build -t <%= projectName %> .
117
153
 
118
154
  # Run Container
119
- docker run -p 3000:3000 -e DATABASE_URL=... <%= projectName %>
155
+ docker run -p 3000:3000 <%= projectName %>
120
156
  ```
157
+ <% } -%>
121
158
 
122
159
  ## šŸ”’ Security Features
123
160
  - **Helmet**: Sets secure HTTP headers.
@@ -1,14 +1,13 @@
1
1
  const { Sequelize } = require('sequelize');
2
2
  require('dotenv').config();
3
3
 
4
- // Determine dialect
5
4
  <% if (database === 'MySQL') { %>const dialect = 'mysql';<% } -%>
6
5
  <% if (database === 'PostgreSQL') { %>const dialect = 'postgres';<% } -%>
7
6
 
8
7
  const sequelize = new Sequelize(
9
8
  process.env.DB_NAME || '<%= dbName %>',
10
9
  process.env.DB_USER || '<% if (database === 'MySQL') { %>root<% } else { %>postgres<% } %>',
11
- process.env.DB_PASSWORD || '<% if (database === 'MySQL') { %>root<% } else { %>postgres<% } %>',
10
+ process.env.DB_PASSWORD || '<% if (database === 'MySQL') { %>root<% } else { %>root<% } %>',
12
11
  {
13
12
  host: process.env.DB_HOST || '127.0.0.1',
14
13
  dialect: dialect,
@@ -3,14 +3,13 @@ import dotenv from 'dotenv';
3
3
 
4
4
  dotenv.config();
5
5
 
6
- // Determine dialect
7
6
  <% if (database === 'MySQL') { %>const dialect = 'mysql';<% } -%>
8
7
  <% if (database === 'PostgreSQL') { %>const dialect = 'postgres';<% } -%>
9
8
 
10
9
  const sequelize = new Sequelize(
11
10
  process.env.DB_NAME || '<%= dbName %>',
12
11
  process.env.DB_USER || '<% if (database === 'MySQL') { %>root<% } else { %>postgres<% } %>',
13
- process.env.DB_PASSWORD || '<% if (database === 'MySQL') { %>root<% } else { %>postgres<% } %>',
12
+ process.env.DB_PASSWORD || '<% if (database === 'MySQL') { %>root<% } else { %>root<% } %>',
14
13
  {
15
14
  host: process.env.DB_HOST || '127.0.0.1',
16
15
  dialect: dialect,