nodejs-quickstart-structure 1.18.0 → 1.19.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 +17 -4
- package/README.md +2 -1
- package/bin/index.js +93 -92
- package/lib/generator.js +1 -1
- package/lib/modules/caching-setup.js +76 -73
- package/lib/modules/config-files.js +4 -0
- package/lib/modules/kafka-setup.js +249 -191
- package/lib/modules/project-setup.js +1 -0
- package/package.json +13 -2
- package/templates/clean-architecture/js/src/errors/BadRequestError.js +11 -10
- package/templates/clean-architecture/js/src/errors/BadRequestError.spec.js.ejs +22 -21
- package/templates/clean-architecture/js/src/errors/NotFoundError.js +11 -10
- package/templates/clean-architecture/js/src/errors/NotFoundError.spec.js.ejs +22 -21
- package/templates/clean-architecture/js/src/infrastructure/repositories/UserRepository.js.ejs +69 -39
- package/templates/clean-architecture/js/src/infrastructure/repositories/UserRepository.spec.js.ejs +142 -81
- package/templates/clean-architecture/js/src/infrastructure/webserver/server.js.ejs +1 -1
- package/templates/clean-architecture/js/src/interfaces/controllers/userController.js.ejs +156 -75
- package/templates/clean-architecture/js/src/interfaces/controllers/userController.spec.js.ejs +234 -138
- package/templates/clean-architecture/js/src/interfaces/graphql/resolvers/user.resolvers.js.ejs +27 -21
- package/templates/clean-architecture/js/src/interfaces/graphql/resolvers/user.resolvers.spec.js.ejs +66 -49
- package/templates/clean-architecture/js/src/interfaces/graphql/typeDefs/user.types.js.ejs +19 -17
- package/templates/clean-architecture/js/src/interfaces/routes/api.js +12 -10
- package/templates/clean-architecture/js/src/usecases/DeleteUser.js +11 -0
- package/templates/clean-architecture/js/src/usecases/DeleteUser.spec.js.ejs +47 -0
- package/templates/clean-architecture/js/src/usecases/UpdateUser.js +11 -0
- package/templates/clean-architecture/js/src/usecases/UpdateUser.spec.js.ejs +48 -0
- package/templates/clean-architecture/js/src/utils/errorMessages.js +14 -0
- package/templates/clean-architecture/ts/src/errors/BadRequestError.spec.ts.ejs +22 -21
- package/templates/clean-architecture/ts/src/errors/BadRequestError.ts +9 -8
- package/templates/clean-architecture/ts/src/errors/NotFoundError.spec.ts.ejs +22 -21
- package/templates/clean-architecture/ts/src/errors/NotFoundError.ts +9 -8
- package/templates/clean-architecture/ts/src/index.ts.ejs +1 -1
- package/templates/clean-architecture/ts/src/infrastructure/repositories/UserRepository.spec.ts.ejs +175 -85
- package/templates/clean-architecture/ts/src/infrastructure/repositories/userRepository.ts.ejs +74 -0
- package/templates/clean-architecture/ts/src/interfaces/controllers/userController.spec.ts.ejs +331 -185
- package/templates/clean-architecture/ts/src/interfaces/controllers/userController.ts.ejs +173 -84
- package/templates/clean-architecture/ts/src/interfaces/graphql/resolvers/user.resolvers.spec.ts.ejs +68 -51
- package/templates/clean-architecture/ts/src/interfaces/graphql/resolvers/user.resolvers.ts.ejs +29 -21
- package/templates/clean-architecture/ts/src/interfaces/graphql/typeDefs/user.types.ts.ejs +17 -15
- package/templates/clean-architecture/ts/src/interfaces/routes/userRoutes.ts +13 -11
- package/templates/clean-architecture/ts/src/usecases/deleteUser.spec.ts.ejs +47 -0
- package/templates/clean-architecture/ts/src/usecases/deleteUser.ts +9 -0
- package/templates/clean-architecture/ts/src/usecases/updateUser.spec.ts.ejs +48 -0
- package/templates/clean-architecture/ts/src/usecases/updateUser.ts +9 -0
- package/templates/clean-architecture/ts/src/utils/errorMessages.ts +12 -0
- package/templates/common/.gitattributes +46 -0
- package/templates/common/.snyk.ejs +45 -0
- package/templates/common/Dockerfile +17 -9
- package/templates/common/README.md.ejs +295 -263
- package/templates/common/caching/clean/js/DeleteUser.js.ejs +27 -0
- package/templates/common/caching/clean/js/UpdateUser.js.ejs +27 -0
- package/templates/common/caching/clean/ts/deleteUser.ts.ejs +24 -0
- package/templates/common/caching/clean/ts/updateUser.ts.ejs +25 -0
- package/templates/common/caching/ts/memoryCache.ts.ejs +73 -64
- package/templates/common/caching/ts/redisClient.ts.ejs +89 -80
- package/templates/common/database/js/models/User.js.ejs +79 -53
- package/templates/common/database/js/models/User.js.mongoose.ejs +23 -19
- package/templates/common/database/js/models/User.spec.js.ejs +94 -84
- package/templates/common/database/ts/models/User.spec.ts.ejs +100 -84
- package/templates/common/database/ts/models/User.ts.ejs +87 -61
- package/templates/common/database/ts/models/User.ts.mongoose.ejs +30 -25
- package/templates/common/health/js/healthRoute.js.ejs +50 -47
- package/templates/common/health/ts/healthRoute.ts.ejs +49 -46
- package/templates/common/jest.e2e.config.js.ejs +8 -8
- package/templates/common/kafka/js/messaging/baseConsumer.js.ejs +30 -30
- package/templates/common/kafka/js/messaging/userEventSchema.js.ejs +12 -11
- package/templates/common/kafka/js/messaging/welcomeEmailConsumer.js.ejs +44 -31
- package/templates/common/kafka/js/messaging/welcomeEmailConsumer.spec.js.ejs +86 -49
- package/templates/common/kafka/js/services/kafkaService.js.ejs +93 -93
- package/templates/common/kafka/js/utils/kafkaEvents.js.ejs +7 -0
- package/templates/common/kafka/ts/messaging/userEventSchema.spec.ts.ejs +51 -51
- package/templates/common/kafka/ts/messaging/userEventSchema.ts.ejs +12 -11
- package/templates/common/kafka/ts/messaging/welcomeEmailConsumer.spec.ts.ejs +86 -49
- package/templates/common/kafka/ts/messaging/welcomeEmailConsumer.ts.ejs +38 -25
- package/templates/common/kafka/ts/services/kafkaService.ts.ejs +95 -95
- package/templates/common/kafka/ts/utils/kafkaEvents.ts.ejs +5 -0
- package/templates/common/package.json.ejs +10 -2
- package/templates/common/shutdown/js/gracefulShutdown.js.ejs +65 -61
- package/templates/common/shutdown/js/gracefulShutdown.spec.js.ejs +149 -160
- package/templates/common/shutdown/ts/gracefulShutdown.spec.ts.ejs +179 -158
- package/templates/common/shutdown/ts/gracefulShutdown.ts.ejs +59 -55
- package/templates/common/src/tests/e2e/e2e.users.test.js.ejs +120 -49
- package/templates/common/src/tests/e2e/e2e.users.test.ts.ejs +120 -49
- package/templates/common/swagger.yml.ejs +118 -66
- package/templates/db/mysql/V1__Initial_Setup.sql.ejs +10 -9
- package/templates/db/postgres/V1__Initial_Setup.sql.ejs +10 -9
- package/templates/mvc/js/src/controllers/userController.js.ejs +246 -105
- package/templates/mvc/js/src/controllers/userController.spec.js.ejs +481 -209
- package/templates/mvc/js/src/errors/BadRequestError.js +11 -10
- package/templates/mvc/js/src/errors/BadRequestError.spec.js.ejs +22 -21
- package/templates/mvc/js/src/errors/NotFoundError.js +11 -10
- package/templates/mvc/js/src/errors/NotFoundError.spec.js.ejs +22 -21
- package/templates/mvc/js/src/graphql/resolvers/user.resolvers.js.ejs +25 -19
- package/templates/mvc/js/src/graphql/resolvers/user.resolvers.spec.js.ejs +64 -47
- package/templates/mvc/js/src/graphql/typeDefs/user.types.js.ejs +19 -17
- package/templates/mvc/js/src/index.js.ejs +1 -1
- package/templates/mvc/js/src/routes/api.js +10 -8
- package/templates/mvc/js/src/routes/api.spec.js.ejs +41 -36
- package/templates/mvc/js/src/utils/errorMessages.js +14 -0
- package/templates/mvc/ts/src/controllers/userController.spec.ts.ejs +481 -203
- package/templates/mvc/ts/src/controllers/userController.ts.ejs +248 -107
- package/templates/mvc/ts/src/errors/BadRequestError.spec.ts.ejs +22 -21
- package/templates/mvc/ts/src/errors/BadRequestError.ts +9 -8
- package/templates/mvc/ts/src/errors/NotFoundError.spec.ts.ejs +27 -21
- package/templates/mvc/ts/src/errors/NotFoundError.ts +9 -8
- package/templates/mvc/ts/src/graphql/resolvers/user.resolvers.spec.ts.ejs +68 -51
- package/templates/mvc/ts/src/graphql/resolvers/user.resolvers.ts.ejs +29 -21
- package/templates/mvc/ts/src/graphql/typeDefs/user.types.ts.ejs +17 -15
- package/templates/mvc/ts/src/index.ts.ejs +156 -153
- package/templates/mvc/ts/src/routes/api.spec.ts.ejs +59 -40
- package/templates/mvc/ts/src/routes/api.ts +12 -10
- package/templates/mvc/ts/src/utils/errorMessages.ts +12 -0
- package/templates/clean-architecture/ts/src/infrastructure/repositories/UserRepository.ts.ejs +0 -37
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Enforce LF endings for all text files
|
|
2
|
+
* text=auto eol=lf
|
|
3
|
+
|
|
4
|
+
# Explicitly handle common text file types
|
|
5
|
+
*.js text eol=lf
|
|
6
|
+
*.ts text eol=lf
|
|
7
|
+
*.tsx text eol=lf
|
|
8
|
+
*.jsx text eol=lf
|
|
9
|
+
*.mjs text eol=lf
|
|
10
|
+
*.cjs text eol=lf
|
|
11
|
+
*.json text eol=lf
|
|
12
|
+
*.md text eol=lf
|
|
13
|
+
*.sh text eol=lf
|
|
14
|
+
*.yml text eol=lf
|
|
15
|
+
*.yaml text eol=lf
|
|
16
|
+
*.html text eol=lf
|
|
17
|
+
*.css text eol=lf
|
|
18
|
+
*.scss text eol=lf
|
|
19
|
+
*.less text eol=lf
|
|
20
|
+
*.graphql text eol=lf
|
|
21
|
+
*.sql text eol=lf
|
|
22
|
+
*.pug text eol=lf
|
|
23
|
+
|
|
24
|
+
# Configuration files
|
|
25
|
+
.env* text eol=lf
|
|
26
|
+
.editorconfig text eol=lf
|
|
27
|
+
.prettierrc text eol=lf
|
|
28
|
+
.eslintrc* text eol=lf
|
|
29
|
+
.gitignore text eol=lf
|
|
30
|
+
.dockerignore text eol=lf
|
|
31
|
+
.gitattributes text eol=lf
|
|
32
|
+
|
|
33
|
+
# Assets
|
|
34
|
+
*.png binary
|
|
35
|
+
*.jpg binary
|
|
36
|
+
*.jpeg binary
|
|
37
|
+
*.gif binary
|
|
38
|
+
*.ico binary
|
|
39
|
+
*.webp binary
|
|
40
|
+
*.avif binary
|
|
41
|
+
*.pdf binary
|
|
42
|
+
*.woff binary
|
|
43
|
+
*.woff2 binary
|
|
44
|
+
*.ttf binary
|
|
45
|
+
*.eot binary
|
|
46
|
+
*.svg text eol=lf
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Snyk (https://snyk.io) policy file, default is to interrupt on any vulnerability found.
|
|
2
|
+
# This file ignores vulnerabilities internal to the package manager (npm) itself,
|
|
3
|
+
# as they do not affect your application's production security posture.
|
|
4
|
+
version: v1.18.2
|
|
5
|
+
ignore:
|
|
6
|
+
# Minimatch ReDoS/Complexity in npm internal dependencies
|
|
7
|
+
SNYK-JS-MINIMATCH-15353387:
|
|
8
|
+
- '*':
|
|
9
|
+
reason: Internal npm dependency, does not affect application runtime.
|
|
10
|
+
expires: '2027-03-27T10:00:00.000Z'
|
|
11
|
+
SNYK-JS-MINIMATCH-15353389:
|
|
12
|
+
- '*':
|
|
13
|
+
reason: Internal npm dependency, does not affect application runtime.
|
|
14
|
+
expires: '2027-03-27T10:00:00.000Z'
|
|
15
|
+
SNYK-JS-MINIMATCH-15309438:
|
|
16
|
+
- '*':
|
|
17
|
+
reason: Internal npm dependency, does not affect application runtime.
|
|
18
|
+
expires: '2027-03-27T10:00:00.000Z'
|
|
19
|
+
# Tar Symlink Attack in npm internal dependencies
|
|
20
|
+
SNYK-JS-TAR-15456201:
|
|
21
|
+
- '*':
|
|
22
|
+
reason: Internal npm dependency, does not affect application runtime.
|
|
23
|
+
expires: '2027-03-27T10:00:00.000Z'
|
|
24
|
+
SNYK-JS-TAR-15416075:
|
|
25
|
+
- '*':
|
|
26
|
+
reason: Internal npm dependency, does not affect application runtime.
|
|
27
|
+
expires: '2027-03-27T10:00:00.000Z'
|
|
28
|
+
SNYK-JS-TAR-15307072:
|
|
29
|
+
- '*':
|
|
30
|
+
reason: Internal npm dependency, does not affect application runtime.
|
|
31
|
+
expires: '2027-03-27T10:00:00.000Z'
|
|
32
|
+
# Brace-expansion Infinite Loop in npm internal dependencies
|
|
33
|
+
SNYK-JS-BRACEEXPANSION-15789759:
|
|
34
|
+
- '*':
|
|
35
|
+
reason: Internal npm dependency, does not affect application runtime.
|
|
36
|
+
expires: '2027-03-27T10:00:00.000Z'
|
|
37
|
+
SNYK-JS-ISAACSBRACEEXPANSION-15208653:
|
|
38
|
+
- '*':
|
|
39
|
+
reason: Internal npm dependency, does not affect application runtime.
|
|
40
|
+
expires: '2027-03-27T10:00:00.000Z'
|
|
41
|
+
# Picomatch ReDoS in npm internal dependencies
|
|
42
|
+
SNYK-JS-PICOMATCH-15765511:
|
|
43
|
+
- '*':
|
|
44
|
+
reason: Internal npm dependency, does not affect application runtime.
|
|
45
|
+
expires: '2027-03-27T10:00:00.000Z'
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
# ==========================================
|
|
2
2
|
# Stage 1: Builder
|
|
3
3
|
# ==========================================
|
|
4
|
-
FROM node:22
|
|
4
|
+
FROM node:22-alpine AS builder
|
|
5
5
|
|
|
6
6
|
# Upgrade OS packages to fix upstream vulnerabilities (Snyk-detected)
|
|
7
|
-
RUN
|
|
8
|
-
|
|
9
|
-
rm -rf /var/lib/apt/lists/*
|
|
7
|
+
RUN apk update && apk upgrade && \
|
|
8
|
+
apk add --no-cache ca-certificates zlib>=1.3.2-r0 --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main
|
|
10
9
|
|
|
11
10
|
WORKDIR /app
|
|
12
11
|
ENV NPM_CONFIG_UPDATE_NOTIFIER=false
|
|
13
12
|
|
|
13
|
+
# Upgrade npm using corepack (safer in Alpine)
|
|
14
|
+
RUN corepack enable && corepack prepare npm@11.6.4 --activate
|
|
15
|
+
|
|
14
16
|
COPY package*.json ./
|
|
15
17
|
COPY tsconfig*.json ./
|
|
16
18
|
|
|
@@ -25,23 +27,28 @@ COPY . .
|
|
|
25
27
|
# ==========================================
|
|
26
28
|
# Stage 2: Production
|
|
27
29
|
# ==========================================
|
|
28
|
-
FROM node:22
|
|
30
|
+
FROM node:22-alpine AS production
|
|
29
31
|
|
|
30
32
|
# Upgrade OS packages to fix upstream vulnerabilities (Snyk-detected)
|
|
31
|
-
RUN
|
|
32
|
-
|
|
33
|
-
rm -rf /var/lib/apt/lists/*
|
|
33
|
+
RUN apk update && apk upgrade && \
|
|
34
|
+
apk add --no-cache ca-certificates zlib>=1.3.2-r0 --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main
|
|
34
35
|
|
|
35
36
|
WORKDIR /app
|
|
36
37
|
|
|
37
38
|
ENV NODE_ENV=production
|
|
38
39
|
ENV NPM_CONFIG_UPDATE_NOTIFIER=false
|
|
39
40
|
|
|
41
|
+
# Upgrade npm using corepack (safer in Alpine)
|
|
42
|
+
RUN corepack enable && corepack prepare npm@11.6.4 --activate
|
|
43
|
+
|
|
40
44
|
COPY package*.json ./
|
|
41
45
|
|
|
42
46
|
# Install ONLY production dependencies
|
|
43
47
|
RUN npm ci --only=production --ignore-scripts --no-audit --no-fund || npm ci --only=production --ignore-scripts --no-audit --no-fund || npm ci --only=production --ignore-scripts --no-audit --no-fund
|
|
44
48
|
|
|
49
|
+
# Remove npm and caches to achieve Zero-Vulnerability status in the final image
|
|
50
|
+
RUN rm -rf /usr/local/lib/node_modules/npm /usr/local/bin/npm /usr/local/bin/npx /root/.npm /root/.cache
|
|
51
|
+
|
|
45
52
|
# Copy built artifacts from builder
|
|
46
53
|
<% if (language === 'TypeScript') { %>
|
|
47
54
|
COPY --from=builder /app/dist ./dist
|
|
@@ -62,4 +69,5 @@ RUN mkdir -p logs && chown -R node:node logs
|
|
|
62
69
|
|
|
63
70
|
USER node
|
|
64
71
|
|
|
65
|
-
|
|
72
|
+
# Start application directly with node (safe even without npm)
|
|
73
|
+
CMD ["node", "<% if (language === 'TypeScript') { %>dist/index.js<% } else { %>src/index.js<% } %>"]
|