@athenna/http 3.0.11 → 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 -77
  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 -268
  120. package/src/Context/Response.js +0 -173
  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 -411
  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 -1395
  151. package/src/index.js +0 -377
@@ -0,0 +1,11 @@
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 { InterceptHandler } from '#src/Types/Middlewares/MiddlewareHandler';
10
+ import { InterceptorContract } from '#src/Contracts/InterceptorContract';
11
+ export type InterceptorRouteType = string | InterceptHandler | InterceptorContract;
@@ -0,0 +1,9 @@
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 {};
@@ -0,0 +1,20 @@
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 { Context } from '#src/Types/Contexts/Context';
10
+ import { InterceptContext } from '#src/Types/Contexts/InterceptContext';
11
+ import { TerminateContext } from '#src/Types/Contexts/TerminateContext';
12
+ export type HandleHandler = (ctx: Context) => any | Promise<any>;
13
+ export type InterceptHandler = (ctx: InterceptContext) => string | Record<string, any> | Record<string, any>[] | Promise<string> | Promise<Record<string, any>> | Promise<Record<string, any>[]>;
14
+ export type TerminateHandler = (ctx: TerminateContext) => any | Promise<any>;
15
+ export type MiddlewareHandler = HandleHandler | TerminateHandler | InterceptHandler;
16
+ export type MiddlewareRecord = {
17
+ middlewares: HandleHandler[];
18
+ terminators: TerminateHandler[];
19
+ interceptors: InterceptHandler[];
20
+ };
@@ -0,0 +1,9 @@
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 {};
@@ -0,0 +1,40 @@
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 type MiddlewareOptions = {
10
+ /**
11
+ * The alias that will be used to register the dependency inside
12
+ * the service provider. Athenna will not create camel alias from
13
+ * the alias set here.
14
+ *
15
+ * @default App/Http/Middlewares/YourMiddlewareClassName
16
+ */
17
+ alias?: string;
18
+ /**
19
+ * The registration type that will be used to register your middleware
20
+ * inside the service provider.
21
+ *
22
+ * @default transient
23
+ */
24
+ type?: 'fake' | 'scoped' | 'singleton' | 'transient';
25
+ /**
26
+ * Set if your middleware is global and should be executed in all requests
27
+ * of your server. If this value is true, Athenna will ignore the "name" property.
28
+ *
29
+ * @default false
30
+ */
31
+ isGlobal?: boolean;
32
+ /**
33
+ * Set the name of your middleware to be used inside routes. If "isGlobal" property
34
+ * is true, Athenna will ignore this property. Athenna will always set the default
35
+ * name of your middleware as the middleware class name in camel case format.
36
+ *
37
+ * @default yourMiddlewareClassName
38
+ */
39
+ name?: string;
40
+ };
@@ -0,0 +1,9 @@
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 {};
@@ -0,0 +1,11 @@
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 { HandleHandler } from '#src/Types/Middlewares/MiddlewareHandler';
10
+ import { MiddlewareContract } from '#src/Contracts/MiddlewareContract';
11
+ export type MiddlewareRouteType = string | HandleHandler | MiddlewareContract;
@@ -0,0 +1,9 @@
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 {};
@@ -0,0 +1,11 @@
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 { TerminateHandler } from '#src/Types/Middlewares/MiddlewareHandler';
10
+ import { TerminatorContract } from '#src/Contracts/TerminatorContract';
11
+ export type TerminatorRouteType = string | TerminateHandler | TerminatorContract;
@@ -0,0 +1,9 @@
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 {};
@@ -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 { RequestHandler } from '#src/Types/Contexts/Context';
10
+ export type RouteHandler = string | RequestHandler;
@@ -0,0 +1,9 @@
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 {};
@@ -0,0 +1,21 @@
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 { HTTPMethods, RouteOptions } from 'fastify';
10
+ import { RequestHandler } from '#src/Types/Contexts/Context';
11
+ import { MiddlewareRecord } from '#src/Types/Middlewares/MiddlewareHandler';
12
+ export type RouteJSON = {
13
+ url: string;
14
+ methods?: HTTPMethods[];
15
+ name?: string;
16
+ deleted?: boolean;
17
+ prefixes?: string[];
18
+ handler?: RequestHandler;
19
+ middlewares?: MiddlewareRecord;
20
+ fastify?: Partial<RouteOptions>;
21
+ };
@@ -0,0 +1,9 @@
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 {};
@@ -0,0 +1,9 @@
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 type RouteResourceTypes = 'index' | 'store' | 'show' | 'update' | 'delete';
@@ -0,0 +1,9 @@
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 {};
@@ -0,0 +1,70 @@
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
+ declare module 'fastify' {
10
+ interface FastifyRequest {
11
+ data: any;
12
+ }
13
+ interface FastifySchema {
14
+ hide?: boolean;
15
+ deprecated?: boolean;
16
+ tags?: string[];
17
+ description?: string;
18
+ summary?: string;
19
+ consumes?: string[];
20
+ produces?: string[];
21
+ externalDocs?: import('openapi-types').OpenAPIV2.ExternalDocumentationObject | import('openapi-types').OpenAPIV3.ExternalDocumentationObject;
22
+ security?: Array<{
23
+ [securityLabel: string]: string[];
24
+ }>;
25
+ /**
26
+ * OpenAPI operation unique identifier
27
+ */
28
+ operationId?: string;
29
+ }
30
+ }
31
+ export * from './Context/Request.js';
32
+ export * from './Context/Response.js';
33
+ export * from './Contracts/MiddlewareContract.js';
34
+ export * from './Contracts/TerminatorContract.js';
35
+ export * from './Contracts/InterceptorContract.js';
36
+ export * from './Decorators/Controller.js';
37
+ export * from './Decorators/Middleware.js';
38
+ export * from './Decorators/Interceptor.js';
39
+ export * from './Decorators/Terminator.js';
40
+ export * from './Facades/Route.js';
41
+ export * from './Facades/Server.js';
42
+ export * from './Providers/HttpRouteProvider.js';
43
+ export * from './Providers/HttpServerProvider.js';
44
+ export * from './Kernels/HttpKernel.js';
45
+ export * from './Handlers/FastifyHandler.js';
46
+ export * from './Handlers/HttpExceptionHandler.js';
47
+ export * from './Router/Router.js';
48
+ export * from './Server/ServerImpl.js';
49
+ export * from './Types/Router/RouteJSON.js';
50
+ export * from './Types/Router/RouteHandler.js';
51
+ export * from './Types/Router/RouteResourceTypes.js';
52
+ export * from './Types/Contexts/Context.js';
53
+ export * from './Types/Contexts/ErrorContext.js';
54
+ export * from './Types/Contexts/TerminateContext.js';
55
+ export * from './Types/Contexts/InterceptContext.js';
56
+ export * from './Types/Middlewares/MiddlewareHandler.js';
57
+ export * from './Exceptions/BadGatewayException.js';
58
+ export * from './Exceptions/BadRequestException.js';
59
+ export * from './Exceptions/ForbiddenException.js';
60
+ export * from './Exceptions/HttpException.js';
61
+ export * from './Exceptions/InternalServerException.js';
62
+ export * from './Exceptions/MethodNotAllowedException.js';
63
+ export * from './Exceptions/NotAcceptableException.js';
64
+ export * from './Exceptions/NotFoundException.js';
65
+ export * from './Exceptions/NotImplementedException.js';
66
+ export * from './Exceptions/PayloadTooLargeException.js';
67
+ export * from './Exceptions/RequestTimeoutException.js';
68
+ export * from './Exceptions/ServiceUnavailableException.js';
69
+ export * from './Exceptions/UnauthorizedException.js';
70
+ export * from './Exceptions/UnprocessableEntityException.js';
package/build/index.js ADDED
@@ -0,0 +1,48 @@
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 './Context/Request.js';
10
+ export * from './Context/Response.js';
11
+ export * from './Contracts/MiddlewareContract.js';
12
+ export * from './Contracts/TerminatorContract.js';
13
+ export * from './Contracts/InterceptorContract.js';
14
+ export * from './Decorators/Controller.js';
15
+ export * from './Decorators/Middleware.js';
16
+ export * from './Decorators/Interceptor.js';
17
+ export * from './Decorators/Terminator.js';
18
+ export * from './Facades/Route.js';
19
+ export * from './Facades/Server.js';
20
+ export * from './Providers/HttpRouteProvider.js';
21
+ export * from './Providers/HttpServerProvider.js';
22
+ export * from './Kernels/HttpKernel.js';
23
+ export * from './Handlers/FastifyHandler.js';
24
+ export * from './Handlers/HttpExceptionHandler.js';
25
+ export * from './Router/Router.js';
26
+ export * from './Server/ServerImpl.js';
27
+ export * from './Types/Router/RouteJSON.js';
28
+ export * from './Types/Router/RouteHandler.js';
29
+ export * from './Types/Router/RouteResourceTypes.js';
30
+ export * from './Types/Contexts/Context.js';
31
+ export * from './Types/Contexts/ErrorContext.js';
32
+ export * from './Types/Contexts/TerminateContext.js';
33
+ export * from './Types/Contexts/InterceptContext.js';
34
+ export * from './Types/Middlewares/MiddlewareHandler.js';
35
+ export * from './Exceptions/BadGatewayException.js';
36
+ export * from './Exceptions/BadRequestException.js';
37
+ export * from './Exceptions/ForbiddenException.js';
38
+ export * from './Exceptions/HttpException.js';
39
+ export * from './Exceptions/InternalServerException.js';
40
+ export * from './Exceptions/MethodNotAllowedException.js';
41
+ export * from './Exceptions/NotAcceptableException.js';
42
+ export * from './Exceptions/NotFoundException.js';
43
+ export * from './Exceptions/NotImplementedException.js';
44
+ export * from './Exceptions/PayloadTooLargeException.js';
45
+ export * from './Exceptions/RequestTimeoutException.js';
46
+ export * from './Exceptions/ServiceUnavailableException.js';
47
+ export * from './Exceptions/UnauthorizedException.js';
48
+ export * from './Exceptions/UnprocessableEntityException.js';