nodejs-quickstart-structure 1.17.0 → 1.18.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/CHANGELOG.md +15 -0
- package/README.md +144 -135
- package/bin/index.js +3 -1
- package/lib/generator.js +3 -2
- package/lib/modules/config-files.js +27 -3
- package/lib/prompts.js +16 -1
- package/package.json +14 -2
- package/templates/clean-architecture/ts/src/index.ts.ejs +1 -2
- package/templates/common/.gitlab-ci.yml.ejs +44 -3
- package/templates/common/Dockerfile +12 -2
- package/templates/common/Jenkinsfile.ejs +26 -21
- package/templates/common/README.md.ejs +15 -5
- package/templates/common/SECURITY.md +20 -0
- package/templates/common/_github/workflows/{ci.yml → ci.yml.ejs} +9 -6
- package/templates/common/_github/workflows/security.yml.ejs +36 -0
- package/templates/common/_husky/pre-commit +4 -0
- package/templates/common/docker-compose.yml.ejs +1 -1
- package/templates/common/kafka/js/config/kafka.js +2 -1
- package/templates/common/kafka/js/config/kafka.spec.js.ejs +6 -0
- package/templates/common/kafka/ts/config/kafka.spec.ts.ejs +6 -0
- package/templates/common/kafka/ts/config/kafka.ts +2 -1
- package/templates/common/package.json.ejs +6 -3
- package/templates/common/sonar-project.properties.ejs +27 -0
- package/templates/mvc/js/src/index.js.ejs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,21 @@ 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.18.0] - 2026-03-25
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Enterprise-Grade Security Hardening**: Integrated **Snyk (SCA)** and **SonarQube (SAST)** into the project scaffolding, providing "Big Tech" industry-standard security analysis out of the box.
|
|
12
|
+
- **Automated Security Workflows**: Pre-configured CI/CD stages for security scanning across GitHub Actions, GitLab CI, and Jenkins.
|
|
13
|
+
- **Pre-commit Security Gates**: Integrated **Husky** and **lint-staged** to automatically enforce code quality and security standards locally before every commit.
|
|
14
|
+
- **Security Standard Enforcement**: Added a standardized `SECURITY.md` policy and automated quality gates to ensure code resilience.
|
|
15
|
+
- **Comprehensive Security Guide**: Created a new documentation guide detailing the setup and operational workflows for the enterprise security features.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- **Matrix Expansion**: Updated the CLI to support over **1,680+ project combinations** by adding a conditional security hardening layer across all CI/CD providers.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
- **Docker Node Version**: Updated Docker node version to 22.22.2-trixie-slim
|
|
22
|
+
|
|
8
23
|
## [1.17.0] - 2026-03-23
|
|
9
24
|
|
|
10
25
|
### Added
|
package/README.md
CHANGED
|
@@ -1,135 +1,144 @@
|
|
|
1
|
-
# Node.js Quickstart Generator
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/nodejs-quickstart-structure)
|
|
4
|
-
[](https://www.npmjs.com/package/nodejs-quickstart-structure)
|
|
6
|
-
[](https://opensource.org/licenses/ISC)
|
|
7
|
-
|
|
8
|
-
A powerful CLI tool to scaffold production-ready Node.js microservices with built-in best practices, allowing you to choose between **MVC** or **Clean Architecture**, **JavaScript** or **TypeScript**, and your preferred database.
|
|
9
|
-
|
|
10
|
-

|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
#
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
##
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
1
|
+
# Node.js Quickstart Generator
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/nodejs-quickstart-structure)
|
|
4
|
+
[](https://www.npmjs.com/package/nodejs-quickstart-structure)
|
|
5
|
+
[](https://www.npmjs.com/package/nodejs-quickstart-structure)
|
|
6
|
+
[](https://opensource.org/licenses/ISC)
|
|
7
|
+
|
|
8
|
+
A powerful CLI tool to scaffold production-ready Node.js microservices with built-in best practices, allowing you to choose between **MVC** or **Clean Architecture**, **JavaScript** or **TypeScript**, and your preferred database.
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 📌 Table of Contents
|
|
15
|
+
|
|
16
|
+
- [🚀 Quick Start](#-quick-start)
|
|
17
|
+
- [✨ Key Features](#-key-features)
|
|
18
|
+
- [🛡️ Professional Standards](#-professional-standards)
|
|
19
|
+
- [🧩 1,680+ Project Combinations](#-1680-project-combinations)
|
|
20
|
+
- [⚙️ Configuration Options](#-configuration-options)
|
|
21
|
+
- [🏗️ Generated Project Structure](#-generated-project-structure)
|
|
22
|
+
- [📖 Documentation](#-documentation)
|
|
23
|
+
- [🗺️ Roadmap & Support](#️-roadmap--support)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 🚀 Quick Start
|
|
28
|
+
|
|
29
|
+
Generate your professional Node.js project in seconds without installing anything globally:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx nodejs-quickstart-structure@latest init
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Installation (Optional)
|
|
36
|
+
|
|
37
|
+
If you prefer to install it globally:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install -g nodejs-quickstart-structure
|
|
41
|
+
# Then run:
|
|
42
|
+
nodejs-quickstart init
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## ✨ Key Features
|
|
48
|
+
|
|
49
|
+
- **Interactive CLI**: Smooth, guided configuration process.
|
|
50
|
+
- **Multiple Architectures**: Supports both **MVC** and **Clean Architecture**.
|
|
51
|
+
- **Modern Languages**: Choice of **JavaScript** or **TypeScript**.
|
|
52
|
+
- **Database Ready**: Pre-configured for **MySQL**, **PostgreSQL**, or **MongoDB**.
|
|
53
|
+
- **Communication Patterns**: Supports **REST**, **GraphQL** (Apollo), and **Kafka** (Event-driven).
|
|
54
|
+
- **Multi-layer Caching**: Integrated **Redis** or built-in **Memory Cache**.
|
|
55
|
+
- **AI-Native Optimized**: specifically designed for **Cursor** and AI agents, including built-in `.cursorrules` and Agent Skill prompts. 🚀
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 🛡️ Professional Standards
|
|
60
|
+
|
|
61
|
+
We don't just generate boilerplate; we generate **production-ready** foundations. Every project includes:
|
|
62
|
+
|
|
63
|
+
- **🔍 Code Quality**: Pre-configured `Eslint` and `Prettier`.
|
|
64
|
+
- **🛡️ Enterprise Security**: Integrated **Snyk (SCA)**, **SonarCloud (SAST)**, `Helmet`, `HPP`, and Rate-Limiting.
|
|
65
|
+
- **🚨 Robust Error Handling**: Centralized global error middleware with custom error classes (`ApiError`, `NotFoundError`, etc.) — consistent across REST & GraphQL.
|
|
66
|
+
- **🧪 Testing Excellence**: Integrated `Jest` and `Supertest` with **>80% Unit Test coverage** out of the box.
|
|
67
|
+
- **🔄 DevOps & CI/CD**: Optimized **Multi-Stage Dockerfiles**, health checks, infrastructure retry logic, and workflows for **GitHub Actions**, **Jenkins**, and **GitLab CI**.
|
|
68
|
+
- **🚀 Scalable Deployment**: Integrated **PM2 Ecosystem** config for zero-downtime reloads.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 🧩 1,680+ Project Combinations
|
|
73
|
+
|
|
74
|
+
The CLI supports a massive number of configurations to fit your exact needs:
|
|
75
|
+
|
|
76
|
+
- **240 Core Combinations**:
|
|
77
|
+
- **MVC Architecture**: 180 variants (Languages × View Engines × Databases × Communication Patterns × Caching)
|
|
78
|
+
- **Clean Architecture**: 60 variants (Languages × Databases × Communication Patterns × Caching)
|
|
79
|
+
- **1,680+ Total Scenarios**:
|
|
80
|
+
- Every combination can be generated across 3 CI/CD providers.
|
|
81
|
+
- Optional **Enterprise-Grade Security Hardening** doubles the scenarios.
|
|
82
|
+
- Every single scenario is verified to be compatible with our **80% Coverage Threshold** policy.
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## ⚙️ Configuration Options
|
|
87
|
+
|
|
88
|
+
The CLI will guide you through:
|
|
89
|
+
1. **Project Name**
|
|
90
|
+
2. **Language**: `JavaScript` | `TypeScript`
|
|
91
|
+
3. **Architecture**: `MVC` | `Clean Architecture`
|
|
92
|
+
4. **View Engine**: (MVC only) `None` | `EJS` | `Pug`
|
|
93
|
+
5. **Database**: `MySQL` | `PostgreSQL` | `MongoDB`
|
|
94
|
+
6. **Communication**: `REST` | `GraphQL` | `Kafka`
|
|
95
|
+
7. **Caching**: `None` | `Redis` | `Memory Cache`
|
|
96
|
+
8. **CI/CD**: `GitHub Actions` | `Jenkins` | `GitLab CI`
|
|
97
|
+
9. **Security**: (Optional) Snyk & SonarCloud Hardening
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 🏗️ Generated Project Structure
|
|
102
|
+
|
|
103
|
+
A typical generated project (TypeScript + Clean Architecture) looks like this:
|
|
104
|
+
|
|
105
|
+
```text
|
|
106
|
+
.
|
|
107
|
+
├── src/
|
|
108
|
+
│ ├── application/ # Use cases & Business logic
|
|
109
|
+
│ ├── domain/ # Entities & Repository interfaces
|
|
110
|
+
│ ├── infrastructure/ # DB, External services, Repositories
|
|
111
|
+
│ ├── interfaces/ # Controllers, Routes, GraphQL, Kafka
|
|
112
|
+
│ ├── errors/ # Custom Error Classes
|
|
113
|
+
│ └── index.ts # Entry point
|
|
114
|
+
├── flyway/sql/ # SQL migrations (if applicable)
|
|
115
|
+
├── docker-compose.yml # Infrastructure services
|
|
116
|
+
├── package.json # Scripts and dependencies
|
|
117
|
+
├── tsconfig.json # TypeScript config
|
|
118
|
+
└── .cursorrules # AI assistance rules
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 📖 Documentation
|
|
124
|
+
|
|
125
|
+
For full guides, architecture deep-dives, and feature references, visit our **[Official Documentation Site](https://paudang.github.io/nodejs-quickstart-structure/)**.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## ❤️ Support & 🗺️ Roadmap
|
|
130
|
+
|
|
131
|
+
### Support the Project
|
|
132
|
+
We just hit **3,000+ downloads**! If this tool helped you, please:
|
|
133
|
+
- Give us a ⭐ on [GitHub](https://github.com/paudang/nodejs-quickstart-structure).
|
|
134
|
+
- Read our [Medium Article](https://medium.com/@paudang/nodejs-quickstart-generator-93c276d60e0b) for tutorials.
|
|
135
|
+
|
|
136
|
+
### Roadmap
|
|
137
|
+
Track our progress and vote for features on our public board:
|
|
138
|
+
👉 **[View our Public Roadmap on Trello](https://trello.com/b/TPTo8ylF/nodejs-quickstart-structure-product)**
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
ISC
|
package/bin/index.js
CHANGED
|
@@ -29,7 +29,8 @@ program
|
|
|
29
29
|
.option('-d, --database <database>', 'Database (MySQL, PostgreSQL)')
|
|
30
30
|
.option('--db-name <name>', 'Database name')
|
|
31
31
|
.option('-c, --communication <communication>', 'Communication (REST APIs, GraphQL, Kafka)')
|
|
32
|
-
.option('--ci-provider <provider>', 'CI/CD Provider (None, GitHub Actions, Jenkins)')
|
|
32
|
+
.option('--ci-provider <provider>', 'CI/CD Provider (None, GitHub Actions, Jenkins, GitLab CI)')
|
|
33
|
+
.option('--include-security', 'Include Enterprise Security Hardening')
|
|
33
34
|
.option('--caching <type>', 'Caching Layer (None/Redis)')
|
|
34
35
|
.action(async (options) => {
|
|
35
36
|
// Fix for Commander camelCase conversion
|
|
@@ -83,6 +84,7 @@ program
|
|
|
83
84
|
process.exit(1);
|
|
84
85
|
}
|
|
85
86
|
});
|
|
87
|
+
|
|
86
88
|
program.parse(process.argv);
|
|
87
89
|
|
|
88
90
|
if (!process.argv.slice(2).length) {
|
package/lib/generator.js
CHANGED
|
@@ -16,9 +16,10 @@ export const generateProject = async (config) => {
|
|
|
16
16
|
viewEngine: 'None',
|
|
17
17
|
caching: 'None',
|
|
18
18
|
dbName: 'demo',
|
|
19
|
-
ciProvider: '
|
|
19
|
+
ciProvider: 'GitHub Actions',
|
|
20
20
|
communication: 'REST APIs',
|
|
21
21
|
database: 'None',
|
|
22
|
+
includeSecurity: false,
|
|
22
23
|
...config
|
|
23
24
|
};
|
|
24
25
|
|
|
@@ -112,7 +113,7 @@ export const generateProject = async (config) => {
|
|
|
112
113
|
----------------------------------------------------
|
|
113
114
|
✅ Linting & Formatting: Eslint + Prettier configured
|
|
114
115
|
✅ Git Hooks: Husky + Lint-Staged ready
|
|
115
|
-
✅ Security: Helmet, CORS, Rate-Limiting added
|
|
116
|
+
✅ Security: Helmet, CORS, Rate-Limiting added${config.includeSecurity ? '\n ✅ Enterprise Security: Snyk (SCA) & SonarCloud (SAST) integration' : ''}
|
|
116
117
|
✅ Testing: Jest setup for Unit/Integration tests
|
|
117
118
|
✅ Docker: Production-ready multi-stage build
|
|
118
119
|
${config.ciProvider !== 'None' ? `✅ CI/CD: ${config.ciProvider} Workflow ready` : '❌ CI/CD: Skipped (User preferred)'}
|
|
@@ -52,6 +52,20 @@ export const renderProfessionalConfig = async (templatesDir, targetDir, config)
|
|
|
52
52
|
const jestE2eTemplate = await fs.readFile(path.join(templatesDir, 'common', 'jest.e2e.config.js.ejs'), 'utf-8');
|
|
53
53
|
const jestE2eContent = ejs.render(jestE2eTemplate, { ...config });
|
|
54
54
|
await fs.writeFile(path.join(targetDir, 'jest.e2e.config.js'), jestE2eContent);
|
|
55
|
+
|
|
56
|
+
// 1. Setup Husky pre-commit (Always for Professional Standard)
|
|
57
|
+
const huskyDir = path.join(targetDir, '.husky');
|
|
58
|
+
await fs.ensureDir(huskyDir);
|
|
59
|
+
await fs.copy(path.join(templatesDir, 'common', '_husky', 'pre-commit'), path.join(huskyDir, 'pre-commit'));
|
|
60
|
+
|
|
61
|
+
// 2. Enterprise Security Hardening (Optional)
|
|
62
|
+
if (config.includeSecurity) {
|
|
63
|
+
await fs.copy(path.join(templatesDir, 'common', 'SECURITY.md'), path.join(targetDir, 'SECURITY.md'));
|
|
64
|
+
|
|
65
|
+
const sonarTemplate = await fs.readFile(path.join(templatesDir, 'common', 'sonar-project.properties.ejs'), 'utf-8');
|
|
66
|
+
const sonarContent = ejs.render(sonarTemplate, { ...config });
|
|
67
|
+
await fs.writeFile(path.join(targetDir, 'sonar-project.properties'), sonarContent);
|
|
68
|
+
}
|
|
55
69
|
};
|
|
56
70
|
|
|
57
71
|
export const renderAiNativeFiles = async (templatesDir, targetDir, config) => {
|
|
@@ -80,10 +94,20 @@ export const renderAiNativeFiles = async (templatesDir, targetDir, config) => {
|
|
|
80
94
|
};
|
|
81
95
|
|
|
82
96
|
export const setupCiCd = async (templatesDir, targetDir, config) => {
|
|
83
|
-
const { ciProvider } = config;
|
|
97
|
+
const { ciProvider, includeSecurity } = config;
|
|
84
98
|
if (ciProvider === 'GitHub Actions') {
|
|
85
|
-
|
|
86
|
-
await fs.
|
|
99
|
+
const workflowsDir = path.join(targetDir, '.github/workflows');
|
|
100
|
+
await fs.ensureDir(workflowsDir);
|
|
101
|
+
|
|
102
|
+
const ciTemplate = await fs.readFile(path.join(templatesDir, 'common', '_github/workflows/ci.yml.ejs'), 'utf-8');
|
|
103
|
+
const ciContent = ejs.render(ciTemplate, { ...config });
|
|
104
|
+
await fs.writeFile(path.join(workflowsDir, 'ci.yml'), ciContent);
|
|
105
|
+
|
|
106
|
+
if (includeSecurity) {
|
|
107
|
+
const securityTemplate = await fs.readFile(path.join(templatesDir, 'common', '_github/workflows/security.yml.ejs'), 'utf-8');
|
|
108
|
+
const securityContent = ejs.render(securityTemplate, { ...config });
|
|
109
|
+
await fs.writeFile(path.join(workflowsDir, 'security.yml'), securityContent);
|
|
110
|
+
}
|
|
87
111
|
} else if (ciProvider === 'Jenkins') {
|
|
88
112
|
const jenkinsTemplate = await fs.readFile(path.join(templatesDir, 'common', 'Jenkinsfile.ejs'), 'utf-8');
|
|
89
113
|
const jenkinsContent = ejs.render(jenkinsTemplate, { ...config });
|
package/lib/prompts.js
CHANGED
|
@@ -77,9 +77,24 @@ export const getProjectDetails = async (options = {}) => {
|
|
|
77
77
|
choices: ['None', 'GitHub Actions', 'Jenkins', 'GitLab CI'],
|
|
78
78
|
default: 'None',
|
|
79
79
|
when: !options.ciProvider
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: 'select',
|
|
83
|
+
name: 'includeSecurity',
|
|
84
|
+
message: 'Include Enterprise Security Hardening (Big Tech Standard: Snyk, SonarQube)?',
|
|
85
|
+
choices: ['No', 'Yes'],
|
|
86
|
+
default: "No",
|
|
87
|
+
when: (answers) => !options.includeSecurity && (options.ciProvider || answers.ciProvider) !== 'None'
|
|
80
88
|
}
|
|
81
89
|
];
|
|
82
90
|
|
|
83
91
|
const answers = await inquirer.prompt(questions);
|
|
84
|
-
|
|
92
|
+
const result = { ...options, ...answers };
|
|
93
|
+
|
|
94
|
+
// Normalize includeSecurity to boolean if it's a string from the select prompt
|
|
95
|
+
if (typeof result.includeSecurity === 'string') {
|
|
96
|
+
result.includeSecurity = result.includeSecurity === 'Yes';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return result;
|
|
85
100
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodejs-quickstart-structure",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The ultimate nodejs quickstart structure CLI to scaffold Node.js microservices with MVC or Clean Architecture",
|
|
6
6
|
"main": "bin/index.js",
|
|
@@ -12,7 +12,12 @@
|
|
|
12
12
|
"test:e2e": "npm run test:e2e:windows",
|
|
13
13
|
"test:e2e:windows": "node scripts/validate-windows.js",
|
|
14
14
|
"test:e2e:linux": "node scripts/validate-linux.js",
|
|
15
|
-
"test:verify:mongo": "node scripts/verify-migration.js"
|
|
15
|
+
"test:verify:mongo": "node scripts/verify-migration.js",
|
|
16
|
+
"docs:dev": "vitepress dev docs",
|
|
17
|
+
"docs:build": "vitepress build docs",
|
|
18
|
+
"docs:preview": "vitepress preview docs",
|
|
19
|
+
"security:check": "npm audit && npm run snyk:test",
|
|
20
|
+
"snyk:test": "snyk test"
|
|
16
21
|
},
|
|
17
22
|
"keywords": [
|
|
18
23
|
"nodejs",
|
|
@@ -45,6 +50,13 @@
|
|
|
45
50
|
"fs-extra": "^11.3.0",
|
|
46
51
|
"inquirer": "^13.3.2"
|
|
47
52
|
},
|
|
53
|
+
"overrides": {
|
|
54
|
+
"esbuild": "^0.25.0"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"snyk": "^1.1303.2",
|
|
58
|
+
"vitepress": "^1.0.0-rc.45"
|
|
59
|
+
},
|
|
48
60
|
"files": [
|
|
49
61
|
"bin",
|
|
50
62
|
"lib",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { env } from '@/config/env';
|
|
1
2
|
import express from 'express';
|
|
2
3
|
import cors from 'cors';
|
|
3
4
|
import helmet from 'helmet';
|
|
@@ -23,8 +24,6 @@ import { typeDefs, resolvers } from '@/interfaces/graphql';
|
|
|
23
24
|
import { gqlContext, MyContext } from '@/interfaces/graphql/context';
|
|
24
25
|
<%_ } -%>
|
|
25
26
|
|
|
26
|
-
import { env } from '@/config/env';
|
|
27
|
-
|
|
28
27
|
const app = express();
|
|
29
28
|
const port = env.PORT;
|
|
30
29
|
|
|
@@ -4,6 +4,10 @@ variables:
|
|
|
4
4
|
stages:
|
|
5
5
|
- lint
|
|
6
6
|
- test
|
|
7
|
+
<% if (includeSecurity) { %>
|
|
8
|
+
- security
|
|
9
|
+
- quality
|
|
10
|
+
<% } %>
|
|
7
11
|
- build
|
|
8
12
|
|
|
9
13
|
cache:
|
|
@@ -12,19 +16,19 @@ cache:
|
|
|
12
16
|
|
|
13
17
|
install_dependencies:
|
|
14
18
|
stage: .pre
|
|
15
|
-
image: node:22-
|
|
19
|
+
image: node:22-slim
|
|
16
20
|
script:
|
|
17
21
|
- npm ci
|
|
18
22
|
|
|
19
23
|
lint_code:
|
|
20
24
|
stage: lint
|
|
21
|
-
image: node:22-
|
|
25
|
+
image: node:22-slim
|
|
22
26
|
script:
|
|
23
27
|
- npm run lint
|
|
24
28
|
|
|
25
29
|
run_unit_tests:
|
|
26
30
|
stage: test
|
|
27
|
-
image: node:22-
|
|
31
|
+
image: node:22-slim
|
|
28
32
|
script:
|
|
29
33
|
- npm run test:coverage
|
|
30
34
|
|
|
@@ -37,7 +41,44 @@ run_e2e_tests:
|
|
|
37
41
|
- apk add --no-cache nodejs npm docker-compose
|
|
38
42
|
- npm ci
|
|
39
43
|
- npm run test:e2e
|
|
44
|
+
<% if (includeSecurity) { %>
|
|
45
|
+
snyk_scan:
|
|
46
|
+
stage: security
|
|
47
|
+
image: node:22-alpine
|
|
48
|
+
script:
|
|
49
|
+
- npm ci
|
|
50
|
+
- npm run snyk:test
|
|
51
|
+
only:
|
|
52
|
+
- main
|
|
40
53
|
|
|
54
|
+
snyk_container_scan:
|
|
55
|
+
stage: security
|
|
56
|
+
image: docker:20.10.16
|
|
57
|
+
services:
|
|
58
|
+
- docker:20.10.16-dind
|
|
59
|
+
script:
|
|
60
|
+
- apk add --no-cache nodejs npm
|
|
61
|
+
- npm install -g snyk
|
|
62
|
+
- docker build -t <%= projectName %>:latest .
|
|
63
|
+
- snyk container test <%= projectName %>:latest --file=Dockerfile --severity-threshold=high --skip-unused-projects
|
|
64
|
+
|
|
65
|
+
sonarqube_check:
|
|
66
|
+
stage: quality
|
|
67
|
+
image:
|
|
68
|
+
name: sonarsource/sonar-scanner-cli:latest
|
|
69
|
+
entrypoint: [""]
|
|
70
|
+
variables:
|
|
71
|
+
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
|
|
72
|
+
GIT_DEPTH: "0"
|
|
73
|
+
cache:
|
|
74
|
+
key: "${CI_JOB_NAME}"
|
|
75
|
+
paths:
|
|
76
|
+
- .sonar/cache
|
|
77
|
+
script:
|
|
78
|
+
- sonar-scanner
|
|
79
|
+
only:
|
|
80
|
+
- main
|
|
81
|
+
<% } %>
|
|
41
82
|
build_app:
|
|
42
83
|
stage: build
|
|
43
84
|
image: node:22-alpine
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
# ==========================================
|
|
2
2
|
# Stage 1: Builder
|
|
3
3
|
# ==========================================
|
|
4
|
-
FROM node:22-
|
|
4
|
+
FROM node:22.22.2-trixie-slim AS builder
|
|
5
|
+
|
|
6
|
+
# Upgrade OS packages to fix upstream vulnerabilities (Snyk-detected)
|
|
7
|
+
RUN apt-get update && apt-get upgrade -y && \
|
|
8
|
+
apt-get install -y --no-install-recommends ca-certificates && \
|
|
9
|
+
rm -rf /var/lib/apt/lists/*
|
|
5
10
|
|
|
6
11
|
WORKDIR /app
|
|
7
12
|
ENV NPM_CONFIG_UPDATE_NOTIFIER=false
|
|
@@ -20,7 +25,12 @@ COPY . .
|
|
|
20
25
|
# ==========================================
|
|
21
26
|
# Stage 2: Production
|
|
22
27
|
# ==========================================
|
|
23
|
-
FROM node:22-
|
|
28
|
+
FROM node:22.22.2-trixie-slim AS production
|
|
29
|
+
|
|
30
|
+
# Upgrade OS packages to fix upstream vulnerabilities (Snyk-detected)
|
|
31
|
+
RUN apt-get update && apt-get upgrade -y && \
|
|
32
|
+
apt-get install -y --no-install-recommends ca-certificates && \
|
|
33
|
+
rm -rf /var/lib/apt/lists/*
|
|
24
34
|
|
|
25
35
|
WORKDIR /app
|
|
26
36
|
|
|
@@ -31,29 +31,34 @@ pipeline {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// withSonarQubeEnv('SonarQube') {
|
|
46
|
-
// sh "${scannerHome}/bin/sonar-scanner"
|
|
47
|
-
// }
|
|
48
|
-
// }
|
|
49
|
-
// }
|
|
34
|
+
<% if (includeSecurity) { %>
|
|
35
|
+
stage('SonarQube Analysis') {
|
|
36
|
+
environment {
|
|
37
|
+
scannerHome = tool 'SonarScanner'
|
|
38
|
+
}
|
|
39
|
+
steps {
|
|
40
|
+
withSonarQubeEnv('SonarQube') {
|
|
41
|
+
sh "${scannerHome}/bin/sonar-scanner"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
50
45
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
stage('Security Scan') {
|
|
47
|
+
steps {
|
|
48
|
+
sh 'npm audit --audit-level=high'
|
|
49
|
+
sh 'npm run snyk:test'
|
|
50
|
+
}
|
|
51
|
+
}
|
|
56
52
|
|
|
53
|
+
stage('Snyk Container Scan') {
|
|
54
|
+
steps {
|
|
55
|
+
script {
|
|
56
|
+
sh 'docker build -t <%= projectName %>:latest .'
|
|
57
|
+
sh 'snyk container test <%= projectName %>:latest --file=Dockerfile --severity-threshold=high --skip-unused-projects'
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
<% } %>
|
|
57
62
|
// stage('Docker Build & Push') {
|
|
58
63
|
// steps {
|
|
59
64
|
// script {
|
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|

|
|
4
4
|

|
|
5
5
|
<% if (language === 'TypeScript') { %><% } else { %><% } %>
|
|
6
|
+
<% if (includeSecurity) { %>
|
|
7
|
+
[](https://snyk.io/)
|
|
8
|
+
[](https://sonarcloud.io/)
|
|
9
|
+
<% } %>
|
|
6
10
|
|
|
7
11
|
A production-ready Node.js microservice generated with **<%= architecture %>** and **<%= database %>**.
|
|
8
12
|
This project comes pre-configured with industry-standard tooling for **Code Quality**, **Testing**, and **Security**.
|
|
@@ -15,6 +19,7 @@ This project comes pre-configured with industry-standard tooling for **Code Qual
|
|
|
15
19
|
- **Quality**: Eslint, Prettier, Husky, Lint-Staged.
|
|
16
20
|
- **Testing**: Jest (Unit & Integration).
|
|
17
21
|
- **DevOps**: Multi-stage Docker build, CI/CD ready.
|
|
22
|
+
<% if (includeSecurity) { %>- **Enterprise Security**: Snyk SCA, SonarCloud SAST.<% } %>
|
|
18
23
|
|
|
19
24
|
## 🔄 CI/CD Pipeline
|
|
20
25
|
<%_ if (ciProvider === 'GitHub Actions') { -%>
|
|
@@ -49,19 +54,20 @@ CI/CD is not currently configured, but the project is ready for integration.
|
|
|
49
54
|
|
|
50
55
|
### 2. Quick Start
|
|
51
56
|
```bash
|
|
52
|
-
# Initialize Git (
|
|
57
|
+
# Initialize Git (Mandatory for Husky hooks)
|
|
53
58
|
git init
|
|
54
59
|
|
|
55
60
|
# Install dependencies
|
|
56
61
|
npm install
|
|
57
62
|
|
|
58
|
-
#
|
|
59
|
-
|
|
63
|
+
# Troubleshooting Husky (if skip git init)
|
|
64
|
+
# npx husky install
|
|
60
65
|
|
|
61
66
|
# Start Infrastructure (DB, etc.)
|
|
62
67
|
docker-compose up -d
|
|
63
68
|
|
|
64
69
|
# Run Development Server
|
|
70
|
+
docker-compose up -d<% if (database !== 'None') { %> db<% } %><% if (caching === 'Redis') { %> redis<% } %><% if (communication === 'Kafka') { %> kafka<% } %>
|
|
65
71
|
npm run dev
|
|
66
72
|
```
|
|
67
73
|
|
|
@@ -241,8 +247,12 @@ docker-compose down
|
|
|
241
247
|
- **CORS**: Configured for cross-origin requests.
|
|
242
248
|
- **Rate Limiting**: Protects against DDoS / Brute-force.
|
|
243
249
|
- **HPP**: Prevents HTTP Parameter Pollution attacks.
|
|
244
|
-
|
|
245
|
-
|
|
250
|
+
<% if (includeSecurity) { %>
|
|
251
|
+
### 🛡️ Enterprise Hardening (Big Tech Standard)
|
|
252
|
+
- **Snyk SCA**: Automated dependency vulnerability scanning.
|
|
253
|
+
- **SonarCloud**: Deep static analysis for code quality and security hotspots.
|
|
254
|
+
- **Security Policy**: Standard `SECURITY.md` for vulnerability reporting.
|
|
255
|
+
<% } %>
|
|
246
256
|
## 🤖 AI-Native Development
|
|
247
257
|
|
|
248
258
|
This project is "AI-Ready" out of the box. We have pre-configured industry-leading AI context files to bridge the gap between "Generated Code" and "AI-Assisted Development."
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
Only the latest `main` branch is supported for security updates.
|
|
6
|
+
|
|
7
|
+
| Version | Supported |
|
|
8
|
+
| ------- | ------------------ |
|
|
9
|
+
| 1.0.x | :white_check_mark: |
|
|
10
|
+
| < 1.0 | :x: |
|
|
11
|
+
|
|
12
|
+
## Reporting a Vulnerability
|
|
13
|
+
|
|
14
|
+
We take the security of this project seriously. If you believe you have found a security vulnerability, please report it following these steps:
|
|
15
|
+
|
|
16
|
+
1. **Do not open a public issue.**
|
|
17
|
+
2. Send an email to the project maintainers (see `package.json`).
|
|
18
|
+
3. Provide a detailed description of the vulnerability, including steps to reproduce.
|
|
19
|
+
|
|
20
|
+
We will acknowledge your report within 48 hours and work on a fix as soon as possible.
|
|
@@ -14,17 +14,13 @@ jobs:
|
|
|
14
14
|
|
|
15
15
|
runs-on: ubuntu-latest
|
|
16
16
|
|
|
17
|
-
strategy:
|
|
18
|
-
matrix:
|
|
19
|
-
node-version: [20.x, 22.x]
|
|
20
|
-
|
|
21
17
|
steps:
|
|
22
18
|
- uses: actions/checkout@v4
|
|
23
19
|
|
|
24
|
-
- name: Use Node.js
|
|
20
|
+
- name: Use Node.js 22.x
|
|
25
21
|
uses: actions/setup-node@v4
|
|
26
22
|
with:
|
|
27
|
-
node-version:
|
|
23
|
+
node-version: 22.x
|
|
28
24
|
cache: 'npm'
|
|
29
25
|
|
|
30
26
|
- name: Install Dependencies
|
|
@@ -41,3 +37,10 @@ jobs:
|
|
|
41
37
|
|
|
42
38
|
- name: Build
|
|
43
39
|
run: npm run build --if-present
|
|
40
|
+
<% if (includeSecurity) { %>
|
|
41
|
+
- name: SonarQube Scan
|
|
42
|
+
uses: SonarSource/sonarqube-scan-action@master
|
|
43
|
+
env:
|
|
44
|
+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
45
|
+
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
|
|
46
|
+
<% } %>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Enterprise Security Scan
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ "main" ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ "main" ]
|
|
8
|
+
schedule:
|
|
9
|
+
- cron: '0 0 * * 1' # Weekly scan
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
node-security:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Run Snyk to check for vulnerabilities
|
|
18
|
+
uses: snyk/actions/node@master
|
|
19
|
+
env:
|
|
20
|
+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
|
21
|
+
with:
|
|
22
|
+
args: --severity-threshold=high
|
|
23
|
+
|
|
24
|
+
container-security:
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v4
|
|
28
|
+
- name: Build Docker image
|
|
29
|
+
run: docker build -t <%= projectName %>:latest .
|
|
30
|
+
- name: Run Snyk to check Docker image for vulnerabilities
|
|
31
|
+
uses: snyk/actions/docker@master
|
|
32
|
+
env:
|
|
33
|
+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
|
34
|
+
with:
|
|
35
|
+
image: <%= projectName %>:latest
|
|
36
|
+
args: --file=Dockerfile --severity-threshold=high --skip-unused-projects
|
|
@@ -9,6 +9,12 @@ jest.mock('kafkajs', () => {
|
|
|
9
9
|
};
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
+
jest.mock('<% if (architecture === "MVC") { %>@/config/env<% } else { %>@/infrastructure/config/env<% } %>', () => ({
|
|
13
|
+
env: {
|
|
14
|
+
KAFKA_BROKER: 'localhost:9092'
|
|
15
|
+
}
|
|
16
|
+
}));
|
|
17
|
+
|
|
12
18
|
describe('Kafka Configuration', () => {
|
|
13
19
|
beforeEach(() => {
|
|
14
20
|
jest.clearAllMocks();
|
|
@@ -11,14 +11,16 @@
|
|
|
11
11
|
"lint": "eslint .",
|
|
12
12
|
"lint:fix": "eslint . --fix",
|
|
13
13
|
"format": "prettier --write .",
|
|
14
|
-
"prepare": "node -e \"try { require('child_process').execSync('husky install'); } catch (e) { console.
|
|
14
|
+
"prepare": "node -e \"if (require('fs').existsSync('.git')) { try { require('child_process').execSync('husky install', { stdio: 'inherit' }); } catch (e) { console.error('Husky installation failed:', e.message); } }\"",
|
|
15
15
|
<% if (database === 'MongoDB') { %> "migrate": "migrate-mongo up",
|
|
16
16
|
<% } -%>
|
|
17
17
|
"test": "jest",
|
|
18
18
|
"test:watch": "jest --watch",
|
|
19
19
|
"test:coverage": "jest --coverage",
|
|
20
20
|
"test:e2e:run": "jest --config ./jest.e2e.config.js --passWithNoTests",
|
|
21
|
-
"test:e2e": "node scripts/run-e2e.js"
|
|
21
|
+
"test:e2e": "node scripts/run-e2e.js"<% if (includeSecurity) { %>,
|
|
22
|
+
"security:check": "npm audit && npm run snyk:test",
|
|
23
|
+
"snyk:test": "snyk test"<% } %>
|
|
22
24
|
},
|
|
23
25
|
"dependencies": {
|
|
24
26
|
"express": "^4.18.2",
|
|
@@ -82,7 +84,8 @@
|
|
|
82
84
|
"eslint-plugin-import-x": "^4.6.1",
|
|
83
85
|
"eslint-import-resolver-typescript": "^3.7.0",
|
|
84
86
|
"husky": "^8.0.3",
|
|
85
|
-
"lint-staged": "^15.4.3"
|
|
87
|
+
"lint-staged": "^15.4.3",
|
|
88
|
+
"snyk": "^1.1295.0"<% if (language === 'TypeScript') { %>,
|
|
86
89
|
"typescript-eslint": "^8.24.1",<%_ if (communication === 'REST APIs' || communication === 'Kafka') { %>
|
|
87
90
|
"@types/swagger-ui-express": "^4.1.6",
|
|
88
91
|
"@types/yamljs": "^0.2.34",<%_ } %>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# SonarCloud/SonarQube Project Configuration
|
|
2
|
+
# See https://docs.sonarqube.org/latest/analysis/analysis-parameters/
|
|
3
|
+
|
|
4
|
+
sonar.projectKey=your-org-key_<%= projectName %>
|
|
5
|
+
sonar.projectName=<%= projectName %>
|
|
6
|
+
sonar.organization=your-org-key
|
|
7
|
+
sonar.projectVersion=1.0.0
|
|
8
|
+
|
|
9
|
+
# Path to the source directories
|
|
10
|
+
sonar.sources=src
|
|
11
|
+
# Path to the test directories
|
|
12
|
+
sonar.tests=tests
|
|
13
|
+
|
|
14
|
+
# Language specific settings
|
|
15
|
+
sonar.javascript.environments=node
|
|
16
|
+
sonar.typescript.tsconfigPath=tsconfig.json
|
|
17
|
+
sonar.javascript.lcov.reportPaths=coverage/lcov.info
|
|
18
|
+
|
|
19
|
+
# Exclusions
|
|
20
|
+
sonar.exclusions=node_modules/**, dist/**, coverage/**, tests/**
|
|
21
|
+
|
|
22
|
+
# Quality Gates
|
|
23
|
+
sonar.qualitygate.wait=true
|
|
24
|
+
sonar.qualitygate.timeout=300
|
|
25
|
+
|
|
26
|
+
# Security Hotspots
|
|
27
|
+
sonar.security.reportPaths=snyk-report.json
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { env } = require('./config/env');
|
|
1
2
|
const express = require('express');
|
|
2
3
|
const cors = require('cors');
|
|
3
4
|
<%_ if (communication === 'REST APIs' || communication === 'Kafka') { -%>const apiRoutes = require('./routes/api');<%_ } %>
|
|
@@ -16,7 +17,6 @@ const { gqlContext } = require('./graphql/context');
|
|
|
16
17
|
const swaggerUi = require('swagger-ui-express');
|
|
17
18
|
const swaggerSpecs = require('./config/swagger');
|
|
18
19
|
<%_ } -%>
|
|
19
|
-
const { env } = require('./config/env');
|
|
20
20
|
const setupGracefulShutdown = require('./utils/gracefulShutdown');
|
|
21
21
|
|
|
22
22
|
const app = express();
|