@h4ad/serverless-adapter 2.3.0 → 2.4.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 (272) hide show
  1. package/README.md +4 -260
  2. package/lib/@types/binary-settings.d.ts +24 -6
  3. package/lib/@types/binary-settings.d.ts.map +1 -0
  4. package/lib/@types/binary-settings.js +1 -0
  5. package/lib/@types/binary-settings.js.map +1 -0
  6. package/lib/@types/headers.d.ts +16 -3
  7. package/lib/@types/headers.d.ts.map +1 -0
  8. package/lib/@types/headers.js +1 -0
  9. package/lib/@types/headers.js.map +1 -0
  10. package/lib/@types/helpers.d.ts +4 -0
  11. package/lib/@types/helpers.d.ts.map +1 -0
  12. package/lib/@types/helpers.js +1 -0
  13. package/lib/@types/helpers.js.map +1 -0
  14. package/lib/@types/huawei/huawei-api-gateway-event.d.ts +62 -0
  15. package/lib/@types/huawei/huawei-api-gateway-event.d.ts.map +1 -0
  16. package/lib/@types/huawei/huawei-api-gateway-event.js +2 -0
  17. package/lib/@types/huawei/huawei-api-gateway-event.js.map +1 -0
  18. package/lib/@types/huawei/huawei-api-gateway-response.d.ts +20 -0
  19. package/lib/@types/huawei/huawei-api-gateway-response.d.ts.map +1 -0
  20. package/lib/@types/huawei/huawei-api-gateway-response.js +2 -0
  21. package/lib/@types/huawei/huawei-api-gateway-response.js.map +1 -0
  22. package/lib/@types/huawei/huawei-context.d.ts +157 -0
  23. package/lib/@types/huawei/huawei-context.d.ts.map +1 -0
  24. package/lib/@types/huawei/huawei-context.js +1 -0
  25. package/lib/@types/huawei/huawei-context.js.map +1 -0
  26. package/lib/@types/huawei/index.d.ts +1 -0
  27. package/lib/@types/huawei/index.d.ts.map +1 -0
  28. package/lib/@types/huawei/index.js +6 -1
  29. package/lib/@types/huawei/index.js.map +1 -0
  30. package/lib/@types/index.d.ts +2 -1
  31. package/lib/@types/index.d.ts.map +1 -0
  32. package/lib/@types/index.js +7 -2
  33. package/lib/@types/index.js.map +1 -0
  34. package/lib/adapters/aws/alb.adapter.d.ts +18 -10
  35. package/lib/adapters/aws/alb.adapter.d.ts.map +1 -0
  36. package/lib/adapters/aws/alb.adapter.js +14 -9
  37. package/lib/adapters/aws/alb.adapter.js.map +1 -0
  38. package/lib/adapters/aws/api-gateway-v1.adapter.d.ts +20 -12
  39. package/lib/adapters/aws/api-gateway-v1.adapter.d.ts.map +1 -0
  40. package/lib/adapters/aws/api-gateway-v1.adapter.js +19 -14
  41. package/lib/adapters/aws/api-gateway-v1.adapter.js.map +1 -0
  42. package/lib/adapters/aws/api-gateway-v2.adapter.d.ts +19 -11
  43. package/lib/adapters/aws/api-gateway-v2.adapter.d.ts.map +1 -0
  44. package/lib/adapters/aws/api-gateway-v2.adapter.js +15 -10
  45. package/lib/adapters/aws/api-gateway-v2.adapter.js.map +1 -0
  46. package/lib/adapters/aws/dynamodb.adapter.d.ts +18 -10
  47. package/lib/adapters/aws/dynamodb.adapter.d.ts.map +1 -0
  48. package/lib/adapters/aws/dynamodb.adapter.js +13 -8
  49. package/lib/adapters/aws/dynamodb.adapter.js.map +1 -0
  50. package/lib/adapters/aws/event-bridge.adapter.d.ts +21 -10
  51. package/lib/adapters/aws/event-bridge.adapter.d.ts.map +1 -0
  52. package/lib/adapters/aws/event-bridge.adapter.js +13 -8
  53. package/lib/adapters/aws/event-bridge.adapter.js.map +1 -0
  54. package/lib/adapters/aws/index.d.ts +1 -0
  55. package/lib/adapters/aws/index.d.ts.map +1 -0
  56. package/lib/adapters/aws/index.js +6 -1
  57. package/lib/adapters/aws/index.js.map +1 -0
  58. package/lib/adapters/aws/lambda-edge.adapter.d.ts +76 -46
  59. package/lib/adapters/aws/lambda-edge.adapter.d.ts.map +1 -0
  60. package/lib/adapters/aws/lambda-edge.adapter.js +40 -24
  61. package/lib/adapters/aws/lambda-edge.adapter.js.map +1 -0
  62. package/lib/adapters/aws/sns.adapter.d.ts +18 -10
  63. package/lib/adapters/aws/sns.adapter.d.ts.map +1 -0
  64. package/lib/adapters/aws/sns.adapter.js +13 -8
  65. package/lib/adapters/aws/sns.adapter.js.map +1 -0
  66. package/lib/adapters/aws/sqs.adapter.d.ts +18 -10
  67. package/lib/adapters/aws/sqs.adapter.d.ts.map +1 -0
  68. package/lib/adapters/aws/sqs.adapter.js +13 -8
  69. package/lib/adapters/aws/sqs.adapter.js.map +1 -0
  70. package/lib/adapters/dummy/dummy.adapter.d.ts +9 -5
  71. package/lib/adapters/dummy/dummy.adapter.d.ts.map +1 -0
  72. package/lib/adapters/dummy/dummy.adapter.js +9 -5
  73. package/lib/adapters/dummy/dummy.adapter.js.map +1 -0
  74. package/lib/adapters/dummy/index.d.ts +1 -0
  75. package/lib/adapters/dummy/index.d.ts.map +1 -0
  76. package/lib/adapters/dummy/index.js +6 -1
  77. package/lib/adapters/dummy/index.js.map +1 -0
  78. package/lib/adapters/huawei/huawei-api-gateway.adapter.d.ts +19 -12
  79. package/lib/adapters/huawei/huawei-api-gateway.adapter.d.ts.map +1 -0
  80. package/lib/adapters/huawei/huawei-api-gateway.adapter.js +14 -9
  81. package/lib/adapters/huawei/huawei-api-gateway.adapter.js.map +1 -0
  82. package/lib/adapters/huawei/index.d.ts +1 -0
  83. package/lib/adapters/huawei/index.d.ts.map +1 -0
  84. package/lib/adapters/huawei/index.js +6 -1
  85. package/lib/adapters/huawei/index.js.map +1 -0
  86. package/lib/contracts/adapter.contract.d.ts +30 -30
  87. package/lib/contracts/adapter.contract.d.ts.map +1 -0
  88. package/lib/contracts/adapter.contract.js +2 -0
  89. package/lib/contracts/adapter.contract.js.map +1 -0
  90. package/lib/contracts/framework.contract.d.ts +7 -3
  91. package/lib/contracts/framework.contract.d.ts.map +1 -0
  92. package/lib/contracts/framework.contract.js +1 -0
  93. package/lib/contracts/framework.contract.js.map +1 -0
  94. package/lib/contracts/handler.contract.d.ts +7 -0
  95. package/lib/contracts/handler.contract.d.ts.map +1 -0
  96. package/lib/contracts/handler.contract.js +1 -0
  97. package/lib/contracts/handler.contract.js.map +1 -0
  98. package/lib/contracts/index.d.ts +1 -0
  99. package/lib/contracts/index.d.ts.map +1 -0
  100. package/lib/contracts/index.js +6 -1
  101. package/lib/contracts/index.js.map +1 -0
  102. package/lib/contracts/resolver.contract.d.ts +17 -4
  103. package/lib/contracts/resolver.contract.d.ts.map +1 -0
  104. package/lib/contracts/resolver.contract.js +1 -0
  105. package/lib/contracts/resolver.contract.js.map +1 -0
  106. package/lib/core/base-handler.d.ts +9 -5
  107. package/lib/core/base-handler.d.ts.map +1 -0
  108. package/lib/core/base-handler.js +9 -5
  109. package/lib/core/base-handler.js.map +1 -0
  110. package/lib/core/constants.d.ts +27 -0
  111. package/lib/core/constants.d.ts.map +1 -0
  112. package/lib/core/constants.js +21 -0
  113. package/lib/core/constants.js.map +1 -0
  114. package/lib/core/current-invoke.d.ts +17 -6
  115. package/lib/core/current-invoke.d.ts.map +1 -0
  116. package/lib/core/current-invoke.js +12 -4
  117. package/lib/core/current-invoke.js.map +1 -0
  118. package/lib/core/event-body.d.ts +9 -3
  119. package/lib/core/event-body.d.ts.map +1 -0
  120. package/lib/core/event-body.js +9 -3
  121. package/lib/core/event-body.js.map +1 -0
  122. package/lib/core/headers.d.ts +17 -6
  123. package/lib/core/headers.d.ts.map +1 -0
  124. package/lib/core/headers.js +17 -6
  125. package/lib/core/headers.js.map +1 -0
  126. package/lib/core/index.d.ts +1 -0
  127. package/lib/core/index.d.ts.map +1 -0
  128. package/lib/core/index.js +6 -1
  129. package/lib/core/index.js.map +1 -0
  130. package/lib/core/is-binary.d.ts +29 -11
  131. package/lib/core/is-binary.d.ts.map +1 -0
  132. package/lib/core/is-binary.js +29 -11
  133. package/lib/core/is-binary.js.map +1 -0
  134. package/lib/core/logger.d.ts +22 -5
  135. package/lib/core/logger.d.ts.map +1 -0
  136. package/lib/core/logger.js +8 -3
  137. package/lib/core/logger.js.map +1 -0
  138. package/lib/core/no-op.d.ts +4 -0
  139. package/lib/core/no-op.d.ts.map +1 -0
  140. package/lib/core/no-op.js +4 -0
  141. package/lib/core/no-op.js.map +1 -0
  142. package/lib/core/optional.d.ts +8 -3
  143. package/lib/core/optional.d.ts.map +1 -0
  144. package/lib/core/optional.js +8 -3
  145. package/lib/core/optional.js.map +1 -0
  146. package/lib/core/path.d.ts +14 -5
  147. package/lib/core/path.d.ts.map +1 -0
  148. package/lib/core/path.js +14 -5
  149. package/lib/core/path.js.map +1 -0
  150. package/lib/core/stream.d.ts +5 -1
  151. package/lib/core/stream.d.ts.map +1 -0
  152. package/lib/core/stream.js +6 -2
  153. package/lib/core/stream.js.map +1 -0
  154. package/lib/frameworks/express/express.framework.d.ts +5 -1
  155. package/lib/frameworks/express/express.framework.d.ts.map +1 -0
  156. package/lib/frameworks/express/express.framework.js +5 -1
  157. package/lib/frameworks/express/express.framework.js.map +1 -0
  158. package/lib/frameworks/express/index.d.ts +1 -0
  159. package/lib/frameworks/express/index.d.ts.map +1 -0
  160. package/lib/frameworks/express/index.js +6 -1
  161. package/lib/frameworks/express/index.js.map +1 -0
  162. package/lib/frameworks/fastify/fastify.framework.d.ts +5 -1
  163. package/lib/frameworks/fastify/fastify.framework.d.ts.map +1 -0
  164. package/lib/frameworks/fastify/fastify.framework.js +5 -1
  165. package/lib/frameworks/fastify/fastify.framework.js.map +1 -0
  166. package/lib/frameworks/fastify/index.d.ts +1 -0
  167. package/lib/frameworks/fastify/index.d.ts.map +1 -0
  168. package/lib/frameworks/fastify/index.js +6 -1
  169. package/lib/frameworks/fastify/index.js.map +1 -0
  170. package/lib/frameworks/hapi/hapi.framework.d.ts +5 -1
  171. package/lib/frameworks/hapi/hapi.framework.d.ts.map +1 -0
  172. package/lib/frameworks/hapi/hapi.framework.js +5 -1
  173. package/lib/frameworks/hapi/hapi.framework.js.map +1 -0
  174. package/lib/frameworks/hapi/index.d.ts +1 -0
  175. package/lib/frameworks/hapi/index.d.ts.map +1 -0
  176. package/lib/frameworks/hapi/index.js +6 -1
  177. package/lib/frameworks/hapi/index.js.map +1 -0
  178. package/lib/frameworks/koa/index.d.ts +1 -0
  179. package/lib/frameworks/koa/index.d.ts.map +1 -0
  180. package/lib/frameworks/koa/index.js +6 -1
  181. package/lib/frameworks/koa/index.js.map +1 -0
  182. package/lib/frameworks/koa/koa.framework.d.ts +5 -1
  183. package/lib/frameworks/koa/koa.framework.d.ts.map +1 -0
  184. package/lib/frameworks/koa/koa.framework.js +5 -1
  185. package/lib/frameworks/koa/koa.framework.js.map +1 -0
  186. package/lib/frameworks/lazy/index.d.ts +2 -0
  187. package/lib/frameworks/lazy/index.d.ts.map +1 -0
  188. package/lib/frameworks/lazy/index.js +17 -0
  189. package/lib/frameworks/lazy/index.js.map +1 -0
  190. package/lib/frameworks/lazy/lazy.framework.d.ts +7 -2
  191. package/lib/frameworks/lazy/lazy.framework.d.ts.map +1 -0
  192. package/lib/frameworks/lazy/lazy.framework.js +7 -2
  193. package/lib/frameworks/lazy/lazy.framework.js.map +1 -0
  194. package/lib/frameworks/trpc/index.d.ts +2 -0
  195. package/lib/frameworks/trpc/index.d.ts.map +1 -0
  196. package/lib/frameworks/trpc/index.js +18 -0
  197. package/lib/frameworks/trpc/index.js.map +1 -0
  198. package/lib/frameworks/trpc/trpc.framework.d.ts +152 -0
  199. package/lib/frameworks/trpc/trpc.framework.d.ts.map +1 -0
  200. package/lib/frameworks/trpc/trpc.framework.js +119 -0
  201. package/lib/frameworks/trpc/trpc.framework.js.map +1 -0
  202. package/lib/handlers/default/default.handler.d.ts +36 -32
  203. package/lib/handlers/default/default.handler.d.ts.map +1 -0
  204. package/lib/handlers/default/default.handler.js +36 -32
  205. package/lib/handlers/default/default.handler.js.map +1 -0
  206. package/lib/handlers/default/index.d.ts +1 -0
  207. package/lib/handlers/default/index.d.ts.map +1 -0
  208. package/lib/handlers/default/index.js +6 -1
  209. package/lib/handlers/default/index.js.map +1 -0
  210. package/lib/handlers/huawei/http-huawei.handler.d.ts +14 -4
  211. package/lib/handlers/huawei/http-huawei.handler.d.ts.map +1 -0
  212. package/lib/handlers/huawei/http-huawei.handler.js +15 -4
  213. package/lib/handlers/huawei/http-huawei.handler.js.map +1 -0
  214. package/lib/handlers/huawei/index.d.ts +1 -0
  215. package/lib/handlers/huawei/index.d.ts.map +1 -0
  216. package/lib/handlers/huawei/index.js +6 -1
  217. package/lib/handlers/huawei/index.js.map +1 -0
  218. package/lib/index.d.ts +1 -0
  219. package/lib/index.d.ts.map +1 -0
  220. package/lib/index.js +6 -1
  221. package/lib/index.js.map +1 -0
  222. package/lib/network/index.d.ts +1 -0
  223. package/lib/network/index.d.ts.map +1 -0
  224. package/lib/network/index.js +6 -1
  225. package/lib/network/index.js.map +1 -0
  226. package/lib/network/request.d.ts +28 -0
  227. package/lib/network/request.d.ts.map +1 -0
  228. package/lib/network/request.js +7 -0
  229. package/lib/network/request.js.map +1 -0
  230. package/lib/network/response.d.ts +18 -1
  231. package/lib/network/response.d.ts.map +1 -0
  232. package/lib/network/response.js +9 -1
  233. package/lib/network/response.js.map +1 -0
  234. package/lib/resolvers/aws-context/aws-context.resolver.d.ts +7 -9
  235. package/lib/resolvers/aws-context/aws-context.resolver.d.ts.map +1 -0
  236. package/lib/resolvers/aws-context/aws-context.resolver.js +7 -9
  237. package/lib/resolvers/aws-context/aws-context.resolver.js.map +1 -0
  238. package/lib/resolvers/aws-context/index.d.ts +1 -0
  239. package/lib/resolvers/aws-context/index.d.ts.map +1 -0
  240. package/lib/resolvers/aws-context/index.js +6 -1
  241. package/lib/resolvers/aws-context/index.js.map +1 -0
  242. package/lib/resolvers/callback/callback.resolver.d.ts +9 -2
  243. package/lib/resolvers/callback/callback.resolver.d.ts.map +1 -0
  244. package/lib/resolvers/callback/callback.resolver.js +6 -2
  245. package/lib/resolvers/callback/callback.resolver.js.map +1 -0
  246. package/lib/resolvers/callback/index.d.ts +1 -0
  247. package/lib/resolvers/callback/index.d.ts.map +1 -0
  248. package/lib/resolvers/callback/index.js +6 -1
  249. package/lib/resolvers/callback/index.js.map +1 -0
  250. package/lib/resolvers/dummy/dummy.resolver.d.ts +5 -1
  251. package/lib/resolvers/dummy/dummy.resolver.d.ts.map +1 -0
  252. package/lib/resolvers/dummy/dummy.resolver.js +5 -1
  253. package/lib/resolvers/dummy/dummy.resolver.js.map +1 -0
  254. package/lib/resolvers/dummy/index.d.ts +1 -0
  255. package/lib/resolvers/dummy/index.d.ts.map +1 -0
  256. package/lib/resolvers/dummy/index.js +6 -1
  257. package/lib/resolvers/dummy/index.js.map +1 -0
  258. package/lib/resolvers/promise/index.d.ts +1 -0
  259. package/lib/resolvers/promise/index.d.ts.map +1 -0
  260. package/lib/resolvers/promise/index.js +6 -1
  261. package/lib/resolvers/promise/index.js.map +1 -0
  262. package/lib/resolvers/promise/promise.resolver.d.ts +5 -1
  263. package/lib/resolvers/promise/promise.resolver.d.ts.map +1 -0
  264. package/lib/resolvers/promise/promise.resolver.js +5 -1
  265. package/lib/resolvers/promise/promise.resolver.js.map +1 -0
  266. package/lib/serverless-adapter.d.ts +17 -12
  267. package/lib/serverless-adapter.d.ts.map +1 -0
  268. package/lib/serverless-adapter.js +17 -12
  269. package/lib/serverless-adapter.js.map +1 -0
  270. package/package.json +29 -4
  271. package/lib/@types/proxy-params.d.ts +0 -8
  272. package/lib/@types/proxy-params.js +0 -2
