@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.
Files changed (151) hide show
  1. package/build/Commands/MakeControllerCommand.d.ts +15 -0
  2. package/build/Commands/MakeControllerCommand.js +42 -0
  3. package/build/Commands/MakeInterceptorCommand.d.ts +15 -0
  4. package/build/Commands/MakeInterceptorCommand.js +42 -0
  5. package/build/Commands/MakeMiddlewareCommand.d.ts +15 -0
  6. package/build/Commands/MakeMiddlewareCommand.js +42 -0
  7. package/build/Commands/MakeTerminatorCommand.d.ts +15 -0
  8. package/build/Commands/MakeTerminatorCommand.js +42 -0
  9. package/build/Commands/RouteListCommand.d.ts +19 -0
  10. package/build/Commands/RouteListCommand.js +62 -0
  11. package/build/Context/Request.d.ts +144 -0
  12. package/build/Context/Request.js +219 -0
  13. package/build/Context/Response.d.ts +67 -0
  14. package/build/Context/Response.js +102 -0
  15. package/build/Contracts/InterceptorContract.d.ts +15 -0
  16. package/build/Contracts/InterceptorContract.js +9 -0
  17. package/build/Contracts/MiddlewareContract.d.ts +15 -0
  18. package/build/Contracts/MiddlewareContract.js +9 -0
  19. package/build/Contracts/TerminatorContract.d.ts +15 -0
  20. package/build/Contracts/TerminatorContract.js +9 -0
  21. package/build/Decorators/Controller.d.ts +14 -0
  22. package/build/Decorators/Controller.js +28 -0
  23. package/build/Decorators/Interceptor.d.ts +14 -0
  24. package/build/Decorators/Interceptor.js +37 -0
  25. package/build/Decorators/Middleware.d.ts +14 -0
  26. package/build/Decorators/Middleware.js +37 -0
  27. package/build/Decorators/Terminator.d.ts +14 -0
  28. package/build/Decorators/Terminator.js +37 -0
  29. package/build/Exceptions/BadGatewayException.d.ts +20 -0
  30. package/build/Exceptions/BadGatewayException.js +22 -0
  31. package/build/Exceptions/BadRequestException.d.ts +20 -0
  32. package/build/Exceptions/BadRequestException.js +22 -0
  33. package/build/Exceptions/ForbiddenException.d.ts +20 -0
  34. package/build/Exceptions/ForbiddenException.js +22 -0
  35. package/build/Exceptions/HttpException.d.ts +20 -0
  36. package/build/Exceptions/HttpException.js +27 -0
  37. package/build/Exceptions/InternalServerException.d.ts +20 -0
  38. package/build/Exceptions/InternalServerException.js +22 -0
  39. package/build/Exceptions/MethodNotAllowedException.d.ts +20 -0
  40. package/build/Exceptions/MethodNotAllowedException.js +22 -0
  41. package/build/Exceptions/NotAcceptableException.d.ts +20 -0
  42. package/build/Exceptions/NotAcceptableException.js +22 -0
  43. package/build/Exceptions/NotFoundException.d.ts +20 -0
  44. package/build/Exceptions/NotFoundException.js +22 -0
  45. package/build/Exceptions/NotImplementedException.d.ts +20 -0
  46. package/build/Exceptions/NotImplementedException.js +22 -0
  47. package/build/Exceptions/PayloadTooLargeException.d.ts +20 -0
  48. package/build/Exceptions/PayloadTooLargeException.js +22 -0
  49. package/build/Exceptions/RequestTimeoutException.d.ts +20 -0
  50. package/build/Exceptions/RequestTimeoutException.js +22 -0
  51. package/build/Exceptions/ServiceUnavailableException.d.ts +20 -0
  52. package/build/Exceptions/ServiceUnavailableException.js +22 -0
  53. package/build/Exceptions/UnauthorizedException.d.ts +20 -0
  54. package/build/Exceptions/UnauthorizedException.js +22 -0
  55. package/build/Exceptions/UndefinedMethodException.d.ts +12 -0
  56. package/build/Exceptions/UndefinedMethodException.js +19 -0
  57. package/build/Exceptions/UnprocessableEntityException.d.ts +20 -0
  58. package/build/Exceptions/UnprocessableEntityException.js +22 -0
  59. package/build/Facades/Route.d.ts +10 -0
  60. package/{src → build}/Facades/Route.js +2 -7
  61. package/build/Facades/Server.d.ts +10 -0
  62. package/{src → build}/Facades/Server.js +2 -7
  63. package/build/Handlers/FastifyHandler.d.ts +41 -0
  64. package/build/Handlers/FastifyHandler.js +116 -0
  65. package/build/Handlers/HttpExceptionHandler.d.ts +31 -0
  66. package/build/Handlers/HttpExceptionHandler.js +82 -0
  67. package/build/Kernels/HttpKernel.d.ts +73 -0
  68. package/build/Kernels/HttpKernel.js +221 -0
  69. package/build/Providers/HttpRouteProvider.d.ts +12 -0
  70. package/build/Providers/HttpRouteProvider.js +15 -0
  71. package/build/Providers/HttpServerProvider.d.ts +13 -0
  72. package/build/Providers/HttpServerProvider.js +25 -0
  73. package/build/Router/Route.d.ts +263 -0
  74. package/build/Router/Route.js +447 -0
  75. package/build/Router/RouteGroup.d.ts +96 -0
  76. package/build/Router/RouteGroup.js +123 -0
  77. package/build/Router/RouteResource.d.ts +108 -0
  78. package/build/Router/RouteResource.js +158 -0
  79. package/build/Router/Router.d.ts +103 -0
  80. package/build/Router/Router.js +188 -0
  81. package/build/Server/ServerImpl.d.ts +129 -0
  82. package/build/Server/ServerImpl.js +213 -0
  83. package/build/Types/Contexts/Context.d.ts +20 -0
  84. package/build/Types/Contexts/Context.js +9 -0
  85. package/build/Types/Contexts/ErrorContext.d.ts +21 -0
  86. package/build/Types/Contexts/ErrorContext.js +9 -0
  87. package/build/Types/Contexts/InterceptContext.d.ts +20 -0
  88. package/build/Types/Contexts/InterceptContext.js +9 -0
  89. package/build/Types/Contexts/TerminateContext.d.ts +21 -0
  90. package/build/Types/Contexts/TerminateContext.js +9 -0
  91. package/build/Types/Controllers/ControllerOptions.d.ts +25 -0
  92. package/build/Types/Controllers/ControllerOptions.js +9 -0
  93. package/build/Types/Middlewares/InterceptorRouteType.d.ts +11 -0
  94. package/build/Types/Middlewares/InterceptorRouteType.js +9 -0
  95. package/build/Types/Middlewares/MiddlewareHandler.d.ts +20 -0
  96. package/build/Types/Middlewares/MiddlewareHandler.js +9 -0
  97. package/build/Types/Middlewares/MiddlewareOptions.d.ts +40 -0
  98. package/build/Types/Middlewares/MiddlewareOptions.js +9 -0
  99. package/build/Types/Middlewares/MiddlewareRouteType.d.ts +11 -0
  100. package/build/Types/Middlewares/MiddlewareRouteType.js +9 -0
  101. package/build/Types/Middlewares/TerminatorRouteType.d.ts +11 -0
  102. package/build/Types/Middlewares/TerminatorRouteType.js +9 -0
  103. package/build/Types/Router/RouteHandler.d.ts +10 -0
  104. package/build/Types/Router/RouteHandler.js +9 -0
  105. package/build/Types/Router/RouteJSON.d.ts +21 -0
  106. package/build/Types/Router/RouteJSON.js +9 -0
  107. package/build/Types/Router/RouteResourceTypes.d.ts +9 -0
  108. package/build/Types/Router/RouteResourceTypes.js +9 -0
  109. package/build/index.d.ts +70 -0
  110. package/build/index.js +48 -0
  111. package/package.json +159 -76
  112. package/templates/controller.edge +8 -36
  113. package/templates/interceptor.edge +8 -0
  114. package/templates/middleware.edge +4 -36
  115. package/templates/terminator.edge +6 -0
  116. package/src/Commands/Make/Controller.js +0 -64
  117. package/src/Commands/Make/Middleware.js +0 -80
  118. package/src/Commands/Route/List.js +0 -107
  119. package/src/Context/Request.js +0 -223
  120. package/src/Context/Response.js +0 -137
  121. package/src/Exceptions/BadGatewayException.js +0 -31
  122. package/src/Exceptions/BadRequestException.js +0 -31
  123. package/src/Exceptions/ForbiddenException.js +0 -31
  124. package/src/Exceptions/HttpException.js +0 -33
  125. package/src/Exceptions/InternalServerException.js +0 -31
  126. package/src/Exceptions/MethodNotAllowedException.js +0 -31
  127. package/src/Exceptions/NotAcceptableException.js +0 -31
  128. package/src/Exceptions/NotFoundException.js +0 -31
  129. package/src/Exceptions/NotImplementedException.js +0 -31
  130. package/src/Exceptions/PayloadTooLargeException.js +0 -31
  131. package/src/Exceptions/RequestTimeoutException.js +0 -31
  132. package/src/Exceptions/ServiceUnavailableException.js +0 -31
  133. package/src/Exceptions/UnauthorizedException.js +0 -31
  134. package/src/Exceptions/UndefinedMethodException.js +0 -30
  135. package/src/Exceptions/UnprocessableEntityException.js +0 -31
  136. package/src/Handlers/FastifyHandler.js +0 -148
  137. package/src/Handlers/HttpExceptionHandler.js +0 -88
  138. package/src/Helpers/HttpLoader.js +0 -38
  139. package/src/Kernels/HttpKernel.js +0 -199
  140. package/src/Providers/ControllerProvider.js +0 -29
  141. package/src/Providers/HttpRouteProvider.js +0 -24
  142. package/src/Providers/HttpServerProvider.js +0 -37
  143. package/src/Providers/MiddlewareProvider.js +0 -29
  144. package/src/Router/Route.js +0 -417
  145. package/src/Router/RouteGroup.js +0 -119
  146. package/src/Router/RouteResource.js +0 -247
  147. package/src/Router/Router.js +0 -313
  148. package/src/Utils/isMiddlewareContract.js +0 -17
  149. package/src/Utils/removeSlashes.js +0 -30
  150. package/src/index.d.ts +0 -1331
  151. package/src/index.js +0 -377
