@athenna/http 3.0.10 → 3.1.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/build/Commands/MakeControllerCommand.d.ts +15 -0
- package/build/Commands/MakeControllerCommand.js +42 -0
- package/build/Commands/MakeInterceptorCommand.d.ts +15 -0
- package/build/Commands/MakeInterceptorCommand.js +42 -0
- package/build/Commands/MakeMiddlewareCommand.d.ts +15 -0
- package/build/Commands/MakeMiddlewareCommand.js +42 -0
- package/build/Commands/MakeTerminatorCommand.d.ts +15 -0
- package/build/Commands/MakeTerminatorCommand.js +42 -0
- package/build/Commands/RouteListCommand.d.ts +19 -0
- package/build/Commands/RouteListCommand.js +62 -0
- package/build/Context/Request.d.ts +144 -0
- package/build/Context/Request.js +219 -0
- package/build/Context/Response.d.ts +67 -0
- package/build/Context/Response.js +102 -0
- package/build/Contracts/InterceptorContract.d.ts +15 -0
- package/build/Contracts/InterceptorContract.js +9 -0
- package/build/Contracts/MiddlewareContract.d.ts +15 -0
- package/build/Contracts/MiddlewareContract.js +9 -0
- package/build/Contracts/TerminatorContract.d.ts +15 -0
- package/build/Contracts/TerminatorContract.js +9 -0
- package/build/Decorators/Controller.d.ts +14 -0
- package/build/Decorators/Controller.js +28 -0
- package/build/Decorators/Interceptor.d.ts +14 -0
- package/build/Decorators/Interceptor.js +37 -0
- package/build/Decorators/Middleware.d.ts +14 -0
- package/build/Decorators/Middleware.js +37 -0
- package/build/Decorators/Terminator.d.ts +14 -0
- package/build/Decorators/Terminator.js +37 -0
- package/build/Exceptions/BadGatewayException.d.ts +20 -0
- package/build/Exceptions/BadGatewayException.js +22 -0
- package/build/Exceptions/BadRequestException.d.ts +20 -0
- package/build/Exceptions/BadRequestException.js +22 -0
- package/build/Exceptions/ForbiddenException.d.ts +20 -0
- package/build/Exceptions/ForbiddenException.js +22 -0
- package/build/Exceptions/HttpException.d.ts +20 -0
- package/build/Exceptions/HttpException.js +27 -0
- package/build/Exceptions/InternalServerException.d.ts +20 -0
- package/build/Exceptions/InternalServerException.js +22 -0
- package/build/Exceptions/MethodNotAllowedException.d.ts +20 -0
- package/build/Exceptions/MethodNotAllowedException.js +22 -0
- package/build/Exceptions/NotAcceptableException.d.ts +20 -0
- package/build/Exceptions/NotAcceptableException.js +22 -0
- package/build/Exceptions/NotFoundException.d.ts +20 -0
- package/build/Exceptions/NotFoundException.js +22 -0
- package/build/Exceptions/NotImplementedException.d.ts +20 -0
- package/build/Exceptions/NotImplementedException.js +22 -0
- package/build/Exceptions/PayloadTooLargeException.d.ts +20 -0
- package/build/Exceptions/PayloadTooLargeException.js +22 -0
- package/build/Exceptions/RequestTimeoutException.d.ts +20 -0
- package/build/Exceptions/RequestTimeoutException.js +22 -0
- package/build/Exceptions/ServiceUnavailableException.d.ts +20 -0
- package/build/Exceptions/ServiceUnavailableException.js +22 -0
- package/build/Exceptions/UnauthorizedException.d.ts +20 -0
- package/build/Exceptions/UnauthorizedException.js +22 -0
- package/build/Exceptions/UndefinedMethodException.d.ts +12 -0
- package/build/Exceptions/UndefinedMethodException.js +19 -0
- package/build/Exceptions/UnprocessableEntityException.d.ts +20 -0
- package/build/Exceptions/UnprocessableEntityException.js +22 -0
- package/build/Facades/Route.d.ts +10 -0
- package/{src → build}/Facades/Route.js +2 -7
- package/build/Facades/Server.d.ts +10 -0
- package/{src → build}/Facades/Server.js +2 -7
- package/build/Handlers/FastifyHandler.d.ts +41 -0
- package/build/Handlers/FastifyHandler.js +116 -0
- package/build/Handlers/HttpExceptionHandler.d.ts +31 -0
- package/build/Handlers/HttpExceptionHandler.js +82 -0
- package/build/Kernels/HttpKernel.d.ts +73 -0
- package/build/Kernels/HttpKernel.js +221 -0
- package/build/Providers/HttpRouteProvider.d.ts +12 -0
- package/build/Providers/HttpRouteProvider.js +15 -0
- package/build/Providers/HttpServerProvider.d.ts +13 -0
- package/build/Providers/HttpServerProvider.js +25 -0
- package/build/Router/Route.d.ts +263 -0
- package/build/Router/Route.js +447 -0
- package/build/Router/RouteGroup.d.ts +96 -0
- package/build/Router/RouteGroup.js +123 -0
- package/build/Router/RouteResource.d.ts +108 -0
- package/build/Router/RouteResource.js +158 -0
- package/build/Router/Router.d.ts +103 -0
- package/build/Router/Router.js +188 -0
- package/build/Server/ServerImpl.d.ts +129 -0
- package/build/Server/ServerImpl.js +213 -0
- package/build/Types/Contexts/Context.d.ts +20 -0
- package/build/Types/Contexts/Context.js +9 -0
- package/build/Types/Contexts/ErrorContext.d.ts +21 -0
- package/build/Types/Contexts/ErrorContext.js +9 -0
- package/build/Types/Contexts/InterceptContext.d.ts +20 -0
- package/build/Types/Contexts/InterceptContext.js +9 -0
- package/build/Types/Contexts/TerminateContext.d.ts +21 -0
- package/build/Types/Contexts/TerminateContext.js +9 -0
- package/build/Types/Controllers/ControllerOptions.d.ts +25 -0
- package/build/Types/Controllers/ControllerOptions.js +9 -0
- package/build/Types/Middlewares/InterceptorRouteType.d.ts +11 -0
- package/build/Types/Middlewares/InterceptorRouteType.js +9 -0
- package/build/Types/Middlewares/MiddlewareHandler.d.ts +20 -0
- package/build/Types/Middlewares/MiddlewareHandler.js +9 -0
- package/build/Types/Middlewares/MiddlewareOptions.d.ts +40 -0
- package/build/Types/Middlewares/MiddlewareOptions.js +9 -0
- package/build/Types/Middlewares/MiddlewareRouteType.d.ts +11 -0
- package/build/Types/Middlewares/MiddlewareRouteType.js +9 -0
- package/build/Types/Middlewares/TerminatorRouteType.d.ts +11 -0
- package/build/Types/Middlewares/TerminatorRouteType.js +9 -0
- package/build/Types/Router/RouteHandler.d.ts +10 -0
- package/build/Types/Router/RouteHandler.js +9 -0
- package/build/Types/Router/RouteJSON.d.ts +21 -0
- package/build/Types/Router/RouteJSON.js +9 -0
- package/build/Types/Router/RouteResourceTypes.d.ts +9 -0
- package/build/Types/Router/RouteResourceTypes.js +9 -0
- package/build/index.d.ts +70 -0
- package/build/index.js +48 -0
- package/package.json +159 -76
- package/templates/controller.edge +8 -36
- package/templates/interceptor.edge +8 -0
- package/templates/middleware.edge +4 -36
- package/templates/terminator.edge +6 -0
- package/src/Commands/Make/Controller.js +0 -64
- package/src/Commands/Make/Middleware.js +0 -80
- package/src/Commands/Route/List.js +0 -107
- package/src/Context/Request.js +0 -223
- package/src/Context/Response.js +0 -137
- package/src/Exceptions/BadGatewayException.js +0 -31
- package/src/Exceptions/BadRequestException.js +0 -31
- package/src/Exceptions/ForbiddenException.js +0 -31
- package/src/Exceptions/HttpException.js +0 -33
- package/src/Exceptions/InternalServerException.js +0 -31
- package/src/Exceptions/MethodNotAllowedException.js +0 -31
- package/src/Exceptions/NotAcceptableException.js +0 -31
- package/src/Exceptions/NotFoundException.js +0 -31
- package/src/Exceptions/NotImplementedException.js +0 -31
- package/src/Exceptions/PayloadTooLargeException.js +0 -31
- package/src/Exceptions/RequestTimeoutException.js +0 -31
- package/src/Exceptions/ServiceUnavailableException.js +0 -31
- package/src/Exceptions/UnauthorizedException.js +0 -31
- package/src/Exceptions/UndefinedMethodException.js +0 -30
- package/src/Exceptions/UnprocessableEntityException.js +0 -31
- package/src/Handlers/FastifyHandler.js +0 -148
- package/src/Handlers/HttpExceptionHandler.js +0 -88
- package/src/Helpers/HttpLoader.js +0 -38
- package/src/Kernels/HttpKernel.js +0 -199
- package/src/Providers/ControllerProvider.js +0 -29
- package/src/Providers/HttpRouteProvider.js +0 -24
- package/src/Providers/HttpServerProvider.js +0 -37
- package/src/Providers/MiddlewareProvider.js +0 -29
- package/src/Router/Route.js +0 -417
- package/src/Router/RouteGroup.js +0 -119
- package/src/Router/RouteResource.js +0 -247
- package/src/Router/Router.js +0 -313
- package/src/Utils/isMiddlewareContract.js +0 -17
- package/src/Utils/removeSlashes.js +0 -30
- package/src/index.d.ts +0 -1331
- package/src/index.js +0 -377
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@athenna/http",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "The Athenna Http server. Built on top of fastify.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "João Lenon <lenon@athenna.io>",
|
|
@@ -12,102 +12,126 @@
|
|
|
12
12
|
"router",
|
|
13
13
|
"cors",
|
|
14
14
|
"ctx",
|
|
15
|
+
"helmet",
|
|
16
|
+
"swagger",
|
|
15
17
|
"exception-handling",
|
|
16
18
|
"rate-limiting",
|
|
17
19
|
"middlewares",
|
|
20
|
+
"terminators",
|
|
21
|
+
"interceptors",
|
|
18
22
|
"http-server",
|
|
19
23
|
"athenna",
|
|
20
24
|
"esm"
|
|
21
25
|
],
|
|
22
26
|
"scripts": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
27
|
+
"node": "cross-env NODE_OPTIONS=\"--experimental-import-meta-resolve\" ts-node",
|
|
28
|
+
"build": "npm run node --silent -- bin/build.ts",
|
|
29
|
+
"artisan": "npm run node --silent -- bin/artisan.ts",
|
|
30
|
+
"lint:fix": "eslint \"{src,tests}/**/*.ts\" --fix",
|
|
31
|
+
"test": "npm run --silent lint:fix && npm run node --silent -- bin/test.ts",
|
|
32
|
+
"test:debug": "cross-env DEBUG=api:* npm run node --silent -- bin/test.ts --inspect",
|
|
33
|
+
"test:coverage": "c8 npm run --silent test"
|
|
28
34
|
},
|
|
29
35
|
"files": [
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
36
|
+
"build/*.js",
|
|
37
|
+
"build/*.d.ts",
|
|
38
|
+
"build/**/*.js",
|
|
39
|
+
"build/**/*.d.ts",
|
|
34
40
|
"templates/*",
|
|
35
41
|
"templates/**/*"
|
|
36
42
|
],
|
|
37
43
|
"type": "module",
|
|
38
|
-
"main": "./
|
|
44
|
+
"main": "./build/index.js",
|
|
45
|
+
"types": "./build/index.d.ts",
|
|
39
46
|
"exports": {
|
|
40
|
-
".": "./
|
|
41
|
-
"./
|
|
42
|
-
"./
|
|
43
|
-
"./
|
|
44
|
-
"./
|
|
45
|
-
"./
|
|
46
|
-
"./
|
|
47
|
-
"./commands/
|
|
48
|
-
"./commands/Make/Controller": "./src/Commands/Make/Controller.js",
|
|
49
|
-
"./commands/Make/Middleware": "./src/Commands/Make/Middleware.js"
|
|
47
|
+
".": "./build/index.js",
|
|
48
|
+
"./providers/HttpRouteProvider": "./build/Providers/HttpRouteProvider.js",
|
|
49
|
+
"./providers/HttpServerProvider": "./build/Providers/HttpServerProvider.js",
|
|
50
|
+
"./commands/RouteListCommand": "./build/Commands/RouteListCommand.js",
|
|
51
|
+
"./commands/MakeControllerCommand": "./build/Commands/MakeControllerCommand.js",
|
|
52
|
+
"./commands/MakeMiddlewareCommand": "./build/Commands/MakeMiddlewareCommand.js",
|
|
53
|
+
"./commands/MakeTerminatorCommand": "./build/Commands/MakeTerminatorCommand.js",
|
|
54
|
+
"./commands/MakeInterceptorCommand": "./build/Commands/MakeInterceptorCommand.js"
|
|
50
55
|
},
|
|
51
|
-
"types": "./src/index.d.ts",
|
|
52
56
|
"imports": {
|
|
53
|
-
"#src/*": "./
|
|
54
|
-
"#
|
|
57
|
+
"#src/*": "./build/*.js",
|
|
58
|
+
"#src": "./build/index.js",
|
|
59
|
+
"#tests/*": "./tests/*.js",
|
|
60
|
+
"#tests": "./tests/index.js"
|
|
55
61
|
},
|
|
56
62
|
"dependencies": {
|
|
57
|
-
"fastify": "4.
|
|
63
|
+
"fastify": "^4.13.0"
|
|
58
64
|
},
|
|
59
65
|
"devDependencies": {
|
|
60
|
-
"@athenna/artisan": "3.0.
|
|
61
|
-
"@athenna/common": "3.0.
|
|
62
|
-
"@athenna/config": "3.0.
|
|
63
|
-
"@athenna/ioc": "3.0.
|
|
64
|
-
"@athenna/logger": "3.0.
|
|
65
|
-
"@
|
|
66
|
-
"@fastify/
|
|
67
|
-
"@fastify/
|
|
68
|
-
"@fastify/
|
|
69
|
-
"@fastify/swagger
|
|
70
|
-
"@
|
|
71
|
-
"@japa/
|
|
72
|
-
"@japa/
|
|
73
|
-
"@japa/
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
66
|
+
"@athenna/artisan": "^3.0.0",
|
|
67
|
+
"@athenna/common": "^3.0.0",
|
|
68
|
+
"@athenna/config": "^3.0.0",
|
|
69
|
+
"@athenna/ioc": "^3.0.0",
|
|
70
|
+
"@athenna/logger": "^3.0.0",
|
|
71
|
+
"@athenna/view": "^3.0.0",
|
|
72
|
+
"@fastify/cors": "^8.1.1",
|
|
73
|
+
"@fastify/helmet": "^10.0.2",
|
|
74
|
+
"@fastify/rate-limit": "^7.5.0",
|
|
75
|
+
"@fastify/swagger": "^8.1.0",
|
|
76
|
+
"@fastify/swagger-ui": "^1.1.0",
|
|
77
|
+
"@japa/assert": "^1.3.6",
|
|
78
|
+
"@japa/run-failed-tests": "^1.1.0",
|
|
79
|
+
"@japa/runner": "^2.2.2",
|
|
80
|
+
"@japa/spec-reporter": "^1.3.2",
|
|
81
|
+
"@swc/core": "^1.3.27",
|
|
82
|
+
"@types/bytes": "^3.1.1",
|
|
83
|
+
"@types/callsite": "^1.0.31",
|
|
84
|
+
"@types/columnify": "^1.5.1",
|
|
85
|
+
"@types/debug": "^4.1.7",
|
|
86
|
+
"@types/figlet": "^1.5.5",
|
|
87
|
+
"@types/inquirer": "^9.0.3",
|
|
88
|
+
"@types/kind-of": "^6.0.0",
|
|
89
|
+
"@types/lodash": "^4.14.191",
|
|
90
|
+
"@types/ms": "^0.7.31",
|
|
91
|
+
"@types/pluralize": "^0.0.29",
|
|
92
|
+
"@types/sinon": "^10.0.13",
|
|
93
|
+
"@types/uuid": "^9.0.0",
|
|
94
|
+
"@typescript-eslint/eslint-plugin": "^5.48.1",
|
|
95
|
+
"@typescript-eslint/parser": "^5.48.1",
|
|
96
|
+
"c8": "^7.12.0",
|
|
97
|
+
"cls-rtracer": "^2.6.2",
|
|
98
|
+
"commitizen": "^4.2.6",
|
|
99
|
+
"cross-env": "^7.0.3",
|
|
100
|
+
"cz-conventional-changelog": "^3.3.0",
|
|
101
|
+
"eslint": "^8.32.0",
|
|
102
|
+
"eslint-config-prettier": "^8.6.0",
|
|
103
|
+
"eslint-config-standard": "^17.0.0",
|
|
104
|
+
"eslint-plugin-import": "^2.27.5",
|
|
105
|
+
"eslint-plugin-n": "^15.6.1",
|
|
106
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
107
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
108
|
+
"husky": "^3.1.0",
|
|
109
|
+
"js-yaml": "^4.1.0",
|
|
110
|
+
"lint-staged": "^12.5.0",
|
|
111
|
+
"minimist": "^1.2.7",
|
|
112
|
+
"prettier": "^2.8.3",
|
|
113
|
+
"reflect-metadata": "^0.1.13",
|
|
114
|
+
"rimraf": "^3.0.2",
|
|
115
|
+
"sinon": "^15.0.1",
|
|
116
|
+
"ts-node": "^10.9.1",
|
|
117
|
+
"typescript": "^4.9.4"
|
|
92
118
|
},
|
|
93
119
|
"c8": {
|
|
94
120
|
"all": true,
|
|
95
121
|
"include": [
|
|
96
|
-
"src/**/*.
|
|
122
|
+
"src/**/*.ts"
|
|
97
123
|
],
|
|
98
124
|
"exclude": [
|
|
99
|
-
"src/
|
|
125
|
+
"src/Types/*",
|
|
126
|
+
"src/Contracts/*",
|
|
127
|
+
"src/Exceptions/*"
|
|
100
128
|
],
|
|
101
129
|
"reporter": [
|
|
102
130
|
"text-summary",
|
|
103
131
|
"html"
|
|
104
132
|
],
|
|
105
133
|
"report-dir": "./tests/Coverage",
|
|
106
|
-
"check-coverage": true
|
|
107
|
-
"statements": "70",
|
|
108
|
-
"branches": "70",
|
|
109
|
-
"functions": "70",
|
|
110
|
-
"lines": "70"
|
|
134
|
+
"check-coverage": true
|
|
111
135
|
},
|
|
112
136
|
"husky": {
|
|
113
137
|
"hooks": {
|
|
@@ -115,7 +139,7 @@
|
|
|
115
139
|
}
|
|
116
140
|
},
|
|
117
141
|
"lint-staged": {
|
|
118
|
-
"*.
|
|
142
|
+
"*.ts": [
|
|
119
143
|
"eslint --fix",
|
|
120
144
|
"git add"
|
|
121
145
|
],
|
|
@@ -145,34 +169,93 @@
|
|
|
145
169
|
}
|
|
146
170
|
]
|
|
147
171
|
},
|
|
172
|
+
"eslintIgnore": [
|
|
173
|
+
"build/**/*"
|
|
174
|
+
],
|
|
148
175
|
"eslintConfig": {
|
|
149
176
|
"env": {
|
|
150
177
|
"es2021": true,
|
|
151
178
|
"node": true
|
|
152
179
|
},
|
|
153
180
|
"globals": {
|
|
154
|
-
"ioc": true
|
|
181
|
+
"ioc": true,
|
|
182
|
+
"Env": true,
|
|
183
|
+
"Path": true,
|
|
184
|
+
"Config": true
|
|
155
185
|
},
|
|
156
186
|
"plugins": [
|
|
157
|
-
"prettier"
|
|
187
|
+
"prettier",
|
|
188
|
+
"@typescript-eslint"
|
|
158
189
|
],
|
|
159
190
|
"extends": [
|
|
160
191
|
"standard",
|
|
161
192
|
"eslint:recommended",
|
|
162
|
-
"plugin:prettier/recommended"
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
"**/*.d.ts"
|
|
193
|
+
"plugin:prettier/recommended",
|
|
194
|
+
"plugin:@typescript-eslint/recommended",
|
|
195
|
+
"plugin:@typescript-eslint/eslint-recommended"
|
|
166
196
|
],
|
|
167
|
-
"
|
|
168
|
-
"ecmaVersion": "latest",
|
|
169
|
-
"sourceType": "module"
|
|
170
|
-
},
|
|
197
|
+
"parser": "@typescript-eslint/parser",
|
|
171
198
|
"rules": {
|
|
172
199
|
"camelcase": "off",
|
|
173
200
|
"dot-notation": "off",
|
|
174
201
|
"prettier/prettier": "error",
|
|
175
|
-
"no-useless-constructor": "off"
|
|
202
|
+
"no-useless-constructor": "off",
|
|
203
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
204
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
205
|
+
"@typescript-eslint/no-unused-vars": [
|
|
206
|
+
"error",
|
|
207
|
+
{
|
|
208
|
+
"argsIgnorePattern": "^_",
|
|
209
|
+
"varsIgnorePattern": "^_",
|
|
210
|
+
"caughtErrorsIgnorePattern": "^_"
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"athenna": {
|
|
216
|
+
"preloads": [],
|
|
217
|
+
"services": [],
|
|
218
|
+
"providers": [],
|
|
219
|
+
"commands": [
|
|
220
|
+
"#src/Commands/MakeControllerCommand",
|
|
221
|
+
"#src/Commands/MakeInterceptorCommand",
|
|
222
|
+
"#src/Commands/MakeMiddlewareCommand",
|
|
223
|
+
"#src/Commands/MakeTerminatorCommand",
|
|
224
|
+
"#src/Commands/RouteListCommand"
|
|
225
|
+
],
|
|
226
|
+
"controllers": [
|
|
227
|
+
"#tests/Stubs/controllers/HelloController",
|
|
228
|
+
"#tests/Stubs/controllers/DecoratedController"
|
|
229
|
+
],
|
|
230
|
+
"middlewares": [
|
|
231
|
+
"#tests/Stubs/middlewares/Middleware",
|
|
232
|
+
"#tests/Stubs/middlewares/ImportedMiddleware",
|
|
233
|
+
"#tests/Stubs/middlewares/DecoratedMiddleware",
|
|
234
|
+
"#tests/Stubs/middlewares/DecoratedInterceptor",
|
|
235
|
+
"#tests/Stubs/middlewares/DecoratedTerminator"
|
|
236
|
+
],
|
|
237
|
+
"namedMiddlewares": {
|
|
238
|
+
"middleware": "#tests/Stubs/middlewares/Middleware",
|
|
239
|
+
"interceptor": "#tests/Stubs/middlewares/Interceptor",
|
|
240
|
+
"terminator": "#tests/Stubs/middlewares/Terminator",
|
|
241
|
+
"not-found-middleware": "#tests/Stubs/middlewares/DecoratedMiddleware",
|
|
242
|
+
"not-found-interceptor": "#tests/Stubs/middlewares/DecoratedInterceptor",
|
|
243
|
+
"not-found-terminator": "#tests/Stubs/middlewares/DecoratedTerminator"
|
|
244
|
+
},
|
|
245
|
+
"globalMiddlewares": [
|
|
246
|
+
"#tests/Stubs/middlewares/Middleware",
|
|
247
|
+
"#tests/Stubs/middlewares/Interceptor",
|
|
248
|
+
"#tests/Stubs/middlewares/Terminator",
|
|
249
|
+
"#tests/Stubs/middlewares/DecoratedGlobalMiddleware",
|
|
250
|
+
"#tests/Stubs/middlewares/DecoratedGlobalInterceptor",
|
|
251
|
+
"#tests/Stubs/middlewares/DecoratedGlobalTerminator"
|
|
252
|
+
],
|
|
253
|
+
"commandsManifest": {
|
|
254
|
+
"route:list": "#src/Commands/RouteListCommand",
|
|
255
|
+
"make:controller": "#src/Commands/MakeControllerCommand",
|
|
256
|
+
"make:interceptor": "#src/Commands/MakeInterceptorCommand",
|
|
257
|
+
"make:middleware": "#src/Commands/MakeMiddlewareCommand",
|
|
258
|
+
"make:terminator": "#src/Commands/MakeTerminatorCommand"
|
|
176
259
|
}
|
|
177
260
|
}
|
|
178
261
|
}
|
|
@@ -1,52 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Resolve any dependency of the service container
|
|
4
|
-
* inside the constructor.
|
|
5
|
-
*/
|
|
6
|
-
constructor() {}
|
|
1
|
+
import { Context, Controller } from '@athenna/http'
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* @param {import('@athenna/http').ContextContract} ctx
|
|
12
|
-
*/
|
|
13
|
-
async index({ response }) {
|
|
3
|
+
@Controller()
|
|
4
|
+
export class {{ namePascal }} {
|
|
5
|
+
public async index({ response }: Context): Promise<void> {
|
|
14
6
|
return response.status(200).send([{}])
|
|
15
7
|
}
|
|
16
8
|
|
|
17
|
-
|
|
18
|
-
* Store method
|
|
19
|
-
*
|
|
20
|
-
* @param {import('@athenna/http').ContextContract} ctx
|
|
21
|
-
*/
|
|
22
|
-
async store({ response }) {
|
|
9
|
+
public async store({ response }: Context): Promise<void> {
|
|
23
10
|
return response.status(201).send({})
|
|
24
11
|
}
|
|
25
12
|
|
|
26
|
-
|
|
27
|
-
* Show method
|
|
28
|
-
*
|
|
29
|
-
* @param {import('@athenna/http').ContextContract} ctx
|
|
30
|
-
*/
|
|
31
|
-
async show({ response }) {
|
|
13
|
+
public async show({ response }: Context): Promise<void> {
|
|
32
14
|
return response.status(200).send({})
|
|
33
15
|
}
|
|
34
16
|
|
|
35
|
-
|
|
36
|
-
* Update method
|
|
37
|
-
*
|
|
38
|
-
* @param {import('@athenna/http').ContextContract} ctx
|
|
39
|
-
*/
|
|
40
|
-
async update({ response, params }) {
|
|
17
|
+
public async update({ response, params }: Context): Promise<void> {
|
|
41
18
|
return response.status(200).send({ id: params.id })
|
|
42
19
|
}
|
|
43
20
|
|
|
44
|
-
|
|
45
|
-
* Delete method
|
|
46
|
-
*
|
|
47
|
-
* @param {import('@athenna/http').ContextContract} ctx
|
|
48
|
-
*/
|
|
49
|
-
async delete({ response }) {
|
|
21
|
+
public async delete({ response }: Context): Promise<void> {
|
|
50
22
|
return response.status(204)
|
|
51
23
|
}
|
|
52
24
|
}
|
|
@@ -1,38 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Resolve any dependency of the service container
|
|
4
|
-
* inside the constructor.
|
|
5
|
-
*/
|
|
6
|
-
constructor() {}
|
|
1
|
+
import { Context, Middleware, MiddlewareContract } from '@athenna/http'
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
* @param {import('@athenna/http').HandleContextContract} ctx
|
|
13
|
-
* @return {Promise<void>}
|
|
14
|
-
*/
|
|
15
|
-
async handle(ctx) {}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Intercept method is executed before the response
|
|
19
|
-
* has been sent.
|
|
20
|
-
*
|
|
21
|
-
* @param {import('@athenna/http').InterceptContextContract} ctx
|
|
22
|
-
* @return {Promise<any>}
|
|
23
|
-
*/
|
|
24
|
-
async intercept({ body }) {
|
|
25
|
-
body.intercepted = true
|
|
26
|
-
|
|
27
|
-
return body
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Terminate method is executed after the response
|
|
32
|
-
* has been sent.
|
|
33
|
-
*
|
|
34
|
-
* @param {import('@athenna/http').TerminateContextContract} ctx
|
|
35
|
-
* @return {Promise<void>}
|
|
36
|
-
*/
|
|
37
|
-
async terminate(ctx) {}
|
|
3
|
+
@Middleware()
|
|
4
|
+
export class {{ namePascal }} implements MiddlewareContract {
|
|
5
|
+
public async handle(ctx: Context): Promise<void> {}
|
|
38
6
|
}
|
|
@@ -1,64 +0,0 @@
|
|
|
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
|
-
|
|
10
|
-
import { Path } from '@athenna/common'
|
|
11
|
-
import { Command } from '@athenna/artisan'
|
|
12
|
-
|
|
13
|
-
export class MakeController extends Command {
|
|
14
|
-
/**
|
|
15
|
-
* The name and signature of the console command.
|
|
16
|
-
*
|
|
17
|
-
* @return {string}
|
|
18
|
-
*/
|
|
19
|
-
get signature() {
|
|
20
|
-
return 'make:controller <name>'
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The console command description.
|
|
25
|
-
*
|
|
26
|
-
* @return {string}
|
|
27
|
-
*/
|
|
28
|
-
get description() {
|
|
29
|
-
return 'Make a new controller file.'
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Set additional flags in the commander instance.
|
|
34
|
-
* This method is executed when registering your command.
|
|
35
|
-
*
|
|
36
|
-
* @param {import('commander').Command} commander
|
|
37
|
-
* @return {import('commander').Command}
|
|
38
|
-
*/
|
|
39
|
-
addFlags(commander) {
|
|
40
|
-
return commander.option(
|
|
41
|
-
'--no-lint',
|
|
42
|
-
'Do not run eslint in the controller.',
|
|
43
|
-
true,
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Execute the console command.
|
|
49
|
-
*
|
|
50
|
-
* @param {string} name
|
|
51
|
-
* @param {any} options
|
|
52
|
-
* @return {Promise<void>}
|
|
53
|
-
*/
|
|
54
|
-
async handle(name, options) {
|
|
55
|
-
const resource = 'Controller'
|
|
56
|
-
const path = Path.http(`Controllers/${name}.${Path.ext()}`)
|
|
57
|
-
|
|
58
|
-
this.title(`MAKING ${resource}\n`, 'bold', 'green')
|
|
59
|
-
|
|
60
|
-
const file = await this.makeFile(path, 'controller', options.lint)
|
|
61
|
-
|
|
62
|
-
this.success(`${resource} ({yellow} "${file.name}") successfully created.`)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
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
|
-
|
|
10
|
-
import { Path, String } from '@athenna/common'
|
|
11
|
-
import { Artisan, Command, FilePropertiesHelper } from '@athenna/artisan'
|
|
12
|
-
|
|
13
|
-
export class MakeMiddleware extends Command {
|
|
14
|
-
/**
|
|
15
|
-
* The name and signature of the console command.
|
|
16
|
-
*
|
|
17
|
-
* @return {string}
|
|
18
|
-
*/
|
|
19
|
-
get signature() {
|
|
20
|
-
return 'make:middleware <name>'
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The console command description.
|
|
25
|
-
*
|
|
26
|
-
* @return {string}
|
|
27
|
-
*/
|
|
28
|
-
get description() {
|
|
29
|
-
return 'Make a new middleware file.'
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Set additional flags in the commander instance.
|
|
34
|
-
* This method is executed when registering your command.
|
|
35
|
-
*
|
|
36
|
-
* @param {import('commander').Command} commander
|
|
37
|
-
* @return {import('commander').Command}
|
|
38
|
-
*/
|
|
39
|
-
addFlags(commander) {
|
|
40
|
-
return commander
|
|
41
|
-
.option(
|
|
42
|
-
'--no-register',
|
|
43
|
-
'Do not register the middleware inside Kernel.',
|
|
44
|
-
true,
|
|
45
|
-
)
|
|
46
|
-
.option('--no-lint', 'Do not run eslint in the middleware.', true)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Execute the console command.
|
|
51
|
-
*
|
|
52
|
-
* @param {string} name
|
|
53
|
-
* @param {any} options
|
|
54
|
-
* @return {Promise<void>}
|
|
55
|
-
*/
|
|
56
|
-
async handle(name, options) {
|
|
57
|
-
const resource = 'Middleware'
|
|
58
|
-
const path = Path.http(`Middlewares/${name}.${Path.ext()}`)
|
|
59
|
-
|
|
60
|
-
this.title(`MAKING ${resource}\n`, 'bold', 'green')
|
|
61
|
-
|
|
62
|
-
const file = await this.makeFile(path, 'middleware', options.lint)
|
|
63
|
-
|
|
64
|
-
this.success(`${resource} ({yellow} "${file.name}") successfully created.`)
|
|
65
|
-
|
|
66
|
-
if (options.register) {
|
|
67
|
-
const path = Path.http(`Kernel.${Path.ext()}`)
|
|
68
|
-
|
|
69
|
-
await FilePropertiesHelper.addContentToObjectGetter(
|
|
70
|
-
path,
|
|
71
|
-
'namedMiddlewares',
|
|
72
|
-
`${String.toCamelCase(
|
|
73
|
-
file.name,
|
|
74
|
-
)}: import('#app/Http/Middlewares/${name}')`,
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
await Artisan.call(`eslint:fix ${path} --quiet`)
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|