@leo-h/create-nodejs-app 1.0.11 → 1.0.13
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/dist/index.js +1 -1
- package/dist/package.json.js +1 -1
- package/package.json +5 -1
- package/templates/clean/build.config.ts +1 -0
- package/templates/clean/gitignore +132 -0
- package/templates/clean/npmrc +1 -0
- package/templates/fastify/build.config.ts +1 -0
- package/templates/fastify/gitignore +132 -0
- package/templates/fastify/npmrc +1 -0
- package/templates/fastify/package.json +3 -1
- package/templates/fastify/pnpm-lock.yaml +107 -0
- package/templates/nest/gitignore +132 -0
- package/templates/nest/npmrc +1 -0
- package/templates/nest/package.json +3 -2
- package/templates/nest/pnpm-lock.yaml +144 -18
- package/templates/nest/src/core/errors/validation.error.ts +12 -0
- package/templates/nest/src/infra/http/errors/filters/all-exception.filter.ts +31 -0
- package/templates/nest/src/infra/http/errors/filters/domain-exception.filter.ts +39 -0
- package/templates/nest/src/infra/http/errors/internal-server.error.ts +15 -0
- package/templates/nest/src/infra/http/http.module.ts +4 -4
- package/templates/nest/src/infra/http/middlewares/zod-schema-pipe.ts +24 -11
- package/templates/nest/src/infra/http/middlewares/zod-validation-pipe.ts +4 -4
- package/templates/nest/src/infra/presenters/error.presenter.ts +2 -1
- package/templates/nest/src/core/errors/errors.ts +0 -9
- package/templates/nest/src/infra/http/filters/domain-exception.filter.ts +0 -53
- package/templates/nest/src/infra/http/filters/http-exception.filter.ts +0 -26
@@ -0,0 +1,132 @@
|
|
1
|
+
# Logs
|
2
|
+
logs
|
3
|
+
*.log
|
4
|
+
npm-debug.log*
|
5
|
+
yarn-debug.log*
|
6
|
+
yarn-error.log*
|
7
|
+
lerna-debug.log*
|
8
|
+
.pnpm-debug.log*
|
9
|
+
|
10
|
+
# Diagnostic reports (https://nodejs.org/api/report.html)
|
11
|
+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
12
|
+
|
13
|
+
# Runtime data
|
14
|
+
pids
|
15
|
+
*.pid
|
16
|
+
*.seed
|
17
|
+
*.pid.lock
|
18
|
+
|
19
|
+
# Directory for instrumented libs generated by jscoverage/JSCover
|
20
|
+
lib-cov
|
21
|
+
|
22
|
+
# Coverage directory used by tools like istanbul
|
23
|
+
coverage
|
24
|
+
*.lcov
|
25
|
+
|
26
|
+
# nyc test coverage
|
27
|
+
.nyc_output
|
28
|
+
|
29
|
+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
30
|
+
.grunt
|
31
|
+
|
32
|
+
# Bower dependency directory (https://bower.io/)
|
33
|
+
bower_components
|
34
|
+
|
35
|
+
# node-waf configuration
|
36
|
+
.lock-wscript
|
37
|
+
|
38
|
+
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
39
|
+
build/Release
|
40
|
+
|
41
|
+
# Dependency directories
|
42
|
+
node_modules/
|
43
|
+
jspm_packages/
|
44
|
+
|
45
|
+
# Snowpack dependency directory (https://snowpack.dev/)
|
46
|
+
web_modules/
|
47
|
+
|
48
|
+
# TypeScript cache
|
49
|
+
*.tsbuildinfo
|
50
|
+
|
51
|
+
# Optional npm cache directory
|
52
|
+
.npm
|
53
|
+
|
54
|
+
# Optional eslint cache
|
55
|
+
.eslintcache
|
56
|
+
|
57
|
+
# Optional stylelint cache
|
58
|
+
.stylelintcache
|
59
|
+
|
60
|
+
# Microbundle cache
|
61
|
+
.rpt2_cache/
|
62
|
+
.rts2_cache_cjs/
|
63
|
+
.rts2_cache_es/
|
64
|
+
.rts2_cache_umd/
|
65
|
+
|
66
|
+
# Optional REPL history
|
67
|
+
.node_repl_history
|
68
|
+
|
69
|
+
# Output of 'npm pack'
|
70
|
+
*.tgz
|
71
|
+
|
72
|
+
# Yarn Integrity file
|
73
|
+
.yarn-integrity
|
74
|
+
|
75
|
+
# parcel-bundler cache (https://parceljs.org/)
|
76
|
+
.cache
|
77
|
+
.parcel-cache
|
78
|
+
|
79
|
+
# Next.js build output
|
80
|
+
.next
|
81
|
+
out
|
82
|
+
|
83
|
+
# Nuxt.js build / generate output
|
84
|
+
.nuxt
|
85
|
+
dist
|
86
|
+
|
87
|
+
# Gatsby files
|
88
|
+
.cache/
|
89
|
+
# Comment in the public line in if your project uses Gatsby and not Next.js
|
90
|
+
# https://nextjs.org/blog/next-9-1#public-directory-support
|
91
|
+
# public
|
92
|
+
|
93
|
+
# vuepress build output
|
94
|
+
.vuepress/dist
|
95
|
+
|
96
|
+
# vuepress v2.x temp and cache directory
|
97
|
+
.temp
|
98
|
+
.cache
|
99
|
+
|
100
|
+
# Docusaurus cache and generated files
|
101
|
+
.docusaurus
|
102
|
+
|
103
|
+
# Serverless directories
|
104
|
+
.serverless/
|
105
|
+
|
106
|
+
# FuseBox cache
|
107
|
+
.fusebox/
|
108
|
+
|
109
|
+
# DynamoDB Local files
|
110
|
+
.dynamodb/
|
111
|
+
|
112
|
+
# TernJS port file
|
113
|
+
.tern-port
|
114
|
+
|
115
|
+
# Stores VSCode versions used for testing VSCode extensions
|
116
|
+
.vscode-test
|
117
|
+
|
118
|
+
# yarn v2
|
119
|
+
.yarn/cache
|
120
|
+
.yarn/unplugged
|
121
|
+
.yarn/build-state.yml
|
122
|
+
.yarn/install-state.gz
|
123
|
+
.pnp.*
|
124
|
+
|
125
|
+
# dotenv environment variable files
|
126
|
+
.env
|
127
|
+
.env.development
|
128
|
+
.env.test
|
129
|
+
.env.production
|
130
|
+
|
131
|
+
# OS
|
132
|
+
.DS_Store
|
@@ -0,0 +1 @@
|
|
1
|
+
save-exact=true
|
@@ -12,13 +12,13 @@
|
|
12
12
|
"format": "prettier . --write --cache",
|
13
13
|
"test:unit": "vitest run",
|
14
14
|
"test:unit:watch": "vitest",
|
15
|
+
"test:unit:coverage": "vitest run --coverage.enabled=true",
|
15
16
|
"test:e2e": "vitest run --config ./vitest.config.e2e.mts",
|
16
17
|
"test:e2e:watch": "vitest --config ./vitest.config.e2e.mts",
|
17
|
-
"test:coverage": "vitest run --coverage.enabled=true",
|
18
|
+
"test:e2e:coverage": "vitest run --config ./vitest.config.e2e.mts --coverage.enabled=true",
|
18
19
|
"build": "nest build"
|
19
20
|
},
|
20
21
|
"dependencies": {
|
21
|
-
"@anatine/zod-nestjs": "2.0.9",
|
22
22
|
"@anatine/zod-openapi": "2.2.6",
|
23
23
|
"@fastify/static": "7.0.4",
|
24
24
|
"@nestjs/common": "10.3.10",
|
@@ -44,6 +44,7 @@
|
|
44
44
|
"@types/supertest": "6.0.2",
|
45
45
|
"@typescript-eslint/eslint-plugin": "7.10.0",
|
46
46
|
"@typescript-eslint/parser": "7.10.0",
|
47
|
+
"@vitest/coverage-v8": "1.6.0",
|
47
48
|
"eslint": "8.57.0",
|
48
49
|
"eslint-config-prettier": "9.1.0",
|
49
50
|
"eslint-plugin-vitest": "0.4.0",
|
@@ -8,9 +8,6 @@ importers:
|
|
8
8
|
|
9
9
|
.:
|
10
10
|
dependencies:
|
11
|
-
'@anatine/zod-nestjs':
|
12
|
-
specifier: 2.0.9
|
13
|
-
version: 2.0.9(@anatine/zod-openapi@2.2.6(openapi3-ts@4.3.3)(zod@3.23.8))(@nestjs/common@10.3.10(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/swagger@7.4.0(@fastify/static@7.0.4)(@nestjs/common@10.3.10(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.3.10(@nestjs/common@10.3.10(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.3.10)(reflect-metadata@0.2.2)(rxjs@7.8.1))(reflect-metadata@0.2.2))(openapi3-ts@4.3.3)(zod@3.23.8)
|
14
11
|
'@anatine/zod-openapi':
|
15
12
|
specifier: 2.2.6
|
16
13
|
version: 2.2.6(openapi3-ts@4.3.3)(zod@3.23.8)
|
@@ -81,6 +78,9 @@ importers:
|
|
81
78
|
'@typescript-eslint/parser':
|
82
79
|
specifier: 7.10.0
|
83
80
|
version: 7.10.0(eslint@8.57.0)(typescript@5.4.5)
|
81
|
+
'@vitest/coverage-v8':
|
82
|
+
specifier: 1.6.0
|
83
|
+
version: 1.6.0(vitest@1.6.0(@types/node@20.12.12)(terser@5.31.3))
|
84
84
|
eslint:
|
85
85
|
specifier: 8.57.0
|
86
86
|
version: 8.57.0
|
@@ -117,14 +117,9 @@ importers:
|
|
117
117
|
|
118
118
|
packages:
|
119
119
|
|
120
|
-
'@
|
121
|
-
resolution: {integrity: sha512-
|
122
|
-
|
123
|
-
'@anatine/zod-openapi': ^2.0.1
|
124
|
-
'@nestjs/common': ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0
|
125
|
-
'@nestjs/swagger': ^6.0.0 || ^7.0.0
|
126
|
-
openapi3-ts: ^4.1.2
|
127
|
-
zod: ^3.20.0
|
120
|
+
'@ampproject/remapping@2.3.0':
|
121
|
+
resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==}
|
122
|
+
engines: {node: '>=6.0.0'}
|
128
123
|
|
129
124
|
'@anatine/zod-openapi@2.2.6':
|
130
125
|
resolution: {integrity: sha512-Z5sr2Nq2xifEpPbPdUcvyl776LY652oR3VHMV++WFSmRrRL8RDP2XTkbuGn+vgfVNOD7UrndYwCWnxaiw7IZog==}
|
@@ -154,6 +149,10 @@ packages:
|
|
154
149
|
resolution: {integrity: sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==}
|
155
150
|
engines: {node: '>=6.9.0'}
|
156
151
|
|
152
|
+
'@babel/helper-string-parser@7.24.8':
|
153
|
+
resolution: {integrity: sha512-pO9KhhRcuUyGnJWwyEgnRJTSIZHiT+vMD0kPeD+so0l7mxkMT19g3pjY9GTnHySck/hDzq+dtW/4VgnMkippsQ==}
|
154
|
+
engines: {node: '>=6.9.0'}
|
155
|
+
|
157
156
|
'@babel/helper-validator-identifier@7.24.7':
|
158
157
|
resolution: {integrity: sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==}
|
159
158
|
engines: {node: '>=6.9.0'}
|
@@ -162,6 +161,18 @@ packages:
|
|
162
161
|
resolution: {integrity: sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==}
|
163
162
|
engines: {node: '>=6.9.0'}
|
164
163
|
|
164
|
+
'@babel/parser@7.25.4':
|
165
|
+
resolution: {integrity: sha512-nq+eWrOgdtu3jG5Os4TQP3x3cLA8hR8TvJNjD8vnPa20WGycimcparWnLK4jJhElTK6SDyuJo1weMKO/5LpmLA==}
|
166
|
+
engines: {node: '>=6.0.0'}
|
167
|
+
hasBin: true
|
168
|
+
|
169
|
+
'@babel/types@7.25.4':
|
170
|
+
resolution: {integrity: sha512-zQ1ijeeCXVEh+aNL0RlmkPkG8HUiDcU2pzQQFjtbntgAczRASFzj4H+6+bV+dy1ntKR14I/DypeuRG1uma98iQ==}
|
171
|
+
engines: {node: '>=6.9.0'}
|
172
|
+
|
173
|
+
'@bcoe/v8-coverage@0.2.3':
|
174
|
+
resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==}
|
175
|
+
|
165
176
|
'@colors/colors@1.5.0':
|
166
177
|
resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==}
|
167
178
|
engines: {node: '>=0.1.90'}
|
@@ -378,6 +389,10 @@ packages:
|
|
378
389
|
resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==}
|
379
390
|
engines: {node: '>=12'}
|
380
391
|
|
392
|
+
'@istanbuljs/schema@0.1.3':
|
393
|
+
resolution: {integrity: sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==}
|
394
|
+
engines: {node: '>=8'}
|
395
|
+
|
381
396
|
'@jest/schemas@29.6.3':
|
382
397
|
resolution: {integrity: sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==}
|
383
398
|
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
@@ -872,6 +887,11 @@ packages:
|
|
872
887
|
'@ungap/structured-clone@1.2.0':
|
873
888
|
resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==}
|
874
889
|
|
890
|
+
'@vitest/coverage-v8@1.6.0':
|
891
|
+
resolution: {integrity: sha512-KvapcbMY/8GYIG0rlwwOKCVNRc0OL20rrhFkg/CHNzncV03TE2XWvO5w9uZYoxNiMEBacAJt3unSOiZ7svePew==}
|
892
|
+
peerDependencies:
|
893
|
+
vitest: 1.6.0
|
894
|
+
|
875
895
|
'@vitest/expect@1.6.0':
|
876
896
|
resolution: {integrity: sha512-ixEvFVQjycy/oNgHjqsL6AZCDduC+tflRluaHIzKIsdbzkLn2U/iBnVeJwB6HsIjQBdfMR8Z0tRxKUsvFJEeWQ==}
|
877
897
|
|
@@ -1823,6 +1843,9 @@ packages:
|
|
1823
1843
|
resolution: {integrity: sha512-QFLV0taWQOZtvIRIAdBChesmogZrtuXvVWsFHZTk2SU+anspqZ2vMnoLg7IE1+Uk16N19APic1BuF8bC8c2m5g==}
|
1824
1844
|
engines: {node: '>=8'}
|
1825
1845
|
|
1846
|
+
html-escaper@2.0.2:
|
1847
|
+
resolution: {integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==}
|
1848
|
+
|
1826
1849
|
http-cache-semantics@4.1.1:
|
1827
1850
|
resolution: {integrity: sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==}
|
1828
1851
|
|
@@ -1950,6 +1973,22 @@ packages:
|
|
1950
1973
|
isexe@2.0.0:
|
1951
1974
|
resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==}
|
1952
1975
|
|
1976
|
+
istanbul-lib-coverage@3.2.2:
|
1977
|
+
resolution: {integrity: sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==}
|
1978
|
+
engines: {node: '>=8'}
|
1979
|
+
|
1980
|
+
istanbul-lib-report@3.0.1:
|
1981
|
+
resolution: {integrity: sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==}
|
1982
|
+
engines: {node: '>=10'}
|
1983
|
+
|
1984
|
+
istanbul-lib-source-maps@5.0.6:
|
1985
|
+
resolution: {integrity: sha512-yg2d+Em4KizZC5niWhQaIomgf5WlL4vOOjZ5xGCmF8SnPE/mDWWXgvRExdcpCgh9lLRRa1/fSYp2ymmbJ1pI+A==}
|
1986
|
+
engines: {node: '>=10'}
|
1987
|
+
|
1988
|
+
istanbul-reports@3.1.7:
|
1989
|
+
resolution: {integrity: sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==}
|
1990
|
+
engines: {node: '>=8'}
|
1991
|
+
|
1953
1992
|
iterare@1.2.1:
|
1954
1993
|
resolution: {integrity: sha512-RKYVTCjAnRthyJes037NX/IiqeidgN1xc3j1RjFfECFp28A1GVwK9nA+i0rJPaHqSZwygLzRnFlzUuHFoWWy+Q==}
|
1955
1994
|
engines: {node: '>=6'}
|
@@ -2079,6 +2118,13 @@ packages:
|
|
2079
2118
|
resolution: {integrity: sha512-ISQTe55T2ao7XtlAStud6qwYPZjE4GK1S/BeVPus4jrq6JuOnQ00YKQC581RWhR122W7msZV263KzVeLoqidyQ==}
|
2080
2119
|
engines: {node: '>=12'}
|
2081
2120
|
|
2121
|
+
magicast@0.3.4:
|
2122
|
+
resolution: {integrity: sha512-TyDF/Pn36bBji9rWKHlZe+PZb6Mx5V8IHCSxk7X4aljM4e/vyDvZZYwHewdVaqiA0nb3ghfHU/6AUpDxWoER2Q==}
|
2123
|
+
|
2124
|
+
make-dir@4.0.0:
|
2125
|
+
resolution: {integrity: sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==}
|
2126
|
+
engines: {node: '>=10'}
|
2127
|
+
|
2082
2128
|
media-typer@0.3.0:
|
2083
2129
|
resolution: {integrity: sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==}
|
2084
2130
|
engines: {node: '>= 0.6'}
|
@@ -2863,6 +2909,10 @@ packages:
|
|
2863
2909
|
engines: {node: '>=10'}
|
2864
2910
|
hasBin: true
|
2865
2911
|
|
2912
|
+
test-exclude@6.0.0:
|
2913
|
+
resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==}
|
2914
|
+
engines: {node: '>=8'}
|
2915
|
+
|
2866
2916
|
text-decoding@1.0.0:
|
2867
2917
|
resolution: {integrity: sha512-/0TJD42KDnVwKmDK6jj3xP7E2MG7SHAOG4tyTgyUCRPdHwvkquYNLEQltmdMa3owq3TkddCVcTsoctJI8VQNKA==}
|
2868
2918
|
|
@@ -2890,6 +2940,10 @@ packages:
|
|
2890
2940
|
resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==}
|
2891
2941
|
engines: {node: '>=0.6.0'}
|
2892
2942
|
|
2943
|
+
to-fast-properties@2.0.0:
|
2944
|
+
resolution: {integrity: sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==}
|
2945
|
+
engines: {node: '>=4'}
|
2946
|
+
|
2893
2947
|
to-regex-range@5.0.1:
|
2894
2948
|
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
|
2895
2949
|
engines: {node: '>=8.0'}
|
@@ -3185,14 +3239,10 @@ packages:
|
|
3185
3239
|
|
3186
3240
|
snapshots:
|
3187
3241
|
|
3188
|
-
'@
|
3242
|
+
'@ampproject/remapping@2.3.0':
|
3189
3243
|
dependencies:
|
3190
|
-
'@
|
3191
|
-
'@
|
3192
|
-
'@nestjs/swagger': 7.4.0(@fastify/static@7.0.4)(@nestjs/common@10.3.10(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.3.10(@nestjs/common@10.3.10(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.3.10)(reflect-metadata@0.2.2)(rxjs@7.8.1))(reflect-metadata@0.2.2)
|
3193
|
-
openapi3-ts: 4.3.3
|
3194
|
-
ts-deepmerge: 6.2.1
|
3195
|
-
zod: 3.23.8
|
3244
|
+
'@jridgewell/gen-mapping': 0.3.5
|
3245
|
+
'@jridgewell/trace-mapping': 0.3.25
|
3196
3246
|
|
3197
3247
|
'@anatine/zod-openapi@2.2.6(openapi3-ts@4.3.3)(zod@3.23.8)':
|
3198
3248
|
dependencies:
|
@@ -3237,6 +3287,8 @@ snapshots:
|
|
3237
3287
|
'@babel/highlight': 7.24.7
|
3238
3288
|
picocolors: 1.0.1
|
3239
3289
|
|
3290
|
+
'@babel/helper-string-parser@7.24.8': {}
|
3291
|
+
|
3240
3292
|
'@babel/helper-validator-identifier@7.24.7': {}
|
3241
3293
|
|
3242
3294
|
'@babel/highlight@7.24.7':
|
@@ -3246,6 +3298,18 @@ snapshots:
|
|
3246
3298
|
js-tokens: 4.0.0
|
3247
3299
|
picocolors: 1.0.1
|
3248
3300
|
|
3301
|
+
'@babel/parser@7.25.4':
|
3302
|
+
dependencies:
|
3303
|
+
'@babel/types': 7.25.4
|
3304
|
+
|
3305
|
+
'@babel/types@7.25.4':
|
3306
|
+
dependencies:
|
3307
|
+
'@babel/helper-string-parser': 7.24.8
|
3308
|
+
'@babel/helper-validator-identifier': 7.24.7
|
3309
|
+
to-fast-properties: 2.0.0
|
3310
|
+
|
3311
|
+
'@bcoe/v8-coverage@0.2.3': {}
|
3312
|
+
|
3249
3313
|
'@colors/colors@1.5.0':
|
3250
3314
|
optional: true
|
3251
3315
|
|
@@ -3420,6 +3484,8 @@ snapshots:
|
|
3420
3484
|
wrap-ansi: 8.1.0
|
3421
3485
|
wrap-ansi-cjs: wrap-ansi@7.0.0
|
3422
3486
|
|
3487
|
+
'@istanbuljs/schema@0.1.3': {}
|
3488
|
+
|
3423
3489
|
'@jest/schemas@29.6.3':
|
3424
3490
|
dependencies:
|
3425
3491
|
'@sinclair/typebox': 0.27.8
|
@@ -3926,6 +3992,25 @@ snapshots:
|
|
3926
3992
|
|
3927
3993
|
'@ungap/structured-clone@1.2.0': {}
|
3928
3994
|
|
3995
|
+
'@vitest/coverage-v8@1.6.0(vitest@1.6.0(@types/node@20.12.12)(terser@5.31.3))':
|
3996
|
+
dependencies:
|
3997
|
+
'@ampproject/remapping': 2.3.0
|
3998
|
+
'@bcoe/v8-coverage': 0.2.3
|
3999
|
+
debug: 4.3.5
|
4000
|
+
istanbul-lib-coverage: 3.2.2
|
4001
|
+
istanbul-lib-report: 3.0.1
|
4002
|
+
istanbul-lib-source-maps: 5.0.6
|
4003
|
+
istanbul-reports: 3.1.7
|
4004
|
+
magic-string: 0.30.10
|
4005
|
+
magicast: 0.3.4
|
4006
|
+
picocolors: 1.0.1
|
4007
|
+
std-env: 3.7.0
|
4008
|
+
strip-literal: 2.1.0
|
4009
|
+
test-exclude: 6.0.0
|
4010
|
+
vitest: 1.6.0(@types/node@20.12.12)(terser@5.31.3)
|
4011
|
+
transitivePeerDependencies:
|
4012
|
+
- supports-color
|
4013
|
+
|
3929
4014
|
'@vitest/expect@1.6.0':
|
3930
4015
|
dependencies:
|
3931
4016
|
'@vitest/spy': 1.6.0
|
@@ -5057,6 +5142,8 @@ snapshots:
|
|
5057
5142
|
|
5058
5143
|
hexoid@1.0.0: {}
|
5059
5144
|
|
5145
|
+
html-escaper@2.0.2: {}
|
5146
|
+
|
5060
5147
|
http-cache-semantics@4.1.1: {}
|
5061
5148
|
|
5062
5149
|
http-errors@2.0.0:
|
@@ -5179,6 +5266,27 @@ snapshots:
|
|
5179
5266
|
|
5180
5267
|
isexe@2.0.0: {}
|
5181
5268
|
|
5269
|
+
istanbul-lib-coverage@3.2.2: {}
|
5270
|
+
|
5271
|
+
istanbul-lib-report@3.0.1:
|
5272
|
+
dependencies:
|
5273
|
+
istanbul-lib-coverage: 3.2.2
|
5274
|
+
make-dir: 4.0.0
|
5275
|
+
supports-color: 7.2.0
|
5276
|
+
|
5277
|
+
istanbul-lib-source-maps@5.0.6:
|
5278
|
+
dependencies:
|
5279
|
+
'@jridgewell/trace-mapping': 0.3.25
|
5280
|
+
debug: 4.3.5
|
5281
|
+
istanbul-lib-coverage: 3.2.2
|
5282
|
+
transitivePeerDependencies:
|
5283
|
+
- supports-color
|
5284
|
+
|
5285
|
+
istanbul-reports@3.1.7:
|
5286
|
+
dependencies:
|
5287
|
+
html-escaper: 2.0.2
|
5288
|
+
istanbul-lib-report: 3.0.1
|
5289
|
+
|
5182
5290
|
iterare@1.2.1: {}
|
5183
5291
|
|
5184
5292
|
jackspeak@3.4.3:
|
@@ -5321,6 +5429,16 @@ snapshots:
|
|
5321
5429
|
dependencies:
|
5322
5430
|
'@jridgewell/sourcemap-codec': 1.5.0
|
5323
5431
|
|
5432
|
+
magicast@0.3.4:
|
5433
|
+
dependencies:
|
5434
|
+
'@babel/parser': 7.25.4
|
5435
|
+
'@babel/types': 7.25.4
|
5436
|
+
source-map-js: 1.2.0
|
5437
|
+
|
5438
|
+
make-dir@4.0.0:
|
5439
|
+
dependencies:
|
5440
|
+
semver: 7.6.3
|
5441
|
+
|
5324
5442
|
media-typer@0.3.0: {}
|
5325
5443
|
|
5326
5444
|
memfs@3.5.3:
|
@@ -6070,6 +6188,12 @@ snapshots:
|
|
6070
6188
|
commander: 2.20.3
|
6071
6189
|
source-map-support: 0.5.21
|
6072
6190
|
|
6191
|
+
test-exclude@6.0.0:
|
6192
|
+
dependencies:
|
6193
|
+
'@istanbuljs/schema': 0.1.3
|
6194
|
+
glob: 7.2.3
|
6195
|
+
minimatch: 3.1.2
|
6196
|
+
|
6073
6197
|
text-decoding@1.0.0: {}
|
6074
6198
|
|
6075
6199
|
text-table@0.2.0: {}
|
@@ -6090,6 +6214,8 @@ snapshots:
|
|
6090
6214
|
dependencies:
|
6091
6215
|
os-tmpdir: 1.0.2
|
6092
6216
|
|
6217
|
+
to-fast-properties@2.0.0: {}
|
6218
|
+
|
6093
6219
|
to-regex-range@5.0.1:
|
6094
6220
|
dependencies:
|
6095
6221
|
is-number: 7.0.0
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { DomainError } from "./domain-error";
|
2
|
+
|
3
|
+
export class ValidationError extends DomainError {
|
4
|
+
public error = "ValidationError" as const;
|
5
|
+
public debug: object | null;
|
6
|
+
|
7
|
+
constructor(debug?: object) {
|
8
|
+
super("Os dados recebidos são inválidos.");
|
9
|
+
|
10
|
+
this.debug = debug ?? null;
|
11
|
+
}
|
12
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import {
|
2
|
+
ArgumentsHost,
|
3
|
+
Catch,
|
4
|
+
ExceptionFilter,
|
5
|
+
HttpException,
|
6
|
+
} from "@nestjs/common";
|
7
|
+
import { FastifyReply } from "fastify";
|
8
|
+
import { InternalServerError } from "../internal-server.error";
|
9
|
+
|
10
|
+
@Catch()
|
11
|
+
export class AllExceptionFilter implements ExceptionFilter {
|
12
|
+
catch(exception: unknown, host: ArgumentsHost): void {
|
13
|
+
const ctx = host.switchToHttp();
|
14
|
+
const response = ctx.getResponse<FastifyReply>();
|
15
|
+
|
16
|
+
const debug =
|
17
|
+
exception && typeof exception === "object" && "message" in exception
|
18
|
+
? exception.message
|
19
|
+
: null;
|
20
|
+
|
21
|
+
let httpException: HttpException = new InternalServerError(debug);
|
22
|
+
|
23
|
+
if (exception instanceof HttpException) httpException = exception;
|
24
|
+
|
25
|
+
console.error(exception);
|
26
|
+
|
27
|
+
response
|
28
|
+
.status(httpException.getStatus())
|
29
|
+
.send(httpException.getResponse());
|
30
|
+
}
|
31
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { DomainError } from "@/core/errors/domain-error";
|
2
|
+
import { ValidationError } from "@/core/errors/validation.error";
|
3
|
+
import { ErrorPresenter } from "@/infra/presenters/error.presenter";
|
4
|
+
import {
|
5
|
+
ArgumentsHost,
|
6
|
+
BadRequestException,
|
7
|
+
Catch,
|
8
|
+
ExceptionFilter,
|
9
|
+
HttpException,
|
10
|
+
} from "@nestjs/common";
|
11
|
+
import { FastifyReply } from "fastify";
|
12
|
+
import { InternalServerError } from "../internal-server.error";
|
13
|
+
|
14
|
+
@Catch(DomainError)
|
15
|
+
export class DomainExceptionFilter implements ExceptionFilter {
|
16
|
+
catch(exception: DomainError, host: ArgumentsHost): void {
|
17
|
+
const ctx = host.switchToHttp();
|
18
|
+
const response = ctx.getResponse<FastifyReply>();
|
19
|
+
|
20
|
+
let httpException: HttpException;
|
21
|
+
|
22
|
+
switch (exception.constructor) {
|
23
|
+
case ValidationError:
|
24
|
+
httpException = new BadRequestException(
|
25
|
+
ErrorPresenter.toHttp(400, exception),
|
26
|
+
);
|
27
|
+
break;
|
28
|
+
|
29
|
+
default:
|
30
|
+
httpException = new InternalServerError(exception.message);
|
31
|
+
}
|
32
|
+
|
33
|
+
console.error(exception);
|
34
|
+
|
35
|
+
response
|
36
|
+
.status(httpException.getStatus())
|
37
|
+
.send(httpException.getResponse());
|
38
|
+
}
|
39
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { ErrorPresenter } from "@/infra/presenters/error.presenter";
|
2
|
+
import { HttpException } from "@nestjs/common";
|
3
|
+
|
4
|
+
export class InternalServerError extends HttpException {
|
5
|
+
constructor(debug: unknown) {
|
6
|
+
const statusCode = 500;
|
7
|
+
const presenter = ErrorPresenter.toHttp(statusCode, {
|
8
|
+
error: "InternalServerError",
|
9
|
+
message: "Desculpe, um erro inesperado ocorreu.",
|
10
|
+
debug,
|
11
|
+
});
|
12
|
+
|
13
|
+
super(presenter, statusCode);
|
14
|
+
}
|
15
|
+
}
|
@@ -2,20 +2,20 @@ import { Module } from "@nestjs/common";
|
|
2
2
|
import { APP_FILTER } from "@nestjs/core";
|
3
3
|
import { HelloMultipartController } from "./controllers/hello/hello-multipart.controller";
|
4
4
|
import { HelloController } from "./controllers/hello/hello.controller";
|
5
|
+
import { AllExceptionFilter } from "./errors/filters/all-exception.filter";
|
6
|
+
import { DomainExceptionFilter } from "./errors/filters/domain-exception.filter";
|
5
7
|
import { FastifyMulterEventModule } from "./events/fastify-multer.event.module";
|
6
|
-
import { DomainExceptionFilter } from "./filters/domain-exception.filter";
|
7
|
-
import { HttpExceptionFilter } from "./filters/http-exception.filter";
|
8
8
|
|
9
9
|
@Module({
|
10
10
|
imports: [FastifyMulterEventModule],
|
11
11
|
providers: [
|
12
12
|
{
|
13
13
|
provide: APP_FILTER,
|
14
|
-
useClass:
|
14
|
+
useClass: AllExceptionFilter,
|
15
15
|
},
|
16
16
|
{
|
17
17
|
provide: APP_FILTER,
|
18
|
-
useClass:
|
18
|
+
useClass: DomainExceptionFilter,
|
19
19
|
},
|
20
20
|
],
|
21
21
|
controllers: [HelloController, HelloMultipartController],
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import {
|
2
|
-
import { extendApi, generateSchema } from "@anatine/zod-openapi";
|
1
|
+
import { generateSchema } from "@anatine/zod-openapi";
|
3
2
|
import { UsePipes, applyDecorators } from "@nestjs/common";
|
4
3
|
import { ZodType } from "zod";
|
5
4
|
import {
|
@@ -15,10 +14,6 @@ export function zodSchemaToSwaggerSchema(schema: ZodType) {
|
|
15
14
|
return generateSchema(schema, false, "3.0") as SchemaObject;
|
16
15
|
}
|
17
16
|
|
18
|
-
export function zodSchemaToNestDto(schema: ZodType) {
|
19
|
-
return class Dto extends createZodDto(extendApi(schema)) {};
|
20
|
-
}
|
21
|
-
|
22
17
|
interface ZodSchemaPipeParams extends ZodValidationPipeSchemas {
|
23
18
|
isMultipart?: boolean;
|
24
19
|
response?: ZodType | Record<number, ZodType>;
|
@@ -38,17 +33,35 @@ export function ZodSchemaPipe({
|
|
38
33
|
const apiDecorators: NestSwaggerDecorator[] = [];
|
39
34
|
|
40
35
|
if (routeParams) {
|
41
|
-
|
42
|
-
|
43
|
-
)
|
36
|
+
const routeParamsSchema = zodSchemaToSwaggerSchema(routeParams);
|
37
|
+
|
38
|
+
for (const paramName in routeParams.shape) {
|
39
|
+
apiDecorators.push(
|
40
|
+
ApiParam({
|
41
|
+
name: paramName,
|
42
|
+
schema: zodSchemaToSwaggerSchema(routeParams.shape[paramName]),
|
43
|
+
required: routeParamsSchema.required?.includes(paramName) ?? false,
|
44
|
+
}),
|
45
|
+
);
|
46
|
+
}
|
44
47
|
}
|
45
48
|
|
46
49
|
if (queryParams) {
|
47
|
-
|
50
|
+
const queryParamsSchema = zodSchemaToSwaggerSchema(queryParams);
|
51
|
+
|
52
|
+
for (const paramName in queryParams.shape) {
|
53
|
+
apiDecorators.push(
|
54
|
+
ApiQuery({
|
55
|
+
name: paramName,
|
56
|
+
schema: zodSchemaToSwaggerSchema(queryParams.shape[paramName]),
|
57
|
+
required: queryParamsSchema.required?.includes(paramName) ?? false,
|
58
|
+
}),
|
59
|
+
);
|
60
|
+
}
|
48
61
|
}
|
49
62
|
|
50
63
|
if (body && !isMultipart) {
|
51
|
-
apiDecorators.push(ApiBody({
|
64
|
+
apiDecorators.push(ApiBody({ schema: zodSchemaToSwaggerSchema(body) }));
|
52
65
|
}
|
53
66
|
|
54
67
|
if (response) {
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import { ValidationError } from "@/core/errors/
|
1
|
+
import { ValidationError } from "@/core/errors/validation.error";
|
2
2
|
import { ArgumentMetadata, PipeTransform } from "@nestjs/common";
|
3
|
-
import { ZodError, ZodType } from "zod";
|
3
|
+
import { ZodError, ZodObject, ZodRawShape, ZodType } from "zod";
|
4
4
|
|
5
5
|
export interface ZodValidationPipeSchemas {
|
6
|
-
routeParams?:
|
7
|
-
queryParams?:
|
6
|
+
routeParams?: ZodObject<ZodRawShape>;
|
7
|
+
queryParams?: ZodObject<ZodRawShape>;
|
8
8
|
body?: ZodType;
|
9
9
|
}
|
10
10
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { DomainError } from "@/core/errors/domain-error";
|
2
|
+
import { env } from "../env";
|
2
3
|
|
3
4
|
type CustomError = Pick<DomainError, "error" | "message" | "debug">;
|
4
5
|
|
@@ -8,7 +9,7 @@ export class ErrorPresenter {
|
|
8
9
|
error: error.error,
|
9
10
|
message: error.message,
|
10
11
|
statusCode,
|
11
|
-
debug: error.debug,
|
12
|
+
debug: env.NODE_ENV !== "production" ? error.debug : null,
|
12
13
|
};
|
13
14
|
}
|
14
15
|
}
|