@asenajs/asena 0.1.18 → 0.2.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 (260) hide show
  1. package/README.md +90 -147
  2. package/dist/index.d.ts +0 -9
  3. package/dist/index.js +0 -9
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/adapter/AsenaAdapter.d.ts +46 -54
  6. package/dist/lib/adapter/AsenaAdapter.js +22 -11
  7. package/dist/lib/adapter/AsenaAdapter.js.map +1 -1
  8. package/dist/lib/adapter/AsenaContext.d.ts +67 -57
  9. package/dist/lib/adapter/AsenaWebsocketAdapter.d.ts +57 -34
  10. package/dist/lib/adapter/AsenaWebsocketAdapter.js +43 -12
  11. package/dist/lib/adapter/AsenaWebsocketAdapter.js.map +1 -1
  12. package/dist/lib/adapter/index.d.ts +1 -0
  13. package/dist/lib/adapter/index.js +1 -0
  14. package/dist/lib/adapter/index.js.map +1 -1
  15. package/dist/lib/adapter/types/ApiParams.d.ts +73 -0
  16. package/dist/lib/adapter/types/ApiParams.js +2 -0
  17. package/dist/lib/adapter/types/ApiParams.js.map +1 -0
  18. package/dist/lib/adapter/types/AsenaHandler.d.ts +2 -0
  19. package/dist/lib/adapter/types/AsenaHandler.js +2 -0
  20. package/dist/lib/adapter/types/AsenaHandler.js.map +1 -0
  21. package/dist/lib/adapter/types/AsenaMiddlewareHandler.d.ts +2 -0
  22. package/dist/lib/adapter/types/AsenaMiddlewareHandler.js +2 -0
  23. package/dist/lib/adapter/types/AsenaMiddlewareHandler.js.map +1 -0
  24. package/dist/lib/adapter/types/BaseMiddleware.d.ts +57 -0
  25. package/dist/lib/adapter/types/BaseMiddleware.js +2 -0
  26. package/dist/lib/adapter/types/BaseMiddleware.js.map +1 -0
  27. package/dist/lib/adapter/types/ErrorHandler.d.ts +2 -0
  28. package/dist/lib/adapter/types/ErrorHandler.js +2 -0
  29. package/dist/lib/adapter/types/ErrorHandler.js.map +1 -0
  30. package/dist/lib/adapter/types/RouteParams.d.ts +8 -5
  31. package/dist/lib/adapter/types/ServeOptions.d.ts +7 -0
  32. package/dist/lib/adapter/types/ServeOptions.js +2 -0
  33. package/dist/lib/adapter/types/ServeOptions.js.map +1 -0
  34. package/dist/lib/adapter/types/WebSocketRegistry.d.ts +5 -4
  35. package/dist/lib/adapter/types/WebsocketAdapterParams.d.ts +1 -1
  36. package/dist/lib/adapter/types/index.d.ts +6 -0
  37. package/dist/lib/adapter/types/index.js +6 -0
  38. package/dist/lib/adapter/types/index.js.map +1 -1
  39. package/dist/lib/ioc/Container.d.ts +8 -3
  40. package/dist/lib/ioc/Container.js +100 -76
  41. package/dist/lib/ioc/Container.js.map +1 -1
  42. package/dist/lib/ioc/IocEngine.d.ts +2 -2
  43. package/dist/lib/ioc/IocEngine.js +28 -16
  44. package/dist/lib/ioc/IocEngine.js.map +1 -1
  45. package/dist/lib/ioc/component/componentUtils.d.ts +1 -1
  46. package/dist/lib/ioc/component/componentUtils.js +16 -12
  47. package/dist/lib/ioc/component/componentUtils.js.map +1 -1
  48. package/dist/lib/{server/decorators/components → ioc/component/decorators}/Component.d.ts +1 -1
  49. package/dist/lib/{server/decorators/components → ioc/component/decorators}/Component.js +2 -2
  50. package/dist/lib/ioc/component/decorators/Component.js.map +1 -0
  51. package/dist/lib/ioc/component/decorators/Implements.js +2 -2
  52. package/dist/lib/ioc/component/decorators/Implements.js.map +1 -1
  53. package/dist/lib/ioc/component/decorators/Inject.d.ts +1 -1
  54. package/dist/lib/ioc/component/decorators/Inject.js +6 -7
  55. package/dist/lib/ioc/component/decorators/Inject.js.map +1 -1
  56. package/dist/lib/ioc/component/decorators/PostConstruct.d.ts +6 -0
  57. package/dist/lib/ioc/component/decorators/PostConstruct.js +17 -0
  58. package/dist/lib/ioc/component/decorators/PostConstruct.js.map +1 -0
  59. package/dist/lib/ioc/component/decorators/Strategy.js +6 -6
  60. package/dist/lib/ioc/component/decorators/Strategy.js.map +1 -1
  61. package/dist/lib/ioc/component/decorators/index.d.ts +1 -0
  62. package/dist/lib/ioc/component/decorators/index.js +1 -0
  63. package/dist/lib/ioc/component/decorators/index.js.map +1 -1
  64. package/dist/lib/ioc/component/index.d.ts +1 -0
  65. package/dist/lib/ioc/component/index.js +2 -0
  66. package/dist/lib/ioc/component/index.js.map +1 -0
  67. package/dist/lib/ioc/constants/ComponentConstants.d.ts +4 -2
  68. package/dist/lib/ioc/constants/ComponentConstants.js +3 -1
  69. package/dist/lib/ioc/constants/ComponentConstants.js.map +1 -1
  70. package/dist/lib/ioc/helper/fileHelper.d.ts +1 -1
  71. package/dist/lib/ioc/helper/fileHelper.js +9 -3
  72. package/dist/lib/ioc/helper/fileHelper.js.map +1 -1
  73. package/dist/lib/ioc/helper/iocHelper.d.ts +2 -3
  74. package/dist/lib/ioc/helper/iocHelper.js +4 -2
  75. package/dist/lib/ioc/helper/iocHelper.js.map +1 -1
  76. package/dist/lib/ioc/types/{Component.d.ts → InjectableComponent.d.ts} +4 -4
  77. package/dist/lib/ioc/types/InjectableComponent.js +2 -0
  78. package/dist/lib/ioc/types/InjectableComponent.js.map +1 -0
  79. package/dist/lib/ioc/types/IocConfig.d.ts +1 -0
  80. package/dist/lib/ioc/types/decorators/ComponentParams.d.ts +1 -1
  81. package/dist/lib/ioc/types/decorators/ComponentType.d.ts +2 -2
  82. package/dist/lib/ioc/types/decorators/ComponentType.js +1 -1
  83. package/dist/lib/ioc/types/decorators/ComponentType.js.map +1 -1
  84. package/dist/lib/ioc/types/decorators/ControllerParams.d.ts +4 -3
  85. package/dist/lib/ioc/types/decorators/MiddlewareParams.d.ts +1 -1
  86. package/dist/lib/ioc/types/index.d.ts +1 -1
  87. package/dist/lib/ioc/types/index.js +1 -1
  88. package/dist/lib/ioc/types/index.js.map +1 -1
  89. package/dist/lib/{services/logger → logger}/DefaultLogger.d.ts +1 -1
  90. package/dist/lib/logger/DefaultLogger.js.map +1 -0
  91. package/dist/lib/{services/types → logger}/Logger.js.map +1 -1
  92. package/dist/lib/logger/index.d.ts +2 -0
  93. package/dist/lib/logger/index.js +3 -0
  94. package/dist/lib/logger/index.js.map +1 -0
  95. package/dist/lib/server/AsenaServer.d.ts +15 -14
  96. package/dist/lib/server/AsenaServer.js +125 -113
  97. package/dist/lib/server/AsenaServer.js.map +1 -1
  98. package/dist/lib/server/config/AsenaConfig.d.ts +43 -0
  99. package/dist/lib/server/config/AsenaConfig.js +2 -0
  100. package/dist/lib/server/config/AsenaConfig.js.map +1 -0
  101. package/dist/lib/server/config/index.d.ts +1 -0
  102. package/dist/lib/server/config/index.js +2 -0
  103. package/dist/lib/server/config/index.js.map +1 -0
  104. package/dist/lib/server/decorators/Override.d.ts +4 -4
  105. package/dist/lib/server/decorators/Override.js +11 -7
  106. package/dist/lib/server/decorators/Override.js.map +1 -1
  107. package/dist/lib/server/decorators/components/Config.d.ts +10 -0
  108. package/dist/lib/server/decorators/components/Config.js +14 -0
  109. package/dist/lib/server/decorators/components/Config.js.map +1 -0
  110. package/dist/lib/server/decorators/components/Controller.js +4 -4
  111. package/dist/lib/server/decorators/components/Controller.js.map +1 -1
  112. package/dist/lib/server/decorators/components/Middleware.d.ts +1 -1
  113. package/dist/lib/server/decorators/components/Middleware.js +19 -9
  114. package/dist/lib/server/decorators/components/Middleware.js.map +1 -1
  115. package/dist/lib/server/decorators/components/Schedule.d.ts +2 -2
  116. package/dist/lib/server/decorators/components/Schedule.js +7 -7
  117. package/dist/lib/server/decorators/components/Schedule.js.map +1 -1
  118. package/dist/lib/server/decorators/components/Service.d.ts +1 -1
  119. package/dist/lib/server/decorators/components/Service.js +2 -2
  120. package/dist/lib/server/decorators/components/Service.js.map +1 -1
  121. package/dist/lib/server/decorators/components/WebSocket.js +4 -4
  122. package/dist/lib/server/decorators/components/WebSocket.js.map +1 -1
  123. package/dist/lib/server/decorators/components/index.d.ts +1 -2
  124. package/dist/lib/server/decorators/components/index.js +1 -2
  125. package/dist/lib/server/decorators/components/index.js.map +1 -1
  126. package/dist/lib/server/decorators/index.d.ts +2 -1
  127. package/dist/lib/server/decorators/index.js +2 -1
  128. package/dist/lib/server/decorators/index.js.map +1 -1
  129. package/dist/lib/server/types/Class.d.ts +0 -3
  130. package/dist/lib/server/types/index.d.ts +2 -2
  131. package/dist/lib/server/types/index.js +2 -2
  132. package/dist/lib/server/types/index.js.map +1 -1
  133. package/dist/lib/server/web/decorators/http.base.d.ts +4 -0
  134. package/dist/lib/server/web/decorators/http.base.js +35 -0
  135. package/dist/lib/server/web/decorators/http.base.js.map +1 -0
  136. package/dist/lib/server/web/decorators/index.d.ts +4 -0
  137. package/dist/lib/server/web/decorators/index.js +5 -0
  138. package/dist/lib/server/web/decorators/index.js.map +1 -0
  139. package/dist/lib/server/web/decorators/methods/Connect.d.ts +7 -0
  140. package/dist/lib/server/web/decorators/methods/Connect.js +12 -0
  141. package/dist/lib/server/web/decorators/methods/Connect.js.map +1 -0
  142. package/dist/lib/server/web/decorators/methods/Delete.d.ts +7 -0
  143. package/dist/lib/server/web/decorators/methods/Delete.js +12 -0
  144. package/dist/lib/server/web/decorators/methods/Delete.js.map +1 -0
  145. package/dist/lib/server/web/decorators/methods/Get.d.ts +7 -0
  146. package/dist/lib/server/web/decorators/methods/Get.js +12 -0
  147. package/dist/lib/server/web/decorators/methods/Get.js.map +1 -0
  148. package/dist/lib/server/web/decorators/methods/Head.d.ts +7 -0
  149. package/dist/lib/server/web/decorators/methods/Head.js +12 -0
  150. package/dist/lib/server/web/decorators/methods/Head.js.map +1 -0
  151. package/dist/lib/server/web/decorators/methods/Options.d.ts +7 -0
  152. package/dist/lib/server/web/decorators/methods/Options.js +12 -0
  153. package/dist/lib/server/web/decorators/methods/Options.js.map +1 -0
  154. package/dist/lib/server/web/decorators/methods/Patch.d.ts +7 -0
  155. package/dist/lib/server/web/decorators/methods/Patch.js +12 -0
  156. package/dist/lib/server/web/decorators/methods/Patch.js.map +1 -0
  157. package/dist/lib/server/web/decorators/methods/Post.d.ts +7 -0
  158. package/dist/lib/server/web/decorators/methods/Post.js +12 -0
  159. package/dist/lib/server/web/decorators/methods/Post.js.map +1 -0
  160. package/dist/lib/server/web/decorators/methods/Put.d.ts +7 -0
  161. package/dist/lib/server/web/decorators/methods/Put.js +12 -0
  162. package/dist/lib/server/web/decorators/methods/Put.js.map +1 -0
  163. package/dist/lib/server/web/decorators/methods/Trace.d.ts +7 -0
  164. package/dist/lib/server/web/decorators/methods/Trace.js +12 -0
  165. package/dist/lib/server/web/decorators/methods/Trace.js.map +1 -0
  166. package/dist/lib/server/web/decorators/methods/index.d.ts +9 -0
  167. package/dist/lib/server/web/decorators/methods/index.js +10 -0
  168. package/dist/lib/server/web/decorators/methods/index.js.map +1 -0
  169. package/dist/lib/server/web/helper/middlewareHelper.d.ts +8 -2
  170. package/dist/lib/server/web/helper/middlewareHelper.js +11 -5
  171. package/dist/lib/server/web/helper/middlewareHelper.js.map +1 -1
  172. package/dist/lib/server/web/middleware/AsenaMiddlewareService.d.ts +8 -10
  173. package/dist/lib/server/web/middleware/AsenaMiddlewareService.js +1 -4
  174. package/dist/lib/server/web/middleware/AsenaMiddlewareService.js.map +1 -1
  175. package/dist/lib/server/web/middleware/AsenaValidationService.d.ts +15 -16
  176. package/dist/lib/server/web/middleware/AsenaValidationService.js +1 -8
  177. package/dist/lib/server/web/middleware/AsenaValidationService.js.map +1 -1
  178. package/dist/lib/server/web/types/HttpMethod.js.map +1 -0
  179. package/dist/lib/server/web/types/HttpStatus.d.ts +79 -0
  180. package/dist/lib/server/web/types/HttpStatus.js +85 -0
  181. package/dist/lib/server/web/types/HttpStatus.js.map +1 -0
  182. package/dist/lib/server/web/types/index.d.ts +2 -2
  183. package/dist/lib/server/web/types/index.js +2 -2
  184. package/dist/lib/server/web/types/index.js.map +1 -1
  185. package/dist/lib/server/web/websocket/AsenaSocket.d.ts +1 -0
  186. package/dist/lib/server/web/websocket/AsenaSocket.js +4 -0
  187. package/dist/lib/server/web/websocket/AsenaSocket.js.map +1 -1
  188. package/dist/lib/server/web/websocket/AsenaWebSocketServer.d.ts +39 -0
  189. package/dist/lib/server/web/websocket/AsenaWebSocketServer.js +41 -1
  190. package/dist/lib/server/web/websocket/AsenaWebSocketServer.js.map +1 -1
  191. package/dist/lib/server/web/websocket/AsenaWebSocketService.js +4 -4
  192. package/dist/lib/server/web/websocket/AsenaWebSocketService.js.map +1 -1
  193. package/dist/lib/server/web/websocket/index.d.ts +1 -0
  194. package/dist/lib/server/web/websocket/index.js +1 -0
  195. package/dist/lib/server/web/websocket/index.js.map +1 -1
  196. package/dist/lib/utils/typedMetadata.d.ts +3 -0
  197. package/dist/lib/utils/typedMetadata.js +16 -0
  198. package/dist/lib/utils/typedMetadata.js.map +1 -0
  199. package/package.json +55 -6
  200. package/dist/lib/adapter/defaultAdapter/DefaultAdapter.d.ts +0 -26
  201. package/dist/lib/adapter/defaultAdapter/DefaultAdapter.js +0 -92
  202. package/dist/lib/adapter/defaultAdapter/DefaultAdapter.js.map +0 -1
  203. package/dist/lib/adapter/defaultAdapter/DefaultContextWrapper.d.ts +0 -32
  204. package/dist/lib/adapter/defaultAdapter/DefaultContextWrapper.js +0 -97
  205. package/dist/lib/adapter/defaultAdapter/DefaultContextWrapper.js.map +0 -1
  206. package/dist/lib/adapter/defaultAdapter/DefaultWebsocketAdapter.d.ts +0 -15
  207. package/dist/lib/adapter/defaultAdapter/DefaultWebsocketAdapter.js +0 -77
  208. package/dist/lib/adapter/defaultAdapter/DefaultWebsocketAdapter.js.map +0 -1
  209. package/dist/lib/adapter/defaultAdapter/index.d.ts +0 -3
  210. package/dist/lib/adapter/defaultAdapter/index.js +0 -4
  211. package/dist/lib/adapter/defaultAdapter/index.js.map +0 -1
  212. package/dist/lib/adapter/defaultAdapter/types/Defaultcontext.d.ts +0 -3
  213. package/dist/lib/adapter/defaultAdapter/types/Defaultcontext.js +0 -2
  214. package/dist/lib/adapter/defaultAdapter/types/Defaultcontext.js.map +0 -1
  215. package/dist/lib/adapter/defaultAdapter/types/Handler.d.ts +0 -4
  216. package/dist/lib/adapter/defaultAdapter/types/Handler.js +0 -2
  217. package/dist/lib/adapter/defaultAdapter/types/Handler.js.map +0 -1
  218. package/dist/lib/adapter/defaultAdapter/types/index.d.ts +0 -2
  219. package/dist/lib/adapter/defaultAdapter/types/index.js +0 -3
  220. package/dist/lib/adapter/defaultAdapter/types/index.js.map +0 -1
  221. package/dist/lib/ioc/types/Component.js +0 -2
  222. package/dist/lib/ioc/types/Component.js.map +0 -1
  223. package/dist/lib/server/decorators/components/Component.js.map +0 -1
  224. package/dist/lib/server/decorators/components/ServerService.d.ts +0 -9
  225. package/dist/lib/server/decorators/components/ServerService.js +0 -13
  226. package/dist/lib/server/decorators/components/ServerService.js.map +0 -1
  227. package/dist/lib/server/web/api/apiHandler.d.ts +0 -55
  228. package/dist/lib/server/web/api/apiHandler.js +0 -107
  229. package/dist/lib/server/web/api/apiHandler.js.map +0 -1
  230. package/dist/lib/server/web/api/index.d.ts +0 -1
  231. package/dist/lib/server/web/api/index.js +0 -2
  232. package/dist/lib/server/web/api/index.js.map +0 -1
  233. package/dist/lib/server/web/http/HttpMethod.js.map +0 -1
  234. package/dist/lib/server/web/http/HttpStatus.d.ts +0 -77
  235. package/dist/lib/server/web/http/HttpStatus.js +0 -84
  236. package/dist/lib/server/web/http/HttpStatus.js.map +0 -1
  237. package/dist/lib/server/web/http/index.d.ts +0 -2
  238. package/dist/lib/server/web/http/index.js +0 -3
  239. package/dist/lib/server/web/http/index.js.map +0 -1
  240. package/dist/lib/server/web/types/ApiHandler.d.ts +0 -22
  241. package/dist/lib/server/web/types/ApiHandler.js +0 -2
  242. package/dist/lib/server/web/types/ApiHandler.js.map +0 -1
  243. package/dist/lib/server/web/types/BaseMiddleware.d.ts +0 -12
  244. package/dist/lib/server/web/types/BaseMiddleware.js +0 -2
  245. package/dist/lib/server/web/types/BaseMiddleware.js.map +0 -1
  246. package/dist/lib/services/index.d.ts +0 -3
  247. package/dist/lib/services/index.js +0 -4
  248. package/dist/lib/services/index.js.map +0 -1
  249. package/dist/lib/services/logger/DefaultLogger.js.map +0 -1
  250. package/dist/lib/services/serverService/AsenaService.d.ts +0 -7
  251. package/dist/lib/services/serverService/AsenaService.js +0 -7
  252. package/dist/lib/services/serverService/AsenaService.js.map +0 -1
  253. package/dist/lib/services/types/index.d.ts +0 -2
  254. package/dist/lib/services/types/index.js +0 -3
  255. package/dist/lib/services/types/index.js.map +0 -1
  256. /package/dist/lib/{services/logger → logger}/DefaultLogger.js +0 -0
  257. /package/dist/lib/{services/types → logger}/Logger.d.ts +0 -0
  258. /package/dist/lib/{services/types → logger}/Logger.js +0 -0
  259. /package/dist/lib/server/web/{http → types}/HttpMethod.d.ts +0 -0
  260. /package/dist/lib/server/web/{http → types}/HttpMethod.js +0 -0