@@ -1,107 +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 { Command } from '@athenna/artisan'
11
- import { Module, Path, String } from '@athenna/common'
12
-
13
- import { Route } from '#src/index'
14
-
15
- export class RouteList extends Command {
16
- /**
17
- * The name and signature of the console command.
18
- *
19
- * @return {string}
20
- */
21
- get signature() {
22
- return 'route:list'
23
- }
24
-
25
- /**
26
- * The console command description.
27
- *
28
- * @return {string}
29
- */
30
- get description() {
31
- return 'List all the routes of your application.'
32
- }
33
-
34
- /**
35
- * Set additional flags in the commander instance.
36
- * This method is executed when registering your command.
37
- *
38
- * @param {import('commander').Command} commander
39
- * @return {import('commander').Command}
40
- */
41
- addFlags(commander) {
42
- return commander.option(
43
- '-m, --middleware',
44
- 'List the middlewares of each route.',
45
- false,
46
- )
47
- }
48
-
49
- /**
50
- * Execute the console command.
51
- *
52
- * @param {any} options
53
- * @return {Promise<void>}
54
- */
55
- async handle(options) {
56
- this.title('ROUTE LISTING\n', 'bold', 'green')
57
-
58
- const Kernel = await Module.getFrom(Path.http(`Kernel.${Path.ext()}`))
59
-
60
- const kernel = new Kernel()
61
-
62
- await kernel.registerCors()
63
- await kernel.registerTracer()
64
- await kernel.registerRateLimit()
65
- await kernel.registerMiddlewares()
66
- await kernel.registerErrorHandler()
67
- await kernel.registerLogMiddleware()
68
-
69
- const routePath = Path.routes(`http.${Path.ext()}`)
70
-
71
- await import(routePath)
72
- const routes = Route.listRoutes()
73
-
74
- const header = ['Method', 'Route', 'Handler']
75
- const rows = []
76
-
77
- if (options.middleware) header.push('Middlewares')
78
-
79
- routes.forEach(route => {
80
- const row = [route.methods.join('|'), route.url, 'Closure']
81
-
82
- if (options.middleware) {
83
- let middlewares = ''
84
-
85
- Object.keys(route.middlewares).forEach(key => {
86
- if (route.middlewares[key].length) {
87
- const number = route.middlewares[key].length
88
-
89
- if (middlewares) {
90
- middlewares = middlewares + '\n'
91
- }
92
-
93
- middlewares = middlewares + `${String.toPascalCase(key)}: ${number}`
94
- }
95
- })
96
-
97
- if (!middlewares) middlewares = 'Not found'
98
-
99
- row.push(middlewares)
100
- }
101
-
102
- rows.push(row)
103
- })
104
-
105
- this.log(this.createTable({ head: header }, ...rows))
106
- }
107
- }
@@ -1,223 +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 { Config } from '@athenna/config'
11
- import { Is, Json } from '@athenna/common'
12
- import { Server } from '#src/index'
13
-
14
- export class Request {
15
- /**
16
- * Fastify request object.
17
- *
18
- * @type {import('fastify').FastifyRequest}
19
- */
20
- #request
21
-
22
- /**
23
- * Create a new instance of Request.
24
- *
25
- * @param {import('fastify').FastifyRequest} request
26
- * @return {Request}
27
- */
28
- constructor(request) {
29
- this.#request = request
30
- }
31
-
32
- /**
33
- * Get the request ip.
34
- *
35
- * @return {string}
36
- */
37
- get ip() {
38
- return this.#request.ip
39
- }
40
-
41
- /**
42
- * Get the request method.
43
- *
44
- * @return {string}
45
- */
46
- get method() {
47
- return this.#request.method
48
- }
49
-
50
- /**
51
- * Get the host url from request.
52
- *
53
- * @return {string}
54
- */
55
- get hostUrl() {
56
- const port = Config.get('http.port', Server.getPort())
57
- let host = Config.get('http.domain', `http://localhost:${port}`)
58
-
59
- if (!Is.Ip(host) && !host.includes('localhost')) {
60
- host = host.replace(`:${port}`, '')
61
- }
62
-
63
- return host.concat(this.originalUrl)
64
- }
65
-
66
- /**
67
- * Get the base request url.
68
- *
69
- * @return {string}
70
- */
71
- get baseUrl() {
72
- return this.#request.url.split('?')[0]
73
- }
74
-
75
- /**
76
- * Get the original request url.
77
- *
78
- * @return {string}
79
- */
80
- get originalUrl() {
81
- return this.#request.url
82
- }
83
-
84
- /**
85
- * Get all body from request.
86
- *
87
- * @return {any}
88
- */
89
- get body() {
90
- return this.#request.body || {}
91
- }
92
-
93
- /**
94
- * Get all params from request.
95
- *
96
- * @return {any}
97
- */
98
- get params() {
99
- return this.#request.params || {}
100
- }
101
-
102
- /**
103
- * Get all queries from request.
104
- *
105
- * @return {any}
106
- */
107
- get queries() {
108
- return this.#request.query || {}
109
- }
110
-
111
- /**
112
- * Get all headers from request.
113
- *
114
- * @return {any}
115
- */
116
- get headers() {
117
- return this.#request.headers || {}
118
- }
119
-
120
- /**
121
- * Get a value from the request params or the default value.
122
- *
123
- * @param {string} param
124
- * @param {string} [defaultValue]
125
- * @return {any}
126
- */
127
- param(param, defaultValue) {
128
- return this.params[param] || defaultValue
129
- }
130
-
131
- /**
132
- * Get a value from the request query param or the default value.
133
- *
134
- * @param {string} query
135
- * @param {string} [defaultValue]
136
- * @return {any}
137
- */
138
- query(query, defaultValue) {
139
- return this.queries[query] || defaultValue
140
- }
141
-
142
- /**
143
- * Get a value from the request header or the default value.
144
- *
145
- * @param {string} header
146
- * @param {string} [defaultValue]
147
- * @return {any}
148
- */
149
- header(header, defaultValue) {
150
- return this.headers[header] || defaultValue
151
- }
152
-
153
- /**
154
- * Get only the selected values from the request body.
155
- *
156
- * @param {string} keys
157
- * @return {any}
158
- */
159
- only(...keys) {
160
- const body = {}
161
-
162
- Object.keys(this.body).forEach(key => {
163
- if (!keys.includes(key)) {
164
- return
165
- }
166
-
167
- body[key] = this.body[key]
168
- })
169
-
170
- return body
171
- }
172
-
173
- /**
174
- * Get all the values from the request body except the selected ones.
175
- *
176
- * @param {string[]} keys
177
- * @return {any}
178
- */
179
- except(...keys) {
180
- const body = {}
181
-
182
- Object.keys(this.body).forEach(key => {
183
- if (keys.includes(key)) {
184
- return
185
- }
186
-
187
- body[key] = this.body[key]
188
- })
189
-
190
- return body
191
- }
192
-
193
- /**
194
- * Get a value from the request body or the default value.
195
- *
196
- * @param {string} key
197
- * @param {string} [defaultValue]
198
- * @return {any}
199
- */
200
- input(key, defaultValue) {
201
- return this.payload(key, defaultValue)
202
- }
203
-
204
- /**
205
- * Get a value from the request body or the default value.
206
- *
207
- * @param {string} key
208
- * @param {string} [defaultValue]
209
- * @return {any}
210
- */
211
- payload(key, defaultValue) {
212
- return Json.get(this.body, key, defaultValue)
213
- }
214
-
215
- /**
216
- * Get the default fastify request object.
217
- *
218
- * @return {import('fastify').FastifyRequest}
219
- */
220
- getFastifyRequest() {
221
- return this.#request
222
- }
223
- }
@@ -1,137 +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
- export class Response {
11
- /**
12
- * Fastify response object.
13
- *
14
- * @type {import('fastify').FastifyReply}
15
- */
16
- #response
17
-
18
- /**
19
- * Create a new instance of Response.
20
- *
21
- * @param {import('fastify').FastifyReply} response
22
- * @return {Response}
23
- */
24
- constructor(response) {
25
- this.#response = response
26
- }
27
-
28
- /**
29
- * Terminate the request sending the response body.
30
- *
31
- * @param {any} [data]
32
- * @return {void}
33
- */
34
- send(data) {
35
- this.#response.send(data)
36
- }
37
-
38
- /**
39
- * Terminate the request sending the response body.
40
- *
41
- * @param {any} [data]
42
- * @return {void}
43
- */
44
- json(data) {
45
- this.#response.send(data)
46
- }
47
-
48
- /**
49
- * Apply helmet in response.
50
- *
51
- * @param {import('@fastify/helmet').FastifyHelmetOptions} [options]
52
- * @return {void}
53
- */
54
- async helmet(options) {
55
- await this.#response.helmet(options)
56
-
57
- return this
58
- }
59
-
60
- /**
61
- * Set the response status code.
62
- *
63
- * @param {number} code
64
- * @return {Response}
65
- */
66
- status(code) {
67
- this.#response.status(code)
68
-
69
- return this
70
- }
71
-
72
- /**
73
- * Remove some header from the response.
74
- *
75
- * @param {string} header
76
- * @return {Response}
77
- */
78
- removeHeader(header) {
79
- this.#response.removeHeader(header)
80
-
81
- return this
82
- }
83
-
84
- /**
85
- * Add some header to the response.
86
- *
87
- * @param {string} header
88
- * @param {any} value
89
- * @return {Response}
90
- */
91
- header(header, value) {
92
- this.#response.header(header, value)
93
-
94
- return this
95
- }
96
-
97
- /**
98
- * Only add some header to the response if it's not defined yet.
99
- *
100
- * @param {string} header
101
- * @param {any} value
102
- * @return {Response}
103
- */
104
- safeHeader(header, value) {
105
- if (!this.#response.hasHeader(header)) {
106
- this.#response.header(header, value)
107
- }
108
-
109
- return this
110
- }
111
-
112
- /**
113
- * Redirect the response to other url with different status code.
114
- *
115
- * @param {string} url
116
- * @param {number} [statusCode]
117
- * @return {void}
118
- */
119
- redirectTo(url, statusCode) {
120
- if (statusCode) {
121
- this.#response.redirect(statusCode, url)
122
-
123
- return
124
- }
125
-
126
- this.#response.redirect(url)
127
- }
128
-
129
- /**
130
- * Get the default fastify response object.
131
- *
132
- * @return {import('fastify').FastifyReply}
133
- */
134
- getFastifyResponse() {
135
- return this.#response
136
- }
137
- }
@@ -1,31 +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 { HttpException } from '#src/Exceptions/HttpException'
11
-
12
- export class BadGatewayException extends HttpException {
13
- /**
14
- * Creates a new instance of BadGatewayException.
15
- *
16
- * @example
17
- * throw new BadGatewayException()
18
- * This exception uses the 502 status code and the "E_BAD_GATEWAY_ERROR" code.
19
- *
20
- * @param {string} [content]
21
- * @param {string} [code]
22
- * @param {string|null} [help]
23
- */
24
- constructor(
25
- content = 'Bad gateway error',
26
- code = 'E_BAD_GATEWAY_ERROR',
27
- help = null,
28
- ) {
29
- super(content, 502, code, help)
30
- }
31
- }
@@ -1,31 +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 { HttpException } from '#src/Exceptions/HttpException'
11
-
12
- export class BadRequestException extends HttpException {
13
- /**
14
- * Creates a new instance of BadRequestException.
15
- *
16
- * @example
17
- * throw new BadRequestException()
18
- * This exception uses the 400 status code and the "E_BAD_REQUEST_ERROR" code.
19
- *
20
- * @param {string} [content]
21
- * @param {string} [code]
22
- * @param {string|null} [help]
23
- */
24
- constructor(
25
- content = 'Bad request error',
26
- code = 'E_BAD_REQUEST_ERROR',
27
- help = null,
28
- ) {
29
- super(content, 400, code, help)
30
- }
31
- }
@@ -1,31 +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 { HttpException } from '#src/Exceptions/HttpException'
11
-
12
- export class ForbiddenException extends HttpException {
13
- /**
14
- * Creates a new instance of ForbiddenException.
15
- *
16
- * @example
17
- * throw new ForbiddenException()
18
- * This exception uses the 403 status code and the "E_FORBIDDEN_ERROR" code.
19
- *
20
- * @param {string} [content]
21
- * @param {string} [code]
22
- * @param {string|null} [help]
23
- */
24
- constructor(
25
- content = 'Forbidden error',
26
- code = 'E_FORBIDDEN_ERROR',
27
- help = null,
28
- ) {
29
- super(content, 403, code, help)
30
- }
31
- }
@@ -1,33 +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 { Exception } from '@athenna/common'
11
-
12
- export class HttpException extends Exception {
13
- /**
14
- * Creates a new instance of HttpException.
15
- *
16
- * @example
17
- * throw new HttpException()
18
- * This exception uses the 500 status code and the "E_HTTP_ERROR" code.
19
- *
20
- * @param {string} [content]
21
- * @param {number} [status]
22
- * @param {string} [code]
23
- * @param {string|null} [help]
24
- */
25
- constructor(
26
- content = 'Http error',
27
- status = 500,
28
- code = 'E_HTTP_ERROR',
29
- help = null,
30
- ) {
31
- super(content, status, code, help)
32
- }
33
- }
@@ -1,31 +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 { HttpException } from '#src/Exceptions/HttpException'
11
-
12
- export class InternalServerException extends HttpException {
13
- /**
14
- * Creates a new instance of InternalServerException.
15
- *
16
- * @example
17
- * throw new InternalServerException()
18
- * This exception uses the 500 status code and the "E_INTERNAL_ERROR" code.
19
- *
20
- * @param {string} [content]
21
- * @param {string} [code]
22
- * @param {string|null} [help]
23
- */
24
- constructor(
25
- content = 'Internal server error',
26
- code = 'E_INTERNAL_ERROR',
27
- help = null,
28
- ) {
29
- super(content, 500, code, help)
30
- }
31
- }
@@ -1,31 +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 { HttpException } from '#src/Exceptions/HttpException'
11
-
12
- export class MethodNotAllowedException extends HttpException {
13
- /**
14
- * Creates a new instance of MethodNotAllowedException.
15
- *
16
- * @example
17
- * throw new MethodNotAllowedException()
18
- * This exception uses the 405 status code and the "E_METHOD_NOT_ALLOWED_ERROR" code.
19
- *
20
- * @param {string} [content]
21
- * @param {string} [code]
22
- * @param {string|null} [help]
23
- */
24
- constructor(
25
- content = 'Method not allowed error',
26
- code = 'E_METHOD_NOT_ALLOWED_ERROR',
27
- help = null,
28
- ) {
29
- super(content, 405, code, help)
30
- }
31
- }
@@ -1,31 +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 { HttpException } from '#src/Exceptions/HttpException'
11
-
12
- export class NotAcceptableException extends HttpException {
13
- /**
14
- * Creates a new instance of NotAcceptableException.
15
- *
16
- * @example
17
- * throw new NotAcceptableException()
18
- * This exception uses the 406 status code and the "E_NOT_ACCEPTABLE_ERROR" code.
19
- *
20
- * @param {string} [content]
21
- * @param {string} [code]
22
- * @param {string|null} [help]
23
- */
24
- constructor(
25
- content = 'Not acceptable error',
26
- code = 'E_NOT_ACCEPTABLE_ERROR',
27
- help = null,
28
- ) {
29
- super(content, 406, code, help)
30
- }
31
- }