@athenna/http 3.10.0 → 4.0.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 (126) hide show
  1. package/package.json +238 -234
  2. package/src/{Decorators → annotations}/Controller.d.ts +1 -1
  3. package/src/{Decorators → annotations}/Controller.js +2 -0
  4. package/src/{Decorators → annotations}/Interceptor.d.ts +2 -2
  5. package/src/{Decorators → annotations}/Interceptor.js +5 -2
  6. package/src/{Decorators → annotations}/Middleware.d.ts +1 -1
  7. package/src/{Decorators → annotations}/Middleware.js +4 -1
  8. package/src/{Decorators → annotations}/Terminator.d.ts +2 -2
  9. package/src/{Decorators → annotations}/Terminator.js +5 -2
  10. package/src/{Commands → commands}/MakeControllerCommand.js +0 -1
  11. package/src/{Commands → commands}/MakeInterceptorCommand.js +0 -1
  12. package/src/{Commands → commands}/MakeMiddlewareCommand.js +0 -1
  13. package/src/{Commands → commands}/MakeTerminatorCommand.js +0 -1
  14. package/src/{Context → context}/Request.d.ts +1 -1
  15. package/src/{Context → context}/Request.js +0 -4
  16. package/src/{Context → context}/Response.d.ts +2 -2
  17. package/src/{Context → context}/Response.js +0 -4
  18. package/src/debug/index.d.ts +10 -0
  19. package/src/debug/index.js +10 -0
  20. package/src/{Exceptions → exceptions}/BadGatewayException.d.ts +1 -1
  21. package/src/{Exceptions → exceptions}/BadGatewayException.js +1 -1
  22. package/src/{Exceptions → exceptions}/BadRequestException.d.ts +1 -1
  23. package/src/{Exceptions → exceptions}/BadRequestException.js +1 -1
  24. package/src/{Exceptions → exceptions}/ForbiddenException.d.ts +1 -1
  25. package/src/{Exceptions → exceptions}/ForbiddenException.js +1 -1
  26. package/src/{Exceptions → exceptions}/HttpException.d.ts +3 -2
  27. package/src/{Exceptions → exceptions}/InternalServerException.d.ts +1 -1
  28. package/src/{Exceptions → exceptions}/InternalServerException.js +1 -1
  29. package/src/{Exceptions → exceptions}/MethodNotAllowedException.d.ts +1 -1
  30. package/src/{Exceptions → exceptions}/MethodNotAllowedException.js +1 -1
  31. package/src/{Exceptions → exceptions}/NotAcceptableException.d.ts +1 -1
  32. package/src/{Exceptions → exceptions}/NotAcceptableException.js +1 -1
  33. package/src/{Exceptions → exceptions}/NotFoundException.d.ts +1 -1
  34. package/src/{Exceptions → exceptions}/NotFoundException.js +1 -1
  35. package/src/{Exceptions → exceptions}/NotImplementedException.d.ts +1 -1
  36. package/src/{Exceptions → exceptions}/NotImplementedException.js +1 -1
  37. package/src/{Exceptions → exceptions}/PayloadTooLargeException.d.ts +1 -1
  38. package/src/{Exceptions → exceptions}/PayloadTooLargeException.js +1 -1
  39. package/src/{Exceptions → exceptions}/RequestTimeoutException.d.ts +1 -1
  40. package/src/{Exceptions → exceptions}/RequestTimeoutException.js +1 -1
  41. package/src/{Exceptions → exceptions}/ServiceUnavailableException.d.ts +1 -1
  42. package/src/{Exceptions → exceptions}/ServiceUnavailableException.js +1 -1
  43. package/src/{Exceptions → exceptions}/UnauthorizedException.d.ts +1 -1
  44. package/src/{Exceptions → exceptions}/UnauthorizedException.js +1 -1
  45. package/src/{Exceptions → exceptions}/UnprocessableEntityException.d.ts +1 -1
  46. package/src/{Exceptions → exceptions}/UnprocessableEntityException.js +1 -1
  47. package/src/{Facades → facades}/Route.d.ts +2 -2
  48. package/src/{Facades → facades}/Server.d.ts +2 -2
  49. package/src/{Handlers → handlers}/FastifyHandler.d.ts +4 -4
  50. package/src/{Handlers → handlers}/FastifyHandler.js +2 -2
  51. package/src/{Handlers → handlers}/HttpExceptionHandler.d.ts +1 -1
  52. package/src/{Handlers → handlers}/HttpExceptionHandler.js +8 -8
  53. package/src/index.d.ts +32 -40
  54. package/src/index.js +32 -40
  55. package/src/{Kernels → kernels}/HttpKernel.js +16 -2
  56. package/src/{Providers → providers}/HttpRouteProvider.js +1 -1
  57. package/src/{Providers → providers}/HttpServerProvider.js +1 -1
  58. package/src/{Router → router}/Route.d.ts +3 -9
  59. package/src/{Router → router}/Route.js +1 -5
  60. package/src/{Router → router}/RouteGroup.d.ts +3 -5
  61. package/src/{Router → router}/RouteGroup.js +2 -6
  62. package/src/{Router → router}/RouteResource.d.ts +2 -5
  63. package/src/{Router → router}/RouteResource.js +5 -13
  64. package/src/{Router → router}/Router.d.ts +7 -9
  65. package/src/{Router → router}/Router.js +15 -17
  66. package/src/{Server → server}/ServerImpl.d.ts +11 -14
  67. package/src/{Server → server}/ServerImpl.js +1 -9
  68. package/src/{Testing/Plugins → testing/plugins}/index.d.ts +5 -5
  69. package/src/{Testing/Plugins → testing/plugins}/index.js +5 -5
  70. package/src/{Testing/Plugins/Request → testing/plugins/request}/TestRequest.d.ts +2 -2
  71. package/src/{Testing/Plugins/Request → testing/plugins/request}/TestRequest.js +7 -5
  72. package/src/{Testing/Plugins/Request → testing/plugins/request}/TestResponse.d.ts +1 -1
  73. package/src/{Testing/Plugins/Request → testing/plugins/request}/TestResponse.js +1 -8
  74. package/src/{Types/Contexts → types/contexts}/Context.d.ts +2 -2
  75. package/src/types/contexts/Context.js +10 -0
  76. package/src/{Types/Contexts → types/contexts}/ErrorContext.d.ts +2 -2
  77. package/src/{Types/Contexts → types/contexts}/ErrorContext.js +2 -1
  78. package/src/{Types/Contexts → types/contexts}/InterceptContext.d.ts +2 -2
  79. package/src/{Types/Contexts → types/contexts}/InterceptContext.js +2 -1
  80. package/src/{Types/Contexts → types/contexts}/TerminateContext.d.ts +2 -2
  81. package/src/{Types/Contexts → types/contexts}/TerminateContext.js +2 -1
  82. package/src/{Contracts → types/contracts}/InterceptorContract.d.ts +1 -1
  83. package/src/{Contracts → types/contracts}/MiddlewareContract.d.ts +1 -1
  84. package/src/{Contracts → types/contracts}/TerminatorContract.d.ts +1 -1
  85. package/src/types/index.d.ts +24 -0
  86. package/src/types/index.js +24 -0
  87. package/src/{Types/Middlewares → types/middlewares}/InterceptorRouteType.d.ts +2 -2
  88. package/src/{Types/Middlewares → types/middlewares}/MiddlewareHandler.d.ts +3 -3
  89. package/src/{Types/Middlewares → types/middlewares}/MiddlewareRouteType.d.ts +2 -2
  90. package/src/{Types/Middlewares → types/middlewares}/TerminatorRouteType.d.ts +2 -2
  91. package/src/{Types/Router → types/router}/RouteHandler.d.ts +1 -1
  92. package/src/{Types/Router/RouteJSON.d.ts → types/router/RouteJson.d.ts} +3 -4
  93. package/src/Types/Router/RouteJSON.js +0 -9
  94. package/templates/controller.edge +0 -24
  95. package/templates/interceptor.edge +0 -8
  96. package/templates/middleware.edge +0 -6
  97. package/templates/terminator.edge +0 -6
  98. /package/src/{Commands → commands}/MakeControllerCommand.d.ts +0 -0
  99. /package/src/{Commands → commands}/MakeInterceptorCommand.d.ts +0 -0
  100. /package/src/{Commands → commands}/MakeMiddlewareCommand.d.ts +0 -0
  101. /package/src/{Commands → commands}/MakeTerminatorCommand.d.ts +0 -0
  102. /package/src/{Commands → commands}/RouteListCommand.d.ts +0 -0
  103. /package/src/{Commands → commands}/RouteListCommand.js +0 -0
  104. /package/src/{Exceptions → exceptions}/HttpException.js +0 -0
  105. /package/src/{Exceptions → exceptions}/UndefinedMethodException.d.ts +0 -0
  106. /package/src/{Exceptions → exceptions}/UndefinedMethodException.js +0 -0
  107. /package/src/{Facades → facades}/Route.js +0 -0
  108. /package/src/{Facades → facades}/Server.js +0 -0
  109. /package/src/{Kernels → kernels}/HttpKernel.d.ts +0 -0
  110. /package/src/{Providers → providers}/HttpRouteProvider.d.ts +0 -0
  111. /package/src/{Providers → providers}/HttpServerProvider.d.ts +0 -0
  112. /package/src/{Contracts → types/contracts}/InterceptorContract.js +0 -0
  113. /package/src/{Contracts → types/contracts}/MiddlewareContract.js +0 -0
  114. /package/src/{Contracts → types/contracts}/TerminatorContract.js +0 -0
  115. /package/src/{Types/Controllers → types/controllers}/ControllerOptions.d.ts +0 -0
  116. /package/src/{Types/Controllers → types/controllers}/ControllerOptions.js +0 -0
  117. /package/src/{Types/Middlewares → types/middlewares}/InterceptorRouteType.js +0 -0
  118. /package/src/{Types/Middlewares → types/middlewares}/MiddlewareHandler.js +0 -0
  119. /package/src/{Types/Middlewares → types/middlewares}/MiddlewareOptions.d.ts +0 -0
  120. /package/src/{Types/Middlewares → types/middlewares}/MiddlewareOptions.js +0 -0
  121. /package/src/{Types/Middlewares → types/middlewares}/MiddlewareRouteType.js +0 -0
  122. /package/src/{Types/Middlewares → types/middlewares}/TerminatorRouteType.js +0 -0
  123. /package/src/{Types/Router → types/router}/RouteHandler.js +0 -0
  124. /package/src/{Types/Contexts/Context.js → types/router/RouteJson.js} +0 -0
  125. /package/src/{Types/Router → types/router}/RouteResourceTypes.d.ts +0 -0
  126. /package/src/{Types/Router → types/router}/RouteResourceTypes.js +0 -0