@@ -1,141 +1,151 @@
1
1
  import type { CookieExtra, SendOptions } from './types';
2
2
  /**
3
- * Interface representing the context for Asena.
3
+ * AsenaContext represents the core context interface for handling HTTP requests and responses in Asena framework.
4
+ * It provides essential methods and properties for request/response handling, data manipulation, and state management.
4
5
  *
5
- * @template R - The type of the request object.
6
- * @template S - The type of the response object.
6
+ * @template R - Type parameter for the underlying request object
7
+ * @template S - Type parameter for the underlying response object
7
8
  */
8
9
  export interface AsenaContext<R, S> {
10
+ /** The original request object */
9
11
  req: R;
12
+ /** The original response object */
10
13
  res: S;
11
14
  /**
12
- * Headers associated with the request.
15
+ * Request headers stored as key-value pairs
13
16
  */
14
17
  headers: Record<string, string>;
15
18
  /**
16
- * Retrieves the request body as an ArrayBuffer.
19
+ * Retrieves the raw request body as an ArrayBuffer.
20
+ * Useful for handling binary data.
17
21
  *
18
- * @returns {Promise<ArrayBuffer>} A promise that resolves to an ArrayBuffer.
22
+ * @returns {Promise<ArrayBuffer>} The request body as an ArrayBuffer
19
23
  */
20
24
  getArrayBuffer: () => Promise<ArrayBuffer>;
21
25
  /**
22
- * Parses and retrieves the request body.
26
+ * Automatically parses the request body based on content type.
27
+ * Supports JSON, form data, and other common formats.
23
28
  *
24
- * @returns {Promise<any>} A promise that resolves to the parsed body.
29
+ * @returns {Promise<any>} The parsed request body
25
30
  */
26
31
  getParseBody: () => Promise<any>;
27
32
  /**
28
- * Retrieves the request body as a Blob.
33
+ * Retrieves the request body as a Blob object.
34
+ * Useful for handling file uploads and binary data.
29
35
  *
30
- * @returns {Promise<Blob>} A promise that resolves to a Blob.
36
+ * @returns {Promise<Blob>} The request body as a Blob
31
37
  */
32
38
  getBlob: () => Promise<Blob>;
33
39
  /**
34
40
  * Retrieves the request body as FormData.
41
+ * Useful for processing multipart/form-data submissions.
35
42
  *
36
- * @returns {Promise<FormData>} A promise that resolves to FormData.
43
+ * @returns {Promise<FormData>} The request body as FormData
37
44
  */
38
45
  getFormData: () => Promise<FormData>;
39
46
  /**
40
- * Retrieves a parameter from the request.
47
+ * Retrieves a route parameter by name.
48
+ * Example: For route "/users/:id", getParam("id") returns the actual ID value.
41
49
  *
42
- * @param {string} s - The name of the parameter.
43
- * @returns {string} The value of the parameter.
50
+ * @param {string} s - The parameter name to retrieve
51
+ * @returns {string} The parameter value
44
52
  */
45
53
  getParam: (s: string) => string;
46
54
  /**
47
- * Retrieves the request body as a specified type.
55
+ * Retrieves and automatically type-casts the request body.
48
56
  *
49
- * @template U - The type to which the body should be parsed.
50
- * @returns {Promise<U>} A promise that resolves to the parsed body.
57
+ * @template U - The expected type of the body
58
+ * @returns {Promise<U>} The typed request body
51
59
  */
52
60
  getBody: <U>() => Promise<U>;
53
61
  /**
54
- * Retrieves a query parameter from the request.
62
+ * Retrieves a single query parameter value.
63
+ * For URL "?name=john", getQuery("name") returns "john".
55
64
  *
56
- * @param {string} query - The name of the query parameter.
57
- * @returns {Promise<string>} A promise that resolves to the value of the query parameter.
65
+ * @param {string} query - The query parameter name
66
+ * @returns {Promise<string>} The query parameter value
58
67
  */
59
68
  getQuery: (query: string) => Promise<string>;
60
69
  /**
61
- * Retrieves all values of a query parameter from the request.
70
+ * Retrieves all values for a query parameter that appears multiple times.
71
+ * For URL "?color=red&color=blue", getQueryAll("color") returns ["red", "blue"].
62
72
  *
63
- * @param {string} query - The name of the query parameter.
64
- * @returns {Promise<string[]>} A promise that resolves to an array of values.
73
+ * @param {string} query - The query parameter name
74
+ * @returns {Promise<string[]>} Array of all values for the query parameter
65
75
  */
66
76
  getQueryAll: (query: string) => Promise<string[]>;
67
77
  /**
68
- * Retrieves a cookie from the request.
78
+ * Retrieves a cookie value by name, with optional signature verification.
69
79
  *
70
- * @param {string} name - The name of the cookie.
71
- * @param {string | BufferSource} [secret] - Optional secret for signed cookies.
72
- * @returns {Promise<string | false>} A promise that resolves to the cookie value or false if not found.
80
+ * @param {string} name - The cookie name
81
+ * @param {string | BufferSource} [secret] - Optional secret for verifying signed cookies
82
+ * @returns {Promise<string | false>} The cookie value if found, false otherwise
73
83
  */
74
84
  getCookie: (name: string, secret?: string | BufferSource) => Promise<string | false>;
75
85
  /**
76
- * Sets a cookie in the response.
86
+ * Sets a cookie with the specified name, value, and options.
77
87
  *
78
- * @param {string} name - The name of the cookie.
79
- * @param {string} value - The value of the cookie.
80
- * @param {CookieExtra<any>} [options] - Optional settings for the cookie.
81
- * @returns {Promise<void>} A promise that resolves when the cookie is set.
88
+ * @param {string} name - The cookie name
89
+ * @param {string} value - The cookie value
90
+ * @param {CookieExtra<any>} [options] - Cookie options (expires, domain, path, etc.)
91
+ * @returns {Promise<void>}
82
92
  */
83
93
  setCookie: (name: string, value: string, options?: CookieExtra<any>) => Promise<void>;
84
94
  /**
85
- * Deletes a cookie from the response.
95
+ * Deletes a cookie by setting its expiration to the past.
86
96
  *
87
- * @param {string} name - The name of the cookie to delete.
88
- * @param {CookieExtra<any>} [options] - Optional settings for the cookie.
89
- * @returns {Promise<void>} A promise that resolves when the cookie is deleted.
97
+ * @param {string} name - The cookie name to delete
98
+ * @param {CookieExtra<any>} [options] - Cookie options (domain, path, etc.)
99
+ * @returns {Promise<void>}
90
100
  */
91
101
  deleteCookie: (name: string, options?: CookieExtra<any>) => Promise<void>;
92
102
  /**
93
- * Retrieves a value from the context.
103
+ * Retrieves a value from the context's state storage.
94
104
  *
95
- * @template T - The type of the value.
96
- * @param {string} key - The key of the value.
97
- * @returns {T} The value associated with the key.
105
+ * @template T - The expected type of the value
106
+ * @param {string} key - The key to retrieve
107
+ * @returns {T} The stored value
98
108
  */
99
109
  getValue: <T>(key: string) => T;
100
110
  /**
101
- * Sets a value in the context.
111
+ * Stores a value in the context's state storage.
102
112
  *
103
- * @param {string} key - The key of the value.
104
- * @param {any} value - The value to set.
113
+ * @param {string} key - The key to store under
114
+ * @param {any} value - The value to store
105
115
  */
106
116
  setValue: (key: string, value: any) => void;
107
117
  /**
108
- * Sets a value for WebSocket communication.
118
+ * Stores a value specifically for WebSocket communication.
109
119
  *
110
- * @param {any} value - The value to set.
120
+ * @param {any} value - The value to store for WebSocket context
111
121
  */
112
122
  setWebSocketValue: (value: any) => void;
113
123
  /**
114
- * Retrieves a value for WebSocket communication.
124
+ * Retrieves the stored WebSocket-specific value.
115
125
  *
116
- * @template T - The type of the value.
117
- * @returns {T} The value associated with the WebSocket.
126
+ * @template T - The expected type of the WebSocket value
127
+ * @returns {T} The stored WebSocket value
118
128
  */
119
129
  getWebSocketValue: <T>() => T;
120
130
  /**
121
- * Sends an HTML response.
131
+ * Sends an HTML response with appropriate content-type headers.
122
132
  *
123
- * @param {string} data - The HTML data to send.
124
- * @returns {Response | Promise<Response> } The response object.
133
+ * @param {string} data - The HTML content to send
134
+ * @returns {Response | Promise<Response>} The response object
125
135
  */
126
136
  html: (data: string) => Response | Promise<Response>;
127
137
  /**
128
- * Sends a response.
138
+ * Sends a response with automatic content-type detection.
129
139
  *
130
- * @param {string | any} data - The data to send.
131
- * @param {SendOptions | number} [status] - Optional status code or send options.
132
- * @returns {Response | Promise<Response>} The response object.
140
+ * @param {string | any} data - The content to send
141
+ * @param {SendOptions | number} [status] - HTTP status code or send options
142
+ * @returns {Response | Promise<Response>} The response object
133
143
  */
134
144
  send: (data: string | any, status?: SendOptions | number) => Response | Promise<Response>;
135
145
  /**
136
- * Redirects the request to a new URL.
146
+ * Performs an HTTP redirect to the specified URL.
137
147
  *
138
- * @param {string} url - The URL to redirect to.
148
+ * @param {string} url - The destination URL
139
149
  */
140
150
  redirect: (url: string) => void;
141
151
  }