@@ -1 +1,2 @@
1
1
  export * from './fastify.framework';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/frameworks/fastify/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -11,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
15
  };
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
13
17
  __exportStar(require("./fastify.framework"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/frameworks/fastify/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC"}
@@ -4,10 +4,14 @@ import type { Server } from 'hapi';
4
4
  import { FrameworkContract } from '../../contracts';
5
5
  /**
6
6
  * The framework that forwards requests to hapi handler
7
+ *
8
+ * @breadcrumb Frameworks / HapiFramework
9
+ * @public
7
10
  */
8
11
  export declare class HapiFramework implements FrameworkContract<Server> {
9
12
  /**
10
- * @inheritDoc
13
+ * {@inheritDoc}
11
14
  */
12
15
  sendRequest(app: Server, request: IncomingMessage, response: ServerResponse): void;
13
16
  }
17
+ //# sourceMappingURL=hapi.framework.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hapi.framework.d.ts","sourceRoot":"","sources":["../../../src/frameworks/hapi/hapi.framework.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIpD;;;;;GAKG;AACH,qBAAa,aAAc,YAAW,iBAAiB,CAAC,MAAM,CAAC;IAC7D;;OAEG;IACI,WAAW,CAChB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,cAAc,GACvB,IAAI;CAKR"}
@@ -5,10 +5,13 @@ exports.HapiFramework = void 0;
5
5
  //#endregion
6
6
  /**
7
7
  * The framework that forwards requests to hapi handler
8
+ *
9
+ * @breadcrumb Frameworks / HapiFramework
10
+ * @public
8
11
  */
9
12
  class HapiFramework {
10
13
  /**
11
- * @inheritDoc
14
+ * {@inheritDoc}
12
15
  */
13
16
  sendRequest(app, request, response) {
14
17
  const httpServer = app.listener;
@@ -16,3 +19,4 @@ class HapiFramework {
16
19
  }
17
20
  }
18
21
  exports.HapiFramework = HapiFramework;
22
+ //# sourceMappingURL=hapi.framework.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hapi.framework.js","sourceRoot":"","sources":["../../../src/frameworks/hapi/hapi.framework.ts"],"names":[],"mappings":";AAAA,iBAAiB;;;AAMjB,YAAY;AAEZ;;;;;GAKG;AACH,MAAa,aAAa;IACxB;;OAEG;IACI,WAAW,CAChB,GAAW,EACX,OAAwB,EACxB,QAAwB;QAExB,MAAM,UAAU,GAAQ,GAAG,CAAC,QAAQ,CAAC;QAErC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAChD,CAAC;CACF;AAbD,sCAaC"}
@@ -1 +1,2 @@
1
1
  export * from './hapi.framework';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/frameworks/hapi/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -11,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
15
  };
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
13
17
  __exportStar(require("./hapi.framework"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/frameworks/hapi/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"}
@@ -1 +1,2 @@
1
1
  export * from './koa.framework';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/frameworks/koa/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -11,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
15
  };
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
13
17
  __exportStar(require("./koa.framework"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/frameworks/koa/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC"}
@@ -4,10 +4,14 @@ import type Application from 'koa';
4
4
  import { FrameworkContract } from '../../contracts';
5
5
  /**
6
6
  * The framework that forwards requests to koa handler
7
+ *
8
+ * @breadcrumb Frameworks / KoaFramework
9
+ * @public
7
10
  */
8
11
  export declare class KoaFramework implements FrameworkContract<Application> {
9
12
  /**
10
- * @inheritDoc
13
+ * {@inheritDoc}
11
14
  */
12
15
  sendRequest(app: Application, request: IncomingMessage, response: ServerResponse): void;
13
16
  }
17
+ //# sourceMappingURL=koa.framework.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"koa.framework.d.ts","sourceRoot":"","sources":["../../../src/frameworks/koa/koa.framework.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AACvD,OAAO,KAAK,WAAW,MAAM,KAAK,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIpD;;;;;GAKG;AACH,qBAAa,YAAa,YAAW,iBAAiB,CAAC,WAAW,CAAC;IACjE;;OAEG;IACI,WAAW,CAChB,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,cAAc,GACvB,IAAI;CAGR"}
@@ -5,13 +5,17 @@ exports.KoaFramework = void 0;
5
5
  //#endregion
6
6
  /**
7
7
  * The framework that forwards requests to koa handler
8
+ *
9
+ * @breadcrumb Frameworks / KoaFramework
10
+ * @public
8
11
  */
9
12
  class KoaFramework {
10
13
  /**
11
- * @inheritDoc
14
+ * {@inheritDoc}
12
15
  */
13
16
  sendRequest(app, request, response) {
14
17
  app.callback()(request, response);
15
18
  }
16
19
  }
17
20
  exports.KoaFramework = KoaFramework;
21
+ //# sourceMappingURL=koa.framework.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"koa.framework.js","sourceRoot":"","sources":["../../../src/frameworks/koa/koa.framework.ts"],"names":[],"mappings":";AAAA,iBAAiB;;;AAMjB,YAAY;AAEZ;;;;;GAKG;AACH,MAAa,YAAY;IACvB;;OAEG;IACI,WAAW,CAChB,GAAgB,EAChB,OAAwB,EACxB,QAAwB;QAExB,GAAG,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC;CACF;AAXD,oCAWC"}
@@ -0,0 +1,2 @@
1
+ export * from './lazy.framework';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/frameworks/lazy/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
@@ -1 +1,18 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./lazy.framework"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/frameworks/lazy/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"}
@@ -5,7 +5,8 @@ import { ILogger } from '../../core';
5
5
  /**
6
6
  * The framework that asynchronously instantiates your application and forwards the request to the framework as quickly as possible.
7
7
  *
8
- * @example```typescript
8
+ * @example
9
+ * ```typescript
9
10
  * import express from 'express';
10
11
  * import { ServerlessAdapter } from '@h4ad/serverless-adapter';
11
12
  * import { ExpressFramework } from '@h4ad/serverless-adapter/lib/frameworks/express';
@@ -27,6 +28,9 @@ import { ILogger } from '../../core';
27
28
  * // set other configurations and then build
28
29
  * .build();
29
30
  * ```
31
+ *
32
+ * @breadcrumb Frameworks / LazyFramework
33
+ * @public
30
34
  */
31
35
  export declare class LazyFramework<TApp> implements FrameworkContract<null> {
32
36
  protected readonly framework: FrameworkContract<TApp>;
@@ -45,7 +49,8 @@ export declare class LazyFramework<TApp> implements FrameworkContract<null> {
45
49
  */
46
50
  protected readonly delayedFactory: Promise<void>;
47
51
  /**
48
- * @inheritDoc
52
+ * {@inheritDoc}
49
53
  */
50
54
  sendRequest(app: null, request: IncomingMessage, response: ServerResponse): void;
51
55
  }
56
+ //# sourceMappingURL=lazy.framework.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazy.framework.d.ts","sourceRoot":"","sources":["../../../src/frameworks/lazy/lazy.framework.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAuB,MAAM,YAAY,CAAC;AAI1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,aAAa,CAAC,IAAI,CAAE,YAAW,iBAAiB,CAAC,IAAI,CAAC;IAO/D,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC,IAAI,CAAC;IACrD,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC;IAC/C,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO;IANpC;;OAEG;gBAEkB,SAAS,EAAE,iBAAiB,CAAC,IAAI,CAAC,EAClC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAC5B,MAAM,GAAE,OAA+B;IAqB5D;;OAEG;IACH,SAAS,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC;IAE3B;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAMjD;;OAEG;IACI,WAAW,CAChB,GAAG,EAAE,IAAI,EACT,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,cAAc,GACvB,IAAI;CAmBR"}
@@ -7,7 +7,8 @@ const core_1 = require("../../core");
7
7
  /**
8
8
  * The framework that asynchronously instantiates your application and forwards the request to the framework as quickly as possible.
9
9
  *
10
- * @example```typescript
10
+ * @example
11
+ * ```typescript
11
12
  * import express from 'express';
12
13
  * import { ServerlessAdapter } from '@h4ad/serverless-adapter';
13
14
  * import { ExpressFramework } from '@h4ad/serverless-adapter/lib/frameworks/express';
@@ -29,6 +30,9 @@ const core_1 = require("../../core");
29
30
  * // set other configurations and then build
30
31
  * .build();
31
32
  * ```
33
+ *
34
+ * @breadcrumb Frameworks / LazyFramework
35
+ * @public
32
36
  */
33
37
  class LazyFramework {
34
38
  //#region Constructor
@@ -54,7 +58,7 @@ class LazyFramework {
54
58
  //#endregion
55
59
  //#region Public Methods
56
60
  /**
57
- * @inheritDoc
61
+ * {@inheritDoc}
58
62
  */
59
63
  sendRequest(app, request, response) {
60
64
  if (this.cachedApp)
@@ -68,3 +72,4 @@ class LazyFramework {
68
72
  }
69
73
  }
70
74
  exports.LazyFramework = LazyFramework;
75
+ //# sourceMappingURL=lazy.framework.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazy.framework.js","sourceRoot":"","sources":["../../../src/frameworks/lazy/lazy.framework.ts"],"names":[],"mappings":";AAAA,iBAAiB;;;AAIjB,qCAA0D;AAE1D,YAAY;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAa,aAAa;IACxB,qBAAqB;IAErB;;OAEG;IACH,YACqB,SAAkC,EAClC,OAA4B,EAC5B,SAAkB,IAAA,0BAAmB,GAAE;QAFvC,cAAS,GAAT,SAAS,CAAyB;QAClC,YAAO,GAAP,OAAO,CAAqB;QAC5B,WAAM,GAAN,MAAM,CAAiC;QAE1D,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,OAAO,EAAE;aACpC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;aACrB,IAAI,CAAC,GAAG,CAAC,EAAE;YACV,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC;QACvB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAY,EAAE,EAAE;YACtB,qDAAqD;YACrD,4CAA4C;YAC5C,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,sFAAsF,CACvF,CAAC;YACF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACP,CAAC;IAgBD,YAAY;IAEZ,wBAAwB;IAExB;;OAEG;IACI,WAAW,CAChB,GAAS,EACT,OAAwB,EACxB,QAAwB;QAExB,IAAI,IAAI,CAAC,SAAS;YAChB,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QAEvE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE;YAC5B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;gBACnB,OAAO,QAAQ,CAAC,IAAI,CAClB,OAAO,EACP,IAAI,KAAK,CACP,8HAA8H,CAC/H,CACF,CAAC;aACH;YAED,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;IACL,CAAC;CAGF;AAtED,sCAsEC"}
@@ -0,0 +1,2 @@
1
+ export * from './trpc.framework';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/frameworks/trpc/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./trpc.framework"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/frameworks/trpc/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"}
@@ -0,0 +1,152 @@
1
+ /// <reference types="node" />
2
+ import { IncomingMessage, ServerResponse } from 'http';
3
+ import type { AnyRouter, DataTransformer } from '@trpc/server';
4
+ import { NodeHTTPCreateContextFnOptions, NodeHTTPHandlerOptions } from '@trpc/server/adapters/node-http';
5
+ import { SingleValueHeaders } from '../../@types';
6
+ import { FrameworkContract } from '../../contracts';
7
+ /**
8
+ * The transformer that is responsible to transform buffer's input to javascript objects
9
+ *
10
+ * @breadcrumb Frameworks / TrpcFramework
11
+ * @public
12
+ */
13
+ export declare class BufferToJSObjectTransformer implements DataTransformer {
14
+ /**
15
+ * Deserialize unknown values to javascript objects
16
+ *
17
+ * @param value - The value to be deserialized
18
+ */
19
+ deserialize(value?: unknown): any;
20
+ /**
21
+ * The value to be serialized, do nothing because tRPC can handle.
22
+ *
23
+ * @param value - The value to be serialized
24
+ */
25
+ serialize(value: any): any;
26
+ }
27
+ /**
28
+ * The context created by this library that allows getting some information from the request and setting the status and header of the response.
29
+ *
30
+ * @breadcrumb Frameworks / TrpcFramework
31
+ * @public
32
+ */
33
+ export interface TrpcAdapterBaseContext {
34
+ /**
35
+ * The request object that will be forward to your app
36
+ */
37
+ request: IncomingMessage;
38
+ /**
39
+ * The response object that will be forward to your app to output the response
40
+ */
41
+ response: ServerResponse;
42
+ /**
43
+ * The method to set response status.
44
+ *
45
+ * @param statusCode - The response status that you want
46
+ */
47
+ setStatus(statusCode: number): void;
48
+ /**
49
+ * The method to set some header in the response
50
+ *
51
+ * @param name - The name of the header
52
+ * @param value - The value to be set in the header
53
+ */
54
+ setHeader(name: string, value: number | string): void;
55
+ /**
56
+ * The method to remove some header from the response
57
+ *
58
+ * @param name - The name of the header
59
+ */
60
+ removeHeader(name: string): void;
61
+ /**
62
+ * The method to return the value of some header from the request
63
+ *
64
+ * @param name - The name of the header
65
+ */
66
+ getHeader(name: string): string | undefined;
67
+ /**
68
+ * The method to return the request headers
69
+ */
70
+ getHeaders(): SingleValueHeaders;
71
+ /**
72
+ * The method to return user's address
73
+ */
74
+ getIp(): string | undefined;
75
+ /**
76
+ * The method to return the URL called
77
+ */
78
+ getUrl(): string | undefined;
79
+ /**
80
+ * The method to return the HTTP Method in the request
81
+ */
82
+ getMethod(): string | undefined;
83
+ }
84
+ /**
85
+ * This is the context merged between {@link TrpcAdapterBaseContext} and the {@link TContext} that you provided.
86
+ *
87
+ * This context will be merged with the context you created with `createContext` inside {@link TrpcFrameworkOptions}.
88
+ * So to make the type work, just send the properties you've added inside {@link TContext}.
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * type MyCustomContext = { user: { name: string } };
93
+ * type TrpcContext = TrpcAdapterContext<MyCustomContext>; // your final context type to put inside trpc.router
94
+ * ```
95
+ *
96
+ * @breadcrumb Frameworks / TrpcFramework
97
+ * @public
98
+ */
99
+ export declare type TrpcAdapterContext<TContext> = TContext & TrpcAdapterBaseContext;
100
+ /**
101
+ * The options to customize the {@link TrpcFramework}
102
+ *
103
+ * @breadcrumb Frameworks / TrpcFramework
104
+ * @public
105
+ */
106
+ export declare type TrpcFrameworkOptions<TContext> = Omit<NodeHTTPHandlerOptions<AnyRouter<TContext>, IncomingMessage, ServerResponse>, 'router' | 'createContext'> & {
107
+ createContext?: (opts: NodeHTTPCreateContextFnOptions<IncomingMessage, ServerResponse>) => Omit<TContext, keyof TrpcAdapterBaseContext> | Promise<Omit<TContext, keyof TrpcAdapterBaseContext>>;
108
+ };
109
+ /**
110
+ * The framework that forwards requests to TRPC handler
111
+ *
112
+ * @breadcrumb Frameworks / TrpcFramework
113
+ * @public
114
+ */
115
+ export declare class TrpcFramework<TContext extends TrpcAdapterBaseContext> implements FrameworkContract<AnyRouter<TContext>> {
116
+ protected readonly options?: TrpcFrameworkOptions<TContext> | undefined;
117
+ /**
118
+ * Default constructor
119
+ */
120
+ constructor(options?: TrpcFrameworkOptions<TContext> | undefined);
121
+ /**
122
+ * {@inheritDoc}
123
+ */
124
+ sendRequest(app: AnyRouter<TContext>, request: IncomingMessage, response: ServerResponse): void;
125
+ /**
126
+ * Get safe url that can be used inside Trpc.
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * const url = getSafeUrlForTrpc('/users?input=hello');
131
+ * console.log(url); // users
132
+ * ```
133
+ *
134
+ * @param request - The request object that will be forward to your app
135
+ */
136
+ protected getSafeUrlForTrpc(request: IncomingMessage): string;
137
+ /**
138
+ * Merge the default context ({@link TrpcAdapterContext}) with the context created by the user.
139
+ *
140
+ * @param createContextOptions - The options sent by trpc to create the context
141
+ */
142
+ protected mergeDefaultContextWithOptionsContext(createContextOptions: NodeHTTPCreateContextFnOptions<IncomingMessage, ServerResponse>): TContext | Promise<TContext>;
143
+ /**
144
+ * Wraps the resolved context from the {@link TrpcFrameworkOptions} created with `createContext` and merge
145
+ * with the {@link TrpcAdapterContext} generated by the library.
146
+ *
147
+ * @param resolvedContext - The context created with `createContext` inside {@link TrpcFrameworkOptions}
148
+ * @param createContextOptions - The options sent by trpc to create the context
149
+ */
150
+ protected wrapResolvedContextWithDefaultContext(resolvedContext: TContext, createContextOptions: NodeHTTPCreateContextFnOptions<IncomingMessage, ServerResponse>): TContext;
151
+ }
152
+ //# sourceMappingURL=trpc.framework.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trpc.framework.d.ts","sourceRoot":"","sources":["../../../src/frameworks/trpc/trpc.framework.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAEL,8BAA8B,EAC9B,sBAAsB,EAEvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAKpD;;;;;GAKG;AACH,qBAAa,2BAA4B,YAAW,eAAe;IACjE;;;;OAIG;IACI,WAAW,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,GAAG;IAMxC;;;;OAIG;IACI,SAAS,CAAC,KAAK,EAAE,GAAG,GAAG,GAAG;CAGlC;AAED;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,OAAO,EAAE,eAAe,CAAC;IAEzB;;OAEG;IACH,QAAQ,EAAE,cAAc,CAAC;IAEzB;;;;OAIG;IACH,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpC;;;;;OAKG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAEtD;;;;OAIG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjC;;;;OAIG;IACH,SAAS,CAAC,IAAI,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AoB,EAAE,8BAA8B,CAClD,eAAe,EACf,cAAc,CACf,GACA,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IA4B/B;;;;;;OAMG;IACH,SAAS,CAAC,qCAAqC,CAC7C,eAAe,EAAE,QAAQ,EACzB,oBAAoB,EAAE,8BAA8B,CAClD,eAAe,EACf,cAAc,CACf,GACA,QAAQ;CAiCZ"}
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ //#region
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.TrpcFramework = exports.BufferToJSObjectTransformer = void 0;
5
+ const node_http_1 = require("@trpc/server/adapters/node-http");
6
+ const core_1 = require("../../core");
7
+ //#endregion
8
+ /**
9
+ * The transformer that is responsible to transform buffer's input to javascript objects
10
+ *
11
+ * @breadcrumb Frameworks / TrpcFramework
12
+ * @public
13
+ */
14
+ class BufferToJSObjectTransformer {
15
+ /**
16
+ * Deserialize unknown values to javascript objects
17
+ *
18
+ * @param value - The value to be deserialized
19
+ */
20
+ deserialize(value) {
21
+ if (value instanceof Buffer)
22
+ return JSON.parse(value.toString('utf-8'));
23
+ return value;
24
+ }
25
+ /**
26
+ * The value to be serialized, do nothing because tRPC can handle.
27
+ *
28
+ * @param value - The value to be serialized
29
+ */
30
+ serialize(value) {
31
+ return value;
32
+ }
33
+ }
34
+ exports.BufferToJSObjectTransformer = BufferToJSObjectTransformer;
35
+ /**
36
+ * The framework that forwards requests to TRPC handler
37
+ *
38
+ * @breadcrumb Frameworks / TrpcFramework
39
+ * @public
40
+ */
41
+ class TrpcFramework {
42
+ //#region Constructor
43
+ /**
44
+ * Default constructor
45
+ */
46
+ constructor(options) {
47
+ this.options = options;
48
+ }
49
+ //#endregion
50
+ //#region Public Methods
51
+ /**
52
+ * {@inheritDoc}
53
+ */
54
+ sendRequest(app, request, response) {
55
+ const endpoint = this.getSafeUrlForTrpc(request);
56
+ (0, node_http_1.nodeHTTPRequestHandler)(Object.assign(Object.assign({ req: request, res: response, path: endpoint, router: app }, this.options), { createContext: createContextOptions => this.mergeDefaultContextWithOptionsContext(createContextOptions) }));
57
+ }
58
+ //#endregion
59
+ //#region Protected Methods
60
+ /**
61
+ * Get safe url that can be used inside Trpc.
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * const url = getSafeUrlForTrpc('/users?input=hello');
66
+ * console.log(url); // users
67
+ * ```
68
+ *
69
+ * @param request - The request object that will be forward to your app
70
+ */
71
+ getSafeUrlForTrpc(request) {
72
+ let url = request.url;
73
+ if (url.startsWith('/'))
74
+ url = url.slice(1);
75
+ if (url.includes('?'))
76
+ url = url.split('?')[0];
77
+ return url;
78
+ }
79
+ /**
80
+ * Merge the default context ({@link TrpcAdapterContext}) with the context created by the user.
81
+ *
82
+ * @param createContextOptions - The options sent by trpc to create the context
83
+ */
84
+ mergeDefaultContextWithOptionsContext(createContextOptions) {
85
+ var _a;
86
+ const createContextFromOptions = (0, core_1.getDefaultIfUndefined)((_a = this.options) === null || _a === void 0 ? void 0 : _a.createContext, () => undefined);
87
+ const resolvedContext = createContextFromOptions(createContextOptions);
88
+ if (resolvedContext && resolvedContext.then) {
89
+ return resolvedContext.then(context => this.wrapResolvedContextWithDefaultContext(context, createContextOptions));
90
+ }
91
+ return this.wrapResolvedContextWithDefaultContext(resolvedContext, createContextOptions);
92
+ }
93
+ /**
94
+ * Wraps the resolved context from the {@link TrpcFrameworkOptions} created with `createContext` and merge
95
+ * with the {@link TrpcAdapterContext} generated by the library.
96
+ *
97
+ * @param resolvedContext - The context created with `createContext` inside {@link TrpcFrameworkOptions}
98
+ * @param createContextOptions - The options sent by trpc to create the context
99
+ */
100
+ wrapResolvedContextWithDefaultContext(resolvedContext, createContextOptions) {
101
+ const request = createContextOptions.req;
102
+ const response = createContextOptions.res;
103
+ return Object.assign(Object.assign({}, resolvedContext), { request,
104
+ response, getUrl: () => request.url, getMethod: () => request.method, getHeaders: () => (0, core_1.getFlattenedHeadersMap)(request.headers, ',', true), setHeader: (header, value) => {
105
+ response.setHeader(header, value);
106
+ }, removeHeader: header => {
107
+ response.removeHeader(header);
108
+ }, getHeader: (header) => {
109
+ return (0, core_1.getFlattenedHeadersMap)(request.headers, ',', true)[header.toLowerCase()];
110
+ }, setStatus: (statusCode) => {
111
+ response.statusCode = statusCode;
112
+ // force undefined to get default message for the status code
113
+ // ref: https://nodejs.org/dist/latest-v16.x/docs/api/http.html#responsestatusmessage
114
+ response.statusMessage = undefined;
115
+ }, getIp: () => request.connection.remoteAddress });
116
+ }
117
+ }
118
+ exports.TrpcFramework = TrpcFramework;
119
+ //# sourceMappingURL=trpc.framework.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trpc.framework.js","sourceRoot":"","sources":["../../../src/frameworks/trpc/trpc.framework.ts"],"names":[],"mappings":";AAAA,SAAS;;;AAIT,+DAKyC;AAGzC,qCAA2E;AAE3E,YAAY;AAEZ;;;;;GAKG;AACH,MAAa,2BAA2B;IACtC;;;;OAIG;IACI,WAAW,CAAC,KAAe;QAChC,IAAI,KAAK,YAAY,MAAM;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAExE,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,KAAU;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AApBD,kEAoBC;AAuGD;;;;;GAKG;AACH,MAAa,aAAa;IAGxB,qBAAqB;IAErB;;OAEG;IACH,YAA+B,OAAwC;QAAxC,YAAO,GAAP,OAAO,CAAiC;IAAG,CAAC;IAE3E,YAAY;IAEZ,wBAAwB;IAExB;;OAEG;IACI,WAAW,CAChB,GAAwB,EACxB,OAAwB,EACxB,QAAwB;QAExB,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAEjD,IAAA,kCAAsB,gCACpB,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,QAAQ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