@@ -6,4 +6,5 @@
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 {};
9
+ import { Request } from '#src/context/Request';
10
+ import { Response } from '#src/context/Response';
@@ -6,8 +6,8 @@
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 { Request } from '#src/Context/Request';
10
- import { Response } from '#src/Context/Response';
9
+ import { Request } from '#src/context/Request';
10
+ import { Response } from '#src/context/Response';
11
11
  export type TerminateContext = {
12
12
  request: Request;
13
13
  response: Response;
@@ -6,4 +6,5 @@
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 {};
9
+ import { Request } from '#src/context/Request';
10
+ import { Response } from '#src/context/Response';
@@ -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 { InterceptContext } from '#src/Types/Contexts/InterceptContext';
9
+ import type { InterceptContext } from '#src/types/contexts/InterceptContext';
10
10
  export interface InterceptorContract {
11
11
  /**
12
12
  * Intercept the request at the end, before returning the response.
@@ -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 { Context } from '#src/Types/Contexts/Context';
9
+ import type { Context } from '#src/types/contexts/Context';
10
10
  export interface MiddlewareContract {
11
11
  /**
12
12
  * Handle the request before going to the route handler.
@@ -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 { TerminateContext } from '#src/Types/Contexts/TerminateContext';
9
+ import type { TerminateContext } from '#src/types/contexts/TerminateContext';
10
10
  export interface TerminatorContract {
11
11
  /**
12
12
  * Handle the request after the response has been sent.
@@ -0,0 +1,24 @@
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
+ export * from '#src/types/contexts/Context';
10
+ export * from '#src/types/contexts/ErrorContext';
11
+ export * from '#src/types/contexts/InterceptContext';
12
+ export * from '#src/types/contexts/TerminateContext';
13
+ export * from '#src/types/controllers/ControllerOptions';
14
+ export * from '#src/types/contracts/InterceptorContract';
15
+ export * from '#src/types/contracts/MiddlewareContract';
16
+ export * from '#src/types/contracts/TerminatorContract';
17
+ export * from '#src/types/middlewares/InterceptorRouteType';
18
+ export * from '#src/types/middlewares/MiddlewareHandler';
19
+ export * from '#src/types/middlewares/MiddlewareOptions';
20
+ export * from '#src/types/middlewares/MiddlewareRouteType';
21
+ export * from '#src/types/middlewares/TerminatorRouteType';
22
+ export * from '#src/types/router/RouteHandler';
23
+ export * from '#src/types/router/RouteJson';
24
+ export * from '#src/types/router/RouteResourceTypes';
@@ -0,0 +1,24 @@
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
+ export * from '#src/types/contexts/Context';
10
+ export * from '#src/types/contexts/ErrorContext';
11
+ export * from '#src/types/contexts/InterceptContext';
12
+ export * from '#src/types/contexts/TerminateContext';
13
+ export * from '#src/types/controllers/ControllerOptions';
14
+ export * from '#src/types/contracts/InterceptorContract';
15
+ export * from '#src/types/contracts/MiddlewareContract';
16
+ export * from '#src/types/contracts/TerminatorContract';
17
+ export * from '#src/types/middlewares/InterceptorRouteType';
18
+ export * from '#src/types/middlewares/MiddlewareHandler';
19
+ export * from '#src/types/middlewares/MiddlewareOptions';
20
+ export * from '#src/types/middlewares/MiddlewareRouteType';
21
+ export * from '#src/types/middlewares/TerminatorRouteType';
22
+ export * from '#src/types/router/RouteHandler';
23
+ export * from '#src/types/router/RouteJson';
24
+ export * from '#src/types/router/RouteResourceTypes';
@@ -6,6 +6,6 @@
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 { InterceptHandler } from '#src/Types/Middlewares/MiddlewareHandler';
10
- import { InterceptorContract } from '#src/Contracts/InterceptorContract';
9
+ import type { InterceptorContract } from '#src/types/contracts/InterceptorContract';
10
+ import type { InterceptHandler } from '#src/types/middlewares/MiddlewareHandler';
11
11
  export type InterceptorRouteType = string | InterceptHandler | InterceptorContract;
@@ -6,9 +6,9 @@
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 { Context } from '#src/Types/Contexts/Context';
10
- import { InterceptContext } from '#src/Types/Contexts/InterceptContext';
11
- import { TerminateContext } from '#src/Types/Contexts/TerminateContext';
9
+ import type { Context } from '#src/types/contexts/Context';
10
+ import type { InterceptContext } from '#src/types/contexts/InterceptContext';
11
+ import type { TerminateContext } from '#src/types/contexts/TerminateContext';
12
12
  export type HandleHandler = (ctx: Context) => any | Promise<any>;
13
13
  export type InterceptHandler = (ctx: InterceptContext) => string | Record<string, any> | Record<string, any>[] | Promise<string> | Promise<Record<string, any>> | Promise<Record<string, any>[]>;
14
14
  export type TerminateHandler = (ctx: TerminateContext) => any | Promise<any>;
@@ -6,6 +6,6 @@
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 { HandleHandler } from '#src/Types/Middlewares/MiddlewareHandler';
10
- import { MiddlewareContract } from '#src/Contracts/MiddlewareContract';
9
+ import type { MiddlewareContract } from '#src/types/contracts/MiddlewareContract';
10
+ import type { HandleHandler } from '#src/types/middlewares/MiddlewareHandler';
11
11
  export type MiddlewareRouteType = string | HandleHandler | MiddlewareContract;
@@ -6,6 +6,6 @@
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 { TerminateHandler } from '#src/Types/Middlewares/MiddlewareHandler';
10
- import { TerminatorContract } from '#src/Contracts/TerminatorContract';
9
+ import type { TerminatorContract } from '#src/types/contracts/TerminatorContract';
10
+ import type { TerminateHandler } from '#src/types/middlewares/MiddlewareHandler';
11
11
  export type TerminatorRouteType = string | TerminateHandler | TerminatorContract;
@@ -6,5 +6,5 @@
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 { RequestHandler } from '#src/Types/Contexts/Context';
9
+ import type { RequestHandler } from '#src/types/contexts/Context';
10
10
  export type RouteHandler = string | RequestHandler;
@@ -6,10 +6,9 @@
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 { HTTPMethods, RouteOptions } from 'fastify';
10
- import { RequestHandler } from '#src/Types/Contexts/Context';
11
- import { MiddlewareRecord } from '#src/Types/Middlewares/MiddlewareHandler';
12
- export type RouteJSON = {
9
+ import type { HTTPMethods, RouteOptions } from 'fastify';
10
+ import type { RequestHandler, MiddlewareRecord } from '#src/types';
11
+ export type RouteJson = {
13
12
  url: string;
14
13
  methods?: HTTPMethods[];
15
14
  name?: string;
@@ -1,9 +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
- export {};
@@ -1,24 +0,0 @@
1
- import { Context, Controller } from '@athenna/http'
2
-
3
- @Controller()
4
- export class {{ namePascal }} {
5
- public async index({ response }: Context): Promise<void> {
6
- return response.status(200).send([{}])
7
- }
8
-
9
- public async store({ response }: Context): Promise<void> {
10
- return response.status(201).send({})
11
- }
12
-
13
- public async show({ response }: Context): Promise<void> {
14
- return response.status(200).send({})
15
- }
16
-
17
- public async update({ response, params }: Context): Promise<void> {
18
- return response.status(200).send({ id: params.id })
19
- }
20
-
21
- public async delete({ response }: Context): Promise<void> {
22
- return response.status(204)
23
- }
24
- }
@@ -1,8 +0,0 @@
1
- import { Interceptor, InterceptContext, InterceptorContract } from '@athenna/http'
2
-
3
- @Interceptor()
4
- export class {{ namePascal }} implements InterceptorContract {
5
- public async intercept(ctx: InterceptContext): Promise<unknown> {
6
- return ctx.body
7
- }
8
- }
@@ -1,6 +0,0 @@
1
- import { Context, Middleware, MiddlewareContract } from '@athenna/http'
2
-
3
- @Middleware()
4
- export class {{ namePascal }} implements MiddlewareContract {
5
- public async handle(ctx: Context): Promise<void> {}
6
- }
@@ -1,6 +0,0 @@
1
- import { Terminator, TerminateContext, TerminatorContract } from '@athenna/http'
2
-
3
- @Terminator()
4
- export class {{ namePascal }} implements TerminatorContract {
5
- public async terminate(ctx: TerminateContext): Promise<void> {}
6
- }
File without changes
File without changes
File without changes
File without changes
File without changes