@athenna/http 4.9.0 → 4.11.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/package.json +220 -219
- package/src/commands/RouteListCommand.d.ts +2 -2
- package/src/commands/RouteListCommand.js +5 -5
- package/src/context/Request.js +1 -1
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -1
- package/src/kernels/HttpKernel.js +1 -1
- package/src/router/Route.js +5 -2
- package/src/server/ServerImpl.d.ts +4 -4
- package/src/server/ServerImpl.js +2 -1
- package/src/types/index.d.ts +1 -0
- package/src/types/index.js +1 -0
- package/src/types/swagger/SwaggerDocument.d.ts +10 -0
- package/src/types/swagger/SwaggerDocument.js +9 -0
package/package.json
CHANGED
|
@@ -1,229 +1,230 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
2
|
+
"name": "@athenna/http",
|
|
3
|
+
"version": "4.11.0",
|
|
4
|
+
"description": "The Athenna Http server. Built on top of fastify.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "João Lenon <lenon@athenna.io>",
|
|
7
|
+
"bugs": "https://github.com/AthennaIO/Http/issues",
|
|
8
|
+
"repository": "https://github.com/AthennaIO/Http.git",
|
|
9
|
+
"homepage": "https://github.com/AthennaIO/Http#readme",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"fastify",
|
|
12
|
+
"router",
|
|
13
|
+
"cors",
|
|
14
|
+
"ctx",
|
|
15
|
+
"helmet",
|
|
16
|
+
"swagger",
|
|
17
|
+
"exception-handling",
|
|
18
|
+
"rate-limiting",
|
|
19
|
+
"middlewares",
|
|
20
|
+
"terminators",
|
|
21
|
+
"interceptors",
|
|
22
|
+
"http-server",
|
|
23
|
+
"athenna",
|
|
24
|
+
"esm"
|
|
25
|
+
],
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=20.0.0"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "node node_modules/@athenna/tsconfig/src/build.js",
|
|
31
|
+
"lint:fix": "eslint \"{bin,src,tests}/**/*.ts\" --fix",
|
|
32
|
+
"test": "npm run --silent lint:fix && node --enable-source-maps --import=@athenna/tsconfig bin/test.ts",
|
|
33
|
+
"test:debug": "cross-env NODE_DEBUG=athenna:* node --inspect --enable-source-maps --import=@athenna/tsconfig bin/test.ts",
|
|
34
|
+
"test:coverage": "c8 npm run --silent test"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"src/*.js",
|
|
38
|
+
"src/*.d.ts",
|
|
39
|
+
"src/**/*.js",
|
|
40
|
+
"src/**/*.d.ts",
|
|
41
|
+
"templates",
|
|
42
|
+
"configurer"
|
|
43
|
+
],
|
|
44
|
+
"type": "module",
|
|
45
|
+
"main": "./src/index.js",
|
|
46
|
+
"types": "./src/index.d.ts",
|
|
47
|
+
"exports": {
|
|
48
|
+
".": "./src/index.js",
|
|
49
|
+
"./types": "./src/types/index.js",
|
|
50
|
+
"./package": "./package.json",
|
|
51
|
+
"./package.json": "./package.json",
|
|
52
|
+
"./testing/plugins": "./src/testing/plugins/index.js",
|
|
53
|
+
"./kernels/HttpKernel": "./src/kernels/HttpKernel.js",
|
|
54
|
+
"./handlers/HttpExceptionHandler": "./src/handlers/HttpExceptionHandler.js",
|
|
55
|
+
"./providers/HttpRouteProvider": "./src/providers/HttpRouteProvider.js",
|
|
56
|
+
"./providers/HttpServerProvider": "./src/providers/HttpServerProvider.js",
|
|
57
|
+
"./commands/RouteListCommand": "./src/commands/RouteListCommand.js",
|
|
58
|
+
"./commands/MakeControllerCommand": "./src/commands/MakeControllerCommand.js",
|
|
59
|
+
"./commands/MakeMiddlewareCommand": "./src/commands/MakeMiddlewareCommand.js",
|
|
60
|
+
"./commands/MakeTerminatorCommand": "./src/commands/MakeTerminatorCommand.js",
|
|
61
|
+
"./commands/MakeInterceptorCommand": "./src/commands/MakeInterceptorCommand.js"
|
|
62
|
+
},
|
|
63
|
+
"imports": {
|
|
64
|
+
"#bin/*": "./bin/*.js",
|
|
65
|
+
"#bin": "./bin/index.js",
|
|
66
|
+
"#src/*": "./src/*.js",
|
|
67
|
+
"#src": "./src/index.js",
|
|
68
|
+
"#src/types": "./src/types/index.js",
|
|
69
|
+
"#src/debug": "./src/debug/index.js",
|
|
70
|
+
"#tests/*": "./tests/*.js",
|
|
71
|
+
"#tests": "./tests/index.js"
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@athenna/artisan": "^4.14.0",
|
|
75
|
+
"@athenna/common": "^4.18.0",
|
|
76
|
+
"@athenna/config": "^4.7.0",
|
|
77
|
+
"@athenna/ioc": "^4.7.0",
|
|
78
|
+
"@athenna/logger": "^4.8.0",
|
|
79
|
+
"@athenna/test": "^4.12.0",
|
|
80
|
+
"@athenna/tsconfig": "^4.9.1",
|
|
81
|
+
"@athenna/view": "^4.6.0",
|
|
82
|
+
"@fastify/cors": "^8.4.0",
|
|
83
|
+
"@fastify/helmet": "^11.1.1",
|
|
84
|
+
"@fastify/rate-limit": "^8.0.3",
|
|
85
|
+
"@fastify/swagger": "^8.11.0",
|
|
86
|
+
"@fastify/swagger-ui": "^1.10.0",
|
|
87
|
+
"@typescript-eslint/eslint-plugin": "^6.7.4",
|
|
88
|
+
"@typescript-eslint/parser": "^6.7.4",
|
|
89
|
+
"commitizen": "^4.2.6",
|
|
90
|
+
"cz-conventional-changelog": "^3.3.0",
|
|
91
|
+
"eslint": "^8.36.0",
|
|
92
|
+
"eslint-config-prettier": "^8.8.0",
|
|
93
|
+
"eslint-config-standard": "^17.0.0",
|
|
94
|
+
"eslint-plugin-import": "^2.27.5",
|
|
95
|
+
"eslint-plugin-n": "^15.6.1",
|
|
96
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
97
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
98
|
+
"foreground-child": "^2.0.0",
|
|
99
|
+
"husky": "^3.1.0",
|
|
100
|
+
"lint-staged": "^12.5.0",
|
|
101
|
+
"prettier": "^2.8.7"
|
|
102
|
+
},
|
|
103
|
+
"c8": {
|
|
104
|
+
"all": true,
|
|
105
|
+
"include": [
|
|
106
|
+
"src/**/*.ts"
|
|
25
107
|
],
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"test:debug": "cross-env NODE_DEBUG=athenna:* sh node --inspect bin/test.ts",
|
|
31
|
-
"test:coverage": "c8 npm run --silent test"
|
|
32
|
-
},
|
|
33
|
-
"files": [
|
|
34
|
-
"src/*.js",
|
|
35
|
-
"src/*.d.ts",
|
|
36
|
-
"src/**/*.js",
|
|
37
|
-
"src/**/*.d.ts",
|
|
38
|
-
"templates",
|
|
39
|
-
"configurer"
|
|
108
|
+
"exclude": [
|
|
109
|
+
"src/types/*",
|
|
110
|
+
"src/exceptions/*",
|
|
111
|
+
"src/commands/*"
|
|
40
112
|
],
|
|
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
|
-
"@fastify/swagger": "^8.1.0",
|
|
81
|
-
"@fastify/swagger-ui": "^1.1.0",
|
|
82
|
-
"@typescript-eslint/eslint-plugin": "^5.56.0",
|
|
83
|
-
"@typescript-eslint/parser": "^5.56.0",
|
|
84
|
-
"c8": "^7.12.0",
|
|
85
|
-
"commitizen": "^4.2.6",
|
|
86
|
-
"cz-conventional-changelog": "^3.3.0",
|
|
87
|
-
"eslint": "^8.36.0",
|
|
88
|
-
"eslint-config-prettier": "^8.8.0",
|
|
89
|
-
"eslint-config-standard": "^17.0.0",
|
|
90
|
-
"eslint-plugin-import": "^2.27.5",
|
|
91
|
-
"eslint-plugin-n": "^15.6.1",
|
|
92
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
93
|
-
"eslint-plugin-promise": "^6.1.1",
|
|
94
|
-
"husky": "^3.1.0",
|
|
95
|
-
"lint-staged": "^12.5.0",
|
|
96
|
-
"prettier": "^2.8.7",
|
|
97
|
-
"reflect-metadata": "^0.1.13",
|
|
98
|
-
"rimraf": "^5.0.1",
|
|
99
|
-
"ts-node": "^10.9.1",
|
|
100
|
-
"typescript": "^5.0.2"
|
|
101
|
-
},
|
|
102
|
-
"c8": {
|
|
103
|
-
"all": true,
|
|
104
|
-
"include": [
|
|
105
|
-
"src/**/*.ts"
|
|
106
|
-
],
|
|
107
|
-
"exclude": [
|
|
108
|
-
"src/types/*",
|
|
109
|
-
"src/exceptions/*",
|
|
110
|
-
"src/commands/*"
|
|
111
|
-
],
|
|
112
|
-
"reporter": [
|
|
113
|
-
"text-summary",
|
|
114
|
-
"html"
|
|
115
|
-
],
|
|
116
|
-
"report-dir": "./tests/coverage",
|
|
117
|
-
"check-coverage": true
|
|
118
|
-
},
|
|
119
|
-
"husky": {
|
|
120
|
-
"hooks": {
|
|
121
|
-
"prepare-commit-msg": "lint-staged && exec < /dev/tty && git cz --hook || true"
|
|
113
|
+
"reporter": [
|
|
114
|
+
"text-summary",
|
|
115
|
+
"html"
|
|
116
|
+
],
|
|
117
|
+
"report-dir": "./tests/coverage",
|
|
118
|
+
"check-coverage": true
|
|
119
|
+
},
|
|
120
|
+
"husky": {
|
|
121
|
+
"hooks": {
|
|
122
|
+
"prepare-commit-msg": "lint-staged && exec < /dev/tty && git cz --hook || true"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"lint-staged": {
|
|
126
|
+
"*.ts": [
|
|
127
|
+
"eslint --fix",
|
|
128
|
+
"git add"
|
|
129
|
+
],
|
|
130
|
+
"*.json": [
|
|
131
|
+
"prettier --write",
|
|
132
|
+
"git add"
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
"config": {
|
|
136
|
+
"commitizen": {
|
|
137
|
+
"path": "./node_modules/cz-conventional-changelog"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"prettier": {
|
|
141
|
+
"singleQuote": true,
|
|
142
|
+
"trailingComma": "none",
|
|
143
|
+
"arrowParens": "avoid",
|
|
144
|
+
"endOfLine": "lf",
|
|
145
|
+
"semi": false,
|
|
146
|
+
"printWidth": 80,
|
|
147
|
+
"overrides": [
|
|
148
|
+
{
|
|
149
|
+
"files": "tests/**/*",
|
|
150
|
+
"options": {
|
|
151
|
+
"printWidth": 120
|
|
122
152
|
}
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
"eslintIgnore": [],
|
|
157
|
+
"eslintConfig": {
|
|
158
|
+
"env": {
|
|
159
|
+
"es2021": true,
|
|
160
|
+
"node": true
|
|
123
161
|
},
|
|
124
|
-
"
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
"*.json": [
|
|
130
|
-
"prettier --write",
|
|
131
|
-
"git add"
|
|
132
|
-
]
|
|
162
|
+
"globals": {
|
|
163
|
+
"ioc": true,
|
|
164
|
+
"Env": true,
|
|
165
|
+
"Path": true,
|
|
166
|
+
"Config": true
|
|
133
167
|
},
|
|
134
|
-
"
|
|
135
|
-
|
|
136
|
-
|
|
168
|
+
"plugins": [
|
|
169
|
+
"prettier",
|
|
170
|
+
"@typescript-eslint"
|
|
171
|
+
],
|
|
172
|
+
"extends": [
|
|
173
|
+
"standard",
|
|
174
|
+
"eslint:recommended",
|
|
175
|
+
"plugin:prettier/recommended",
|
|
176
|
+
"plugin:@typescript-eslint/recommended",
|
|
177
|
+
"plugin:@typescript-eslint/eslint-recommended"
|
|
178
|
+
],
|
|
179
|
+
"parser": "@typescript-eslint/parser",
|
|
180
|
+
"rules": {
|
|
181
|
+
"camelcase": "off",
|
|
182
|
+
"dot-notation": "off",
|
|
183
|
+
"prettier/prettier": "error",
|
|
184
|
+
"no-useless-constructor": "off",
|
|
185
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
186
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
187
|
+
"@typescript-eslint/no-unused-vars": [
|
|
188
|
+
"error",
|
|
189
|
+
{
|
|
190
|
+
"argsIgnorePattern": "^_",
|
|
191
|
+
"varsIgnorePattern": "^_",
|
|
192
|
+
"caughtErrorsIgnorePattern": "^_"
|
|
137
193
|
}
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
"athenna": {
|
|
198
|
+
"templates": {
|
|
199
|
+
"controller": "./templates/controller.edge",
|
|
200
|
+
"interceptor": "./templates/interceptor.edge",
|
|
201
|
+
"middleware": "./templates/middleware.edge",
|
|
202
|
+
"terminator": "./templates/terminator.edge",
|
|
203
|
+
"command": "@athenna/artisan/templates/command.edge"
|
|
138
204
|
},
|
|
139
|
-
"
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
},
|
|
155
|
-
"eslintIgnore": [],
|
|
156
|
-
"eslintConfig": {
|
|
157
|
-
"env": {
|
|
158
|
-
"es2021": true,
|
|
159
|
-
"node": true
|
|
160
|
-
},
|
|
161
|
-
"globals": {
|
|
162
|
-
"ioc": true,
|
|
163
|
-
"Env": true,
|
|
164
|
-
"Path": true,
|
|
165
|
-
"Config": true
|
|
166
|
-
},
|
|
167
|
-
"plugins": [
|
|
168
|
-
"prettier",
|
|
169
|
-
"@typescript-eslint"
|
|
170
|
-
],
|
|
171
|
-
"extends": [
|
|
172
|
-
"standard",
|
|
173
|
-
"eslint:recommended",
|
|
174
|
-
"plugin:prettier/recommended",
|
|
175
|
-
"plugin:@typescript-eslint/recommended",
|
|
176
|
-
"plugin:@typescript-eslint/eslint-recommended"
|
|
177
|
-
],
|
|
178
|
-
"parser": "@typescript-eslint/parser",
|
|
179
|
-
"rules": {
|
|
180
|
-
"camelcase": "off",
|
|
181
|
-
"dot-notation": "off",
|
|
182
|
-
"prettier/prettier": "error",
|
|
183
|
-
"no-useless-constructor": "off",
|
|
184
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
185
|
-
"@typescript-eslint/no-empty-function": "off",
|
|
186
|
-
"@typescript-eslint/no-unused-vars": [
|
|
187
|
-
"error",
|
|
188
|
-
{
|
|
189
|
-
"argsIgnorePattern": "^_",
|
|
190
|
-
"varsIgnorePattern": "^_",
|
|
191
|
-
"caughtErrorsIgnorePattern": "^_"
|
|
192
|
-
}
|
|
193
|
-
]
|
|
194
|
-
}
|
|
205
|
+
"controllers": [
|
|
206
|
+
"#tests/fixtures/controllers/HelloController",
|
|
207
|
+
"#tests/fixtures/controllers/AnnotatedController"
|
|
208
|
+
],
|
|
209
|
+
"middlewares": [
|
|
210
|
+
"#tests/fixtures/middlewares/MyMiddleware",
|
|
211
|
+
"#tests/fixtures/middlewares/ImportedMiddleware"
|
|
212
|
+
],
|
|
213
|
+
"namedMiddlewares": {
|
|
214
|
+
"myMiddleware": "#tests/fixtures/middlewares/MyMiddleware",
|
|
215
|
+
"myInterceptor": "#tests/fixtures/middlewares/MyInterceptor",
|
|
216
|
+
"myTerminator": "#tests/fixtures/middlewares/MyTerminator",
|
|
217
|
+
"not-found-middleware": "#tests/fixtures/middlewares/AnnotatedMiddleware",
|
|
218
|
+
"not-found-interceptor": "#tests/fixtures/middlewares/AnnotatedInterceptor",
|
|
219
|
+
"not-found-terminator": "#tests/fixtures/middlewares/AnnotatedTerminator"
|
|
195
220
|
},
|
|
196
|
-
"
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
"#tests/fixtures/controllers/HelloController",
|
|
206
|
-
"#tests/fixtures/controllers/AnnotatedController"
|
|
207
|
-
],
|
|
208
|
-
"middlewares": [
|
|
209
|
-
"#tests/fixtures/middlewares/MyMiddleware",
|
|
210
|
-
"#tests/fixtures/middlewares/ImportedMiddleware"
|
|
211
|
-
],
|
|
212
|
-
"namedMiddlewares": {
|
|
213
|
-
"myMiddleware": "#tests/fixtures/middlewares/MyMiddleware",
|
|
214
|
-
"myInterceptor": "#tests/fixtures/middlewares/MyInterceptor",
|
|
215
|
-
"myTerminator": "#tests/fixtures/middlewares/MyTerminator",
|
|
216
|
-
"not-found-middleware": "#tests/fixtures/middlewares/AnnotatedMiddleware",
|
|
217
|
-
"not-found-interceptor": "#tests/fixtures/middlewares/AnnotatedInterceptor",
|
|
218
|
-
"not-found-terminator": "#tests/fixtures/middlewares/AnnotatedTerminator"
|
|
219
|
-
},
|
|
220
|
-
"globalMiddlewares": [
|
|
221
|
-
"#tests/fixtures/middlewares/MyMiddleware",
|
|
222
|
-
"#tests/fixtures/middlewares/MyInterceptor",
|
|
223
|
-
"#tests/fixtures/middlewares/MyTerminator",
|
|
224
|
-
"#tests/fixtures/middlewares/AnnotatedGlobalMiddleware",
|
|
225
|
-
"#tests/fixtures/middlewares/AnnotatedGlobalInterceptor",
|
|
226
|
-
"#tests/fixtures/middlewares/AnnotatedGlobalTerminator"
|
|
227
|
-
]
|
|
228
|
-
}
|
|
221
|
+
"globalMiddlewares": [
|
|
222
|
+
"#tests/fixtures/middlewares/MyMiddleware",
|
|
223
|
+
"#tests/fixtures/middlewares/MyInterceptor",
|
|
224
|
+
"#tests/fixtures/middlewares/MyTerminator",
|
|
225
|
+
"#tests/fixtures/middlewares/AnnotatedGlobalMiddleware",
|
|
226
|
+
"#tests/fixtures/middlewares/AnnotatedGlobalInterceptor",
|
|
227
|
+
"#tests/fixtures/middlewares/AnnotatedGlobalTerminator"
|
|
228
|
+
]
|
|
229
|
+
}
|
|
229
230
|
}
|
|
@@ -46,7 +46,7 @@ export class RouteListCommand extends BaseCommand {
|
|
|
46
46
|
* Resolve the http routes file.
|
|
47
47
|
*/
|
|
48
48
|
async resolveRoute() {
|
|
49
|
-
await Module.resolve(Config.get('rc.commands.route:list.route', '#routes/http'), this.
|
|
49
|
+
await Module.resolve(Config.get('rc.commands.route:list.route', '#routes/http'), this.getParentURL());
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Get the http kernel module from RC file or resolve the default one.
|
|
@@ -55,12 +55,12 @@ export class RouteListCommand extends BaseCommand {
|
|
|
55
55
|
if (!Config.exists('rc.commands.route:list.kernel')) {
|
|
56
56
|
return HttpKernel;
|
|
57
57
|
}
|
|
58
|
-
return Module.resolve(Config.get('rc.commands.route:list.kernel'), this.
|
|
58
|
+
return Module.resolve(Config.get('rc.commands.route:list.kernel'), this.getParentURL());
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
-
* Get the
|
|
61
|
+
* Get the parent URL of the project.
|
|
62
62
|
*/
|
|
63
|
-
|
|
64
|
-
return Config.get('rc.
|
|
63
|
+
getParentURL() {
|
|
64
|
+
return Config.get('rc.parentURL', Path.toHref(Path.pwd() + sep));
|
|
65
65
|
}
|
|
66
66
|
}
|
package/src/context/Request.js
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ declare module 'fastify' {
|
|
|
31
31
|
operationId?: string;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
export * from '
|
|
34
|
+
export * from '#src/types';
|
|
35
35
|
export * from '#src/context/Request';
|
|
36
36
|
export * from '#src/context/Response';
|
|
37
37
|
export * from '#src/annotations/Controller';
|
package/src/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
export * from '
|
|
9
|
+
export * from '#src/types';
|
|
10
10
|
export * from '#src/context/Request';
|
|
11
11
|
export * from '#src/context/Response';
|
|
12
12
|
export * from '#src/annotations/Controller';
|
package/src/router/Route.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Is, Route as RouteHelper } from '@athenna/common';
|
|
9
|
+
import { Is, Options, Route as RouteHelper } from '@athenna/common';
|
|
10
10
|
import { UndefinedMethodException } from '#src/exceptions/UndefinedMethodException';
|
|
11
11
|
import { NotFoundMiddlewareException } from '#src/exceptions/NotFoundMiddlewareException';
|
|
12
12
|
export class Route {
|
|
@@ -362,7 +362,10 @@ export class Route {
|
|
|
362
362
|
* })
|
|
363
363
|
* ```
|
|
364
364
|
*/
|
|
365
|
-
response(statusCode, response
|
|
365
|
+
response(statusCode, response) {
|
|
366
|
+
response = Options.create(response, {
|
|
367
|
+
description: `Status code ${statusCode} response`
|
|
368
|
+
});
|
|
366
369
|
if (!this.route.fastify.schema.response) {
|
|
367
370
|
this.route.fastify.schema.response = {};
|
|
368
371
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
/// <reference types="node" resolution-mode="require"/>
|
|
10
10
|
import type { InjectOptions, FastifyInstance, PrintRoutesOptions, FastifyListenOptions, FastifyServerOptions, LightMyRequestChain, LightMyRequestResponse } from 'fastify';
|
|
11
|
-
import type { RouteJson, ErrorHandler, RequestHandler, InterceptHandler, TerminateHandler } from '#src/types';
|
|
11
|
+
import type { RouteJson, ErrorHandler, RequestHandler, InterceptHandler, TerminateHandler, SwaggerDocument } from '#src/types';
|
|
12
12
|
import type { AddressInfo } from 'node:net';
|
|
13
13
|
export declare class ServerImpl {
|
|
14
14
|
/**
|
|
@@ -43,13 +43,13 @@ export declare class ServerImpl {
|
|
|
43
43
|
* Get the fastify version that is running the server.
|
|
44
44
|
*/
|
|
45
45
|
getFastifyVersion(): string;
|
|
46
|
-
getSwagger():
|
|
46
|
+
getSwagger(): Promise<SwaggerDocument>;
|
|
47
47
|
getSwagger(options: {
|
|
48
48
|
yaml: true;
|
|
49
|
-
}): string
|
|
49
|
+
}): Promise<string>;
|
|
50
50
|
getSwagger(options: {
|
|
51
51
|
yaml: false;
|
|
52
|
-
}):
|
|
52
|
+
}): Promise<SwaggerDocument>;
|
|
53
53
|
/**
|
|
54
54
|
* Set the error handler to handle errors that happens inside the server.
|
|
55
55
|
*/
|
package/src/server/ServerImpl.js
CHANGED
|
@@ -54,13 +54,14 @@ export class ServerImpl {
|
|
|
54
54
|
* @fastify/swagger plugin in the server. If the plugin is not installed
|
|
55
55
|
* will return null.
|
|
56
56
|
*/
|
|
57
|
-
getSwagger(options) {
|
|
57
|
+
async getSwagger(options) {
|
|
58
58
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
59
59
|
// @ts-ignore
|
|
60
60
|
const swagger = this.fastify.swagger;
|
|
61
61
|
if (!swagger) {
|
|
62
62
|
return null;
|
|
63
63
|
}
|
|
64
|
+
await this.fastify.ready();
|
|
64
65
|
return swagger(options);
|
|
65
66
|
}
|
|
66
67
|
/**
|
package/src/types/index.d.ts
CHANGED
package/src/types/index.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @athenna/http
|
|
3
|
+
*
|
|
4
|
+
* (c) João Lenon <lenon@athenna.io>
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
import type { OpenAPI } from 'openapi-types';
|
|
10
|
+
export type SwaggerDocument = OpenAPI.Document;
|