@@ -1,71 +1,94 @@
1
1
  import type { AsenaWebSocketService, WSOptions } from '../server/web/websocket';
2
2
  import type { WebSocketHandler } from 'bun';
3
- import type { ServerLogger } from '../services';
4
- import type { WebsocketAdapterParams } from './types';
5
- import type { WebSocketRegistry } from './types';
3
+ import type { BaseMiddleware, WebsocketAdapterParams, WebSocketRegistry } from './types';
4
+ import type { ServerLogger } from '../logger';
5
+ import type { AsenaContext } from './AsenaContext';
6
6
  /**
7
- * Abstract class representing a WebSocket adapter.
7
+ * Abstract class that provides a base implementation for WebSocket adapters.
8
+ * Handles WebSocket connections, registration, and management.
8
9
  *
9
- * @template A - The type of the application.
10
- * @template AM - The type of the message.
10
+ * @template A - Type of the application instance
11
+ * @template R - Type of the request object
12
+ * @template S - Type of the response object
11
13
  */
12
- export declare abstract class AsenaWebsocketAdapter<A, MH> {
14
+ export declare abstract class AsenaWebsocketAdapter<A, C extends AsenaContext<any, any>> {
15
+ readonly name: string;
13
16
  /**
14
- * The WebSocket services.
15
- * @ string - The namespace of the WebSocket.
16
- * @ AsenaWebSocketService<any> - The WebSocket service.
17
- * @ MH[] - The middlewares to use.
17
+ * Registry containing WebSocket services and their configurations
18
+ * Structure:
19
+ * - Key: WebSocket namespace
20
+ * - Value: Object containing:
21
+ * - service: WebSocket service instance
22
+ * - middlewares: Array of middleware functions
18
23
  * @protected
19
24
  */
20
- protected _websockets: WebSocketRegistry;
25
+ protected _websockets: WebSocketRegistry<C>;
21
26
  /**
22
- * The application instance.
27
+ * Reference to the main application instance
23
28
  * @private
24
29
  */
25
30
  private _app;
26
31
  /**
27
- * The WebSocket handler.
32
+ * WebSocket handler instance for managing connections
28
33
  * @private
29
34
  */
30
35
  private _websocket;
31
36
  /**
32
- * The logger instance.
37
+ * Logger instance for WebSocket-related logging
38
+ * @private
33
39
  */
34
40
  private _logger;
35
41
  /**
36
- * Constructor for the AsenaWebSocketAdapter class.
37
- * @param params - The parameters for the constructor.
42
+ * Initializes a new WebSocket adapter instance
43
+ * @param params - Configuration parameters including app instance and logger
38
44
  */
39
45
  protected constructor(params?: WebsocketAdapterParams<A>);
40
46
  /**
41
- * Registers a WebSocket handler.
42
- *
43
- * @param {websocket<any>} websocket - The WebSocket to register.
44
- * @param middlewares to used in upgrade function
47
+ * Registers a new WebSocket service with associated middlewares
48
+ * @param websocket - WebSocket service instance to register
49
+ * @param middlewares - Array of middleware functions to be executed during connection upgrade
45
50
  */
46
- abstract registerWebSocket(websocket: AsenaWebSocketService<any>, middlewares: MH[]): void;
51
+ abstract registerWebSocket(websocket: AsenaWebSocketService<any>, middlewares: BaseMiddleware<C>[]): Promise<void> | void;
47
52
  /**
48
- * Prepares the WebSocket with the given options.
49
- *
50
- * @param {WSOptions} [wsOptions] - Optional WebSocket options.
53
+ * Configures and initializes the WebSocket server with provided options
54
+ * @param wsOptions - Configuration options for the WebSocket server
51
55
  */
52
- abstract prepareWebSocket(wsOptions?: WSOptions): void;
56
+ abstract buildWebsocket(wsOptions?: WSOptions): Promise<void> | void;
53
57
  /**
54
- * Build the WebSocket object for the server.
58
+ * Starts the WebSocket server on the provided HTTP/S server instance
59
+ * @param server - HTTP/S server instance to attach the WebSocket server to
55
60
  */
56
- abstract buildWebsocket(): void;
61
+ abstract startWebsocket(server: any): Promise<void> | void;
57
62
  /**
58
- * Start the WebSocket server.
59
- *
60
- * @param {Server} server - The server to start.
63
+ * Gets the application instance
61
64
  */
62
- abstract startWebsocket(server: any): void;
63
65
  get app(): A;
66
+ /**
67
+ * Sets the application instance
68
+ */
64
69
  set app(value: A);
65
- protected get websockets(): WebSocketRegistry;
66
- protected set websockets(value: WebSocketRegistry);
70
+ /**
71
+ * Gets the WebSocket registry
72
+ */
73
+ protected get websockets(): WebSocketRegistry<C>;
74
+ /**
75
+ * Sets the WebSocket registry
76
+ */
77
+ protected set websockets(value: WebSocketRegistry<C>);
78
+ /**
79
+ * Gets the WebSocket handler
80
+ */
67
81
  get websocket(): WebSocketHandler;
82
+ /**
83
+ * Sets the WebSocket handler
84
+ */
68
85
  set websocket(value: WebSocketHandler);
86
+ /**
87
+ * Gets the logger instance
88
+ */
69
89
  get logger(): ServerLogger;
90
+ /**
91
+ * Sets the logger instance
92
+ */
70
93
  set logger(value: ServerLogger);
71
94
  }
@@ -1,61 +1,92 @@
1
1
  /**
2
- * Abstract class representing a WebSocket adapter.
2
+ * Abstract class that provides a base implementation for WebSocket adapters.
3
+ * Handles WebSocket connections, registration, and management.
3
4
  *
4
- * @template A - The type of the application.
5
- * @template AM - The type of the message.
5
+ * @template A - Type of the application instance
6
+ * @template R - Type of the request object
7
+ * @template S - Type of the response object
6
8
  */
7
9
  export class AsenaWebsocketAdapter {
10
+ name;
8
11
  /**
9
- * The WebSocket services.
10
- * @ string - The namespace of the WebSocket.
11
- * @ AsenaWebSocketService<any> - The WebSocket service.
12
- * @ MH[] - The middlewares to use.
12
+ * Registry containing WebSocket services and their configurations
13
+ * Structure:
14
+ * - Key: WebSocket namespace
15
+ * - Value: Object containing:
16
+ * - service: WebSocket service instance
17
+ * - middlewares: Array of middleware functions
13
18
  * @protected
14
19
  */
15
20
  _websockets;
16
21
  /**
17
- * The application instance.
22
+ * Reference to the main application instance
18
23
  * @private
19
24
  */
20
25
  _app;
21
26
  /**
22
- * The WebSocket handler.
27
+ * WebSocket handler instance for managing connections
23
28
  * @private
24
29
  */
25
30
  _websocket;
26
31
  /**
27
- * The logger instance.
32
+ * Logger instance for WebSocket-related logging
33
+ * @private
28
34
  */
29
35
  _logger = console;
30
36
  /**
31
- * Constructor for the AsenaWebSocketAdapter class.
32
- * @param params - The parameters for the constructor.
37
+ * Initializes a new WebSocket adapter instance
38
+ * @param params - Configuration parameters including app instance and logger
33
39
  */
34
40
  constructor(params) {
35
41
  this._app = params?.app;
36
42
  this._logger = params?.logger;
37
43
  }
44
+ // Getters and Setters with improved documentation
45
+ /**
46
+ * Gets the application instance
47
+ */
38
48
  get app() {
39
49
  return this._app;
40
50
  }
51
+ /**
52
+ * Sets the application instance
53
+ */
41
54
  set app(value) {
42
55
  this._app = value;
43
56
  }
57
+ /**
58
+ * Gets the WebSocket registry
59
+ */
44
60
  get websockets() {
45
61
  return this._websockets;
46
62
  }
63
+ /**
64
+ * Sets the WebSocket registry
65
+ */
47
66
  set websockets(value) {
48
67
  this._websockets = value;
49
68
  }
69
+ /**
70
+ * Gets the WebSocket handler
71
+ */
50
72
  get websocket() {
51
73
  return this._websocket;
52
74
  }
75
+ /**
76
+ * Sets the WebSocket handler
77
+ */
53
78
  set websocket(value) {
54
79
  this._websocket = value;
55
80
  }
81
+ /**
82
+ * Gets the logger instance
83
+ */
56
84
  get logger() {
57
85
  return this._logger;
58
86
  }
87
+ /**
88
+ * Sets the logger instance
89
+ */
59
90
  set logger(value) {
60
91
  this._logger = value;
61
92
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AsenaWebsocketAdapter.js","sourceRoot":"","sources":["../../../lib/adapter/AsenaWebsocketAdapter.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,MAAM,OAAgB,qBAAqB;IAEzC;;;;;;OAMG;IACO,WAAW,CAAoB;IAEzC;;;OAGG;IACK,IAAI,CAAI;IAEhB;;;OAGG;IACK,UAAU,CAAmB;IAErC;;OAEG;IACK,OAAO,GAAiB,OAAO,CAAC;IAExC;;;OAGG;IACH,YAAsB,MAAkC;QACtD,IAAI,CAAC,IAAI,GAAG,MAAM,EAAE,GAAG,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,MAAM,EAAE,MAAM,CAAC;IAChC,CAAC;IA6BD,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,IAAW,GAAG,CAAC,KAAQ;QACrB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;IACpB,CAAC;IAED,IAAc,UAAU;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,IAAc,UAAU,CAAC,KAAwB;QAC/C,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,IAAW,SAAS,CAAC,KAAuB;QAC1C,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC1B,CAAC;IAED,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAW,MAAM,CAAC,KAAmB;QACnC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACvB,CAAC;CAEF"}
1
+ {"version":3,"file":"AsenaWebsocketAdapter.js","sourceRoot":"","sources":["../../../lib/adapter/AsenaWebsocketAdapter.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,MAAM,OAAgB,qBAAqB;IAEzB,IAAI,CAAS;IAE7B;;;;;;;;OAQG;IACO,WAAW,CAAuB;IAE5C;;;OAGG;IACK,IAAI,CAAI;IAEhB;;;OAGG;IACK,UAAU,CAAmB;IAErC;;;OAGG;IACK,OAAO,GAAiB,OAAO,CAAC;IAExC;;;OAGG;IACH,YAAsB,MAAkC;QACtD,IAAI,CAAC,IAAI,GAAG,MAAM,EAAE,GAAG,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,MAAM,EAAE,MAAM,CAAC;IAChC,CAAC;IAwBD,kDAAkD;IAElD;;OAEG;IACH,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,IAAW,GAAG,CAAC,KAAQ;QACrB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,IAAc,UAAU;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAc,UAAU,CAAC,KAA2B;QAClD,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,IAAW,SAAS,CAAC,KAAuB;QAC1C,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAW,MAAM,CAAC,KAAmB;QACnC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACvB,CAAC;CAEF"}
@@ -1,3 +1,4 @@
1
1
  export * from './AsenaAdapter';
2
+ export * from './AsenaWebsocketAdapter';
2
3
  export * from './AsenaContext';
3
4
  export * from './types';
@@ -1,4 +1,5 @@
1
1
  export * from './AsenaAdapter';
2
+ export * from './AsenaWebsocketAdapter';
2
3
  export * from './AsenaContext';
3
4
  export * from './types';
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/adapter/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/adapter/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,73 @@
1
+ import type { HttpMethod } from '../../server/web/types';
2
+ import type { AsenaContext } from '../index';
3
+ import type { MiddlewareClass, ValidatorClass } from "../../server/web/middleware";
4
+ /**
5
+ * Interface representing a route configuration.
6
+ *
7
+ * @template C - The context type extending AsenaContext.
8
+ * @template SH - The schema type for validation.
9
+ */
10
+ export interface Route<C extends AsenaContext<any, any> = any, SH = unknown> {
11
+ /**
12
+ * A dictionary where the key is a string representing the route name
13
+ * and the value is an object containing the parameters for the API route.
14
+ */
15
+ [key: string]: ApiParams<C, SH>;
16
+ }
17
+ /**
18
+ * Interface representing the parameters for an API route.
19
+ *
20
+ * @template C - The context type extending AsenaContext.
21
+ * @template SH - The schema type for validation.
22
+ */
23
+ export interface ApiParams<C extends AsenaContext<any, any> = any, SH = unknown> {
24
+ /** The path for the route. */
25
+ path: string;
26
+ /** The HTTP method for the route. */
27
+ method: HttpMethod;
28
+ /** A brief description of the route. */
29
+ description: string;
30
+ /** An array of middleware classes to be applied to the route. */
31
+ middlewares: MiddlewareClass<C>[];
32
+ /** A flag indicating whether to serve static files. */
33
+ staticServe: boolean;
34
+ /** The validator class for request validation. */
35
+ validator: ValidatorClass<SH>;
36
+ }
37
+ /**
38
+ * Type definition for a controller handler function.
39
+ *
40
+ * @template C - The context type extending AsenaContext.
41
+ * @param {C} c - The context object for the request and response.
42
+ * @param {...any[]} args - Additional arguments passed to the handler.
43
+ * @returns {void | Promise<void> | Promise<Response> | Response} - The result of the handler, which can be void, a promise resolving to void, a promise resolving to a Response, or a Response.
44
+ */
45
+ export type ControllerHandler<C extends AsenaContext<any, any> = any> = (c: C, ...args: any[]) => void | Promise<void> | Promise<Response> | Response;
46
+ /**
47
+ * Interface for defining parameters for a controller decorator.
48
+ *
49
+ * @template C - The context type extending AsenaContext.
50
+ * @template SH - The schema type for validation.
51
+ */
52
+ export interface ControllerDecoratorParams<C extends AsenaContext<any, any> = any, SH = any> {
53
+ /**
54
+ * The path for the route.
55
+ */
56
+ path: string;
57
+ /**
58
+ * Optional array of middleware classes to be applied.
59
+ */
60
+ middlewares?: MiddlewareClass<C>[];
61
+ /**
62
+ * Optional description of the route.
63
+ */
64
+ description?: string;
65
+ /**
66
+ * Optional flag to serve static files.
67
+ */
68
+ staticServe?: boolean;
69
+ /**
70
+ * Optional validator class for request validation.
71
+ */
72
+ validator?: ValidatorClass<SH>;
73
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ApiParams.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiParams.js","sourceRoot":"","sources":["../../../../lib/adapter/types/ApiParams.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import type { AsenaContext } from '../AsenaContext';
2
+ export type AsenaHandler<C extends AsenaContext<any, any> = any> = (context: C) => Promise<void | Response> | (Response | void);
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=AsenaHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AsenaHandler.js","sourceRoot":"","sources":["../../../../lib/adapter/types/AsenaHandler.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export type AsenaMiddlewareHandler<C> = (context: C, next: () => Promise<void>) => Promise<void> | any;
2
+ export type AsenaNextHandler = () => Promise<void>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=AsenaMiddlewareHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AsenaMiddlewareHandler.js","sourceRoot":"","sources":["../../../../lib/adapter/types/AsenaMiddlewareHandler.ts"],"names":[],"mappings":""}
@@ -0,0 +1,57 @@
1
+ import type { Class } from '../../server/types';
2
+ import type { ApiParams } from './ApiParams';
3
+ import type { AsenaContext, AsenaMiddlewareHandler } from '../index';
4
+ /**
5
+ * Interface representing a base middleware.
6
+ *
7
+ * @Templete context - The current Asena context
8
+ */
9
+ export interface BaseMiddleware<C extends AsenaContext<any, any> = any> {
10
+ handle: AsenaMiddlewareHandler<C>;
11
+ override: boolean;
12
+ }
13
+ /**
14
+ * Interface representing a handler for validation.
15
+ *
16
+ * @template S - The type of schema for validation.
17
+ */
18
+ export interface ValidatorHandler<S = unknown> {
19
+ handle: () => Promise<S> | S;
20
+ override: boolean;
21
+ }
22
+ /**
23
+ * Interface representing a base validator.
24
+ *
25
+ * @template S - The type of schema for validation.
26
+ */
27
+ export interface BaseValidator<S = unknown> {
28
+ /**
29
+ * Validator for JSON body.
30
+ */
31
+ json?: ValidatorHandler<S>;
32
+ /**
33
+ * Validator for query parameters.
34
+ */
35
+ query?: ValidatorHandler<S>;
36
+ /**
37
+ * Validator for form data.
38
+ */
39
+ form?: ValidatorHandler<S>;
40
+ /**
41
+ * Validator for URL parameters.
42
+ */
43
+ param?: ValidatorHandler<S>;
44
+ /**
45
+ * Validator for headers.
46
+ */
47
+ header?: ValidatorHandler<S>;
48
+ }
49
+ /**
50
+ * Interface representing the parameters required to prepare middleware.
51
+ */
52
+ export interface PrepareMiddlewareParams {
53
+ controller: Class;
54
+ routePath?: string;
55
+ params?: ApiParams;
56
+ }
57
+ export declare const VALIDATOR_METHODS: string[];
@@ -0,0 +1,2 @@
1
+ export const VALIDATOR_METHODS = ['json', 'query', 'form', 'param', 'header'];
2
+ //# sourceMappingURL=BaseMiddleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseMiddleware.js","sourceRoot":"","sources":["../../../../lib/adapter/types/BaseMiddleware.ts"],"names":[],"mappings":"AAiEA,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { AsenaContext } from '../AsenaContext';
2
+ export type ErrorHandler<C extends AsenaContext<any, any>> = (error: Error, context: C) => Response | Promise<Response>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ErrorHandler.js.map