nodejs-quickstart-structure 1.17.0 → 1.18.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/CHANGELOG.md +25 -4
- package/README.md +144 -135
- package/bin/index.js +93 -90
- package/lib/generator.js +4 -3
- package/lib/modules/config-files.js +31 -3
- package/lib/prompts.js +16 -1
- package/package.json +14 -2
- package/templates/clean-architecture/js/src/infrastructure/webserver/server.js.ejs +1 -1
- package/templates/clean-architecture/ts/src/index.ts.ejs +2 -3
- package/templates/common/.gitlab-ci.yml.ejs +44 -3
- package/templates/common/.snyk.ejs +45 -0
- package/templates/common/Dockerfile +19 -1
- package/templates/common/Jenkinsfile.ejs +26 -21
- package/templates/common/README.md.ejs +72 -54
- 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 +16 -5
- package/templates/common/sonar-project.properties.ejs +27 -0
- package/templates/mvc/js/src/index.js.ejs +2 -2
- package/templates/mvc/ts/src/index.ts.ejs +1 -1
|
@@ -11,14 +11,23 @@
|
|
|
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"<% } %>
|
|
24
|
+
},
|
|
25
|
+
"overrides": {
|
|
26
|
+
"brace-expansion": "^5.0.5",
|
|
27
|
+
"jake": "^10.9.4",
|
|
28
|
+
"micromatch": "^4.0.8",
|
|
29
|
+
"braces": "^3.0.3",
|
|
30
|
+
"picomatch": "^4.0.4"
|
|
22
31
|
},
|
|
23
32
|
"dependencies": {
|
|
24
33
|
"express": "^4.18.2",
|
|
@@ -52,7 +61,8 @@
|
|
|
52
61
|
"morgan": "^1.10.0"<% if (communication === 'REST APIs' || communication === 'Kafka') { %>,
|
|
53
62
|
"swagger-ui-express": "^5.0.0",
|
|
54
63
|
"yamljs": "^0.3.0"<% } %><% if (communication === 'GraphQL') { %>,
|
|
55
|
-
"@apollo/server": "^
|
|
64
|
+
"@apollo/server": "^5.5.0",
|
|
65
|
+
"@as-integrations/express4": "^1.1.2",
|
|
56
66
|
"graphql": "^16.8.1",
|
|
57
67
|
"@graphql-tools/merge": "^9.0.3"<% } %>
|
|
58
68
|
},
|
|
@@ -74,7 +84,7 @@
|
|
|
74
84
|
"@types/morgan": "^1.9.9",
|
|
75
85
|
"rimraf": "^6.0.1"<% if ((viewEngine && viewEngine !== 'None') || communication === 'REST APIs' || communication === 'Kafka') { %>,
|
|
76
86
|
"cpx2": "^8.0.0"<% } %><% } %>,
|
|
77
|
-
"eslint": "^
|
|
87
|
+
"eslint": "^10.1.0",
|
|
78
88
|
"@eslint/js": "^9.20.0",
|
|
79
89
|
"globals": "^15.14.0",
|
|
80
90
|
"prettier": "^3.5.1",
|
|
@@ -82,7 +92,8 @@
|
|
|
82
92
|
"eslint-plugin-import-x": "^4.6.1",
|
|
83
93
|
"eslint-import-resolver-typescript": "^3.7.0",
|
|
84
94
|
"husky": "^8.0.3",
|
|
85
|
-
"lint-staged": "^15.4.3"
|
|
95
|
+
"lint-staged": "^15.4.3",
|
|
96
|
+
"snyk": "^1.1295.0"<% if (language === 'TypeScript') { %>,
|
|
86
97
|
"typescript-eslint": "^8.24.1",<%_ if (communication === 'REST APIs' || communication === 'Kafka') { %>
|
|
87
98
|
"@types/swagger-ui-express": "^4.1.6",
|
|
88
99
|
"@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');<%_ } %>
|
|
@@ -5,7 +6,7 @@ const healthRoutes = require('./routes/healthRoute');
|
|
|
5
6
|
<%_ if (communication === 'Kafka') { -%>const { connectKafka, sendMessage } = require('./services/kafkaService');<%_ } -%>
|
|
6
7
|
<%_ if (communication === 'GraphQL') { -%>
|
|
7
8
|
const { ApolloServer } = require('@apollo/server');
|
|
8
|
-
const { expressMiddleware } = require('@
|
|
9
|
+
const { expressMiddleware } = require('@as-integrations/express4');
|
|
9
10
|
const { ApolloServerPluginLandingPageLocalDefault } = require('@apollo/server/plugin/landingPage/default');
|
|
10
11
|
const { unwrapResolverError } = require('@apollo/server/errors');
|
|
11
12
|
const { ApiError } = require('./errors/ApiError');
|
|
@@ -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();
|
|
@@ -16,7 +16,7 @@ import swaggerSpecs from '@/config/swagger';<%_ } %>
|
|
|
16
16
|
<%_ if (communication === 'Kafka') { -%>import { kafkaService } from '@/services/kafkaService';<%_ } -%>
|
|
17
17
|
<%_ if (communication === 'GraphQL') { -%>
|
|
18
18
|
import { ApolloServer } from '@apollo/server';
|
|
19
|
-
import { expressMiddleware } from '@
|
|
19
|
+
import { expressMiddleware } from '@as-integrations/express4';
|
|
20
20
|
import { ApolloServerPluginLandingPageLocalDefault } from '@apollo/server/plugin/landingPage/default';
|
|
21
21
|
import { unwrapResolverError } from '@apollo/server/errors';
|
|
22
22
|
import { ApiError } from '@/errors/ApiError';
|