@h4ad/serverless-adapter 2.16.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (321) hide show
  1. package/README.md +7 -0
  2. package/lib/@types/binary-settings.js +2 -11
  3. package/lib/@types/binary-settings.js.map +1 -1
  4. package/lib/@types/digital-ocean/digital-ocean-http-event.js +2 -7
  5. package/lib/@types/digital-ocean/digital-ocean-http-event.js.map +1 -1
  6. package/lib/@types/digital-ocean/digital-ocean-http-response.js +2 -7
  7. package/lib/@types/digital-ocean/digital-ocean-http-response.js.map +1 -1
  8. package/lib/@types/digital-ocean/index.js +2 -18
  9. package/lib/@types/digital-ocean/index.js.map +1 -1
  10. package/lib/@types/headers.js +2 -11
  11. package/lib/@types/headers.js.map +1 -1
  12. package/lib/@types/helpers.js +2 -6
  13. package/lib/@types/helpers.js.map +1 -1
  14. package/lib/@types/huawei/huawei-api-gateway-event.js +2 -14
  15. package/lib/@types/huawei/huawei-api-gateway-event.js.map +1 -1
  16. package/lib/@types/huawei/huawei-api-gateway-response.js +2 -7
  17. package/lib/@types/huawei/huawei-api-gateway-response.js.map +1 -1
  18. package/lib/@types/huawei/huawei-context.js +2 -36
  19. package/lib/@types/huawei/huawei-context.js.map +1 -1
  20. package/lib/@types/huawei/index.js +2 -20
  21. package/lib/@types/huawei/index.js.map +1 -1
  22. package/lib/@types/index.js +2 -20
  23. package/lib/@types/index.js.map +1 -1
  24. package/lib/adapters/apollo-server/apollo-server-mutation.adapter.js +2 -86
  25. package/lib/adapters/apollo-server/apollo-server-mutation.adapter.js.map +1 -1
  26. package/lib/adapters/apollo-server/index.js +2 -18
  27. package/lib/adapters/apollo-server/index.js.map +1 -1
  28. package/lib/adapters/aws/alb.adapter.js +2 -129
  29. package/lib/adapters/aws/alb.adapter.js.map +1 -1
  30. package/lib/adapters/aws/api-gateway-v1.adapter.js +2 -140
  31. package/lib/adapters/aws/api-gateway-v1.adapter.js.map +1 -1
  32. package/lib/adapters/aws/api-gateway-v2.adapter.js +2 -133
  33. package/lib/adapters/aws/api-gateway-v2.adapter.js.map +1 -1
  34. package/lib/adapters/aws/base/aws-simple-adapter.js +2 -99
  35. package/lib/adapters/aws/base/aws-simple-adapter.js.map +1 -1
  36. package/lib/adapters/aws/base/index.js +2 -18
  37. package/lib/adapters/aws/base/index.js.map +1 -1
  38. package/lib/adapters/aws/dynamodb.adapter.js +2 -64
  39. package/lib/adapters/aws/dynamodb.adapter.js.map +1 -1
  40. package/lib/adapters/aws/event-bridge.adapter.js +2 -75
  41. package/lib/adapters/aws/event-bridge.adapter.js.map +1 -1
  42. package/lib/adapters/aws/index.js +2 -27
  43. package/lib/adapters/aws/index.js.map +1 -1
  44. package/lib/adapters/aws/lambda-edge.adapter.js +2 -284
  45. package/lib/adapters/aws/lambda-edge.adapter.js.map +1 -1
  46. package/lib/adapters/aws/s3.adapter.js +2 -63
  47. package/lib/adapters/aws/s3.adapter.js.map +1 -1
  48. package/lib/adapters/aws/sns.adapter.js +2 -63
  49. package/lib/adapters/aws/sns.adapter.js.map +1 -1
  50. package/lib/adapters/aws/sqs.adapter.js +2 -64
  51. package/lib/adapters/aws/sqs.adapter.js.map +1 -1
  52. package/lib/adapters/azure/http-trigger-v4.adapter.js +2 -202
  53. package/lib/adapters/azure/http-trigger-v4.adapter.js.map +1 -1
  54. package/lib/adapters/azure/index.js +2 -18
  55. package/lib/adapters/azure/index.js.map +1 -1
  56. package/lib/adapters/digital-ocean/http-function.adapter.js +2 -118
  57. package/lib/adapters/digital-ocean/http-function.adapter.js.map +1 -1
  58. package/lib/adapters/digital-ocean/index.js +2 -18
  59. package/lib/adapters/digital-ocean/index.js.map +1 -1
  60. package/lib/adapters/dummy/dummy.adapter.js +2 -54
  61. package/lib/adapters/dummy/dummy.adapter.js.map +1 -1
  62. package/lib/adapters/dummy/index.js +2 -18
  63. package/lib/adapters/dummy/index.js.map +1 -1
  64. package/lib/adapters/huawei/huawei-api-gateway.adapter.js +2 -126
  65. package/lib/adapters/huawei/huawei-api-gateway.adapter.js.map +1 -1
  66. package/lib/adapters/huawei/index.js +2 -18
  67. package/lib/adapters/huawei/index.js.map +1 -1
  68. package/lib/contracts/adapter.contract.js +2 -18
  69. package/lib/contracts/adapter.contract.js.map +1 -1
  70. package/lib/contracts/framework.contract.js +2 -7
  71. package/lib/contracts/framework.contract.js.map +1 -1
  72. package/lib/contracts/handler.contract.js +2 -13
  73. package/lib/contracts/handler.contract.js.map +1 -1
  74. package/lib/contracts/index.js +2 -21
  75. package/lib/contracts/index.js.map +1 -1
  76. package/lib/contracts/resolver.contract.js +2 -15
  77. package/lib/contracts/resolver.contract.js.map +1 -1
  78. package/lib/core/base-handler.js +2 -67
  79. package/lib/core/base-handler.js.map +1 -1
  80. package/lib/core/constants.js +2 -33
  81. package/lib/core/constants.js.map +1 -1
  82. package/lib/core/current-invoke.js +2 -46
  83. package/lib/core/current-invoke.js.map +1 -1
  84. package/lib/core/event-body.js +2 -31
  85. package/lib/core/event-body.js.map +1 -1
  86. package/lib/core/headers.js +3 -67
  87. package/lib/core/headers.js.map +1 -1
  88. package/lib/core/index.js +2 -28
  89. package/lib/core/index.js.map +1 -1
  90. package/lib/core/is-binary.js +2 -118
  91. package/lib/core/is-binary.js.map +1 -1
  92. package/lib/core/logger.js +2 -115
  93. package/lib/core/logger.js.map +1 -1
  94. package/lib/core/no-op.js +2 -12
  95. package/lib/core/no-op.js.map +1 -1
  96. package/lib/core/optional.js +2 -31
  97. package/lib/core/optional.js.map +1 -1
  98. package/lib/core/path.js +2 -68
  99. package/lib/core/path.js.map +1 -1
  100. package/lib/core/stream.js +2 -63
  101. package/lib/core/stream.js.map +1 -1
  102. package/lib/frameworks/apollo-server/apollo-server.framework.js +2 -87
  103. package/lib/frameworks/apollo-server/apollo-server.framework.js.map +1 -1
  104. package/lib/frameworks/apollo-server/index.js +2 -18
  105. package/lib/frameworks/apollo-server/index.js.map +1 -1
  106. package/lib/frameworks/body-parser/base-body-parser.framework.js +2 -66
  107. package/lib/frameworks/body-parser/base-body-parser.framework.js.map +1 -1
  108. package/lib/frameworks/body-parser/index.js +2 -22
  109. package/lib/frameworks/body-parser/index.js.map +1 -1
  110. package/lib/frameworks/body-parser/json-body-parser.framework.js +2 -29
  111. package/lib/frameworks/body-parser/json-body-parser.framework.js.map +1 -1
  112. package/lib/frameworks/body-parser/raw-body-parser.framework.js +2 -29
  113. package/lib/frameworks/body-parser/raw-body-parser.framework.js.map +1 -1
  114. package/lib/frameworks/body-parser/text-body-parser.framework.js +2 -29
  115. package/lib/frameworks/body-parser/text-body-parser.framework.js.map +1 -1
  116. package/lib/frameworks/body-parser/urlencoded-body-parser.framework.js +2 -29
  117. package/lib/frameworks/body-parser/urlencoded-body-parser.framework.js.map +1 -1
  118. package/lib/frameworks/cors/cors.framework.js +3 -145
  119. package/lib/frameworks/cors/cors.framework.js.map +1 -1
  120. package/lib/frameworks/cors/index.js +2 -18
  121. package/lib/frameworks/cors/index.js.map +1 -1
  122. package/lib/frameworks/deepkit/http-deepkit.framework.js +2 -33
  123. package/lib/frameworks/deepkit/http-deepkit.framework.js.map +1 -1
  124. package/lib/frameworks/deepkit/index.js +2 -18
  125. package/lib/frameworks/deepkit/index.js.map +1 -1
  126. package/lib/frameworks/express/express.framework.js +2 -22
  127. package/lib/frameworks/express/express.framework.js.map +1 -1
  128. package/lib/frameworks/express/index.js +2 -18
  129. package/lib/frameworks/express/index.js.map +1 -1
  130. package/lib/frameworks/fastify/fastify.framework.js +2 -23
  131. package/lib/frameworks/fastify/fastify.framework.js.map +1 -1
  132. package/lib/frameworks/fastify/helpers/no-op-content-parser.js +2 -27
  133. package/lib/frameworks/fastify/helpers/no-op-content-parser.js.map +1 -1
  134. package/lib/frameworks/fastify/index.js +2 -18
  135. package/lib/frameworks/fastify/index.js.map +1 -1
  136. package/lib/frameworks/hapi/hapi.framework.js +2 -23
  137. package/lib/frameworks/hapi/hapi.framework.js.map +1 -1
  138. package/lib/frameworks/hapi/index.js +2 -18
  139. package/lib/frameworks/hapi/index.js.map +1 -1
  140. package/lib/frameworks/koa/index.js +2 -18
  141. package/lib/frameworks/koa/index.js.map +1 -1
  142. package/lib/frameworks/koa/koa.framework.js +2 -22
  143. package/lib/frameworks/koa/koa.framework.js.map +1 -1
  144. package/lib/frameworks/lazy/index.js +2 -18
  145. package/lib/frameworks/lazy/index.js.map +1 -1
  146. package/lib/frameworks/lazy/lazy.framework.js +2 -82
  147. package/lib/frameworks/lazy/lazy.framework.js.map +1 -1
  148. package/lib/frameworks/trpc/index.js +2 -18
  149. package/lib/frameworks/trpc/index.js.map +1 -1
  150. package/lib/frameworks/trpc/trpc.framework.js +2 -152
  151. package/lib/frameworks/trpc/trpc.framework.js.map +1 -1
  152. package/lib/handlers/aws/aws-stream.handler.js +2 -0
  153. package/lib/handlers/aws/aws-stream.handler.js.map +1 -0
  154. package/lib/handlers/aws/index.js +2 -0
  155. package/lib/handlers/aws/index.js.map +1 -0
  156. package/lib/handlers/azure/azure.handler.js +2 -74
  157. package/lib/handlers/azure/azure.handler.js.map +1 -1
  158. package/lib/handlers/azure/index.js +2 -18
  159. package/lib/handlers/azure/index.js.map +1 -1
  160. package/lib/handlers/base/index.js +2 -18
  161. package/lib/handlers/base/index.js.map +1 -1
  162. package/lib/handlers/base/raw-request.js +2 -65
  163. package/lib/handlers/base/raw-request.js.map +1 -1
  164. package/lib/handlers/default/default.handler.js +2 -191
  165. package/lib/handlers/default/default.handler.js.map +1 -1
  166. package/lib/handlers/default/index.js +2 -18
  167. package/lib/handlers/default/index.js.map +1 -1
  168. package/lib/handlers/digital-ocean/digital-ocean.handler.js +2 -34
  169. package/lib/handlers/digital-ocean/digital-ocean.handler.js.map +1 -1
  170. package/lib/handlers/digital-ocean/index.js +2 -18
  171. package/lib/handlers/digital-ocean/index.js.map +1 -1
  172. package/lib/handlers/firebase/http-firebase-v2.handler.js +2 -50
  173. package/lib/handlers/firebase/http-firebase-v2.handler.js.map +1 -1
  174. package/lib/handlers/firebase/http-firebase.handler.js +2 -27
  175. package/lib/handlers/firebase/http-firebase.handler.js.map +1 -1
  176. package/lib/handlers/firebase/index.js +2 -19
  177. package/lib/handlers/firebase/index.js.map +1 -1
  178. package/lib/handlers/gcp/gcp.handler.js +2 -40
  179. package/lib/handlers/gcp/gcp.handler.js.map +1 -1
  180. package/lib/handlers/gcp/index.js +2 -18
  181. package/lib/handlers/gcp/index.js.map +1 -1
  182. package/lib/handlers/huawei/http-huawei.handler.js +2 -106
  183. package/lib/handlers/huawei/http-huawei.handler.js.map +1 -1
  184. package/lib/handlers/huawei/index.js +2 -18
  185. package/lib/handlers/huawei/index.js.map +1 -1
  186. package/lib/index.doc.js +2 -0
  187. package/lib/index.doc.js.map +1 -0
  188. package/lib/index.js +2 -22
  189. package/lib/index.js.map +1 -1
  190. package/lib/network/index.js +2 -19
  191. package/lib/network/index.js.map +1 -1
  192. package/lib/network/request.js +2 -46
  193. package/lib/network/request.js.map +1 -1
  194. package/lib/network/response-stream.js +7 -0
  195. package/lib/network/response-stream.js.map +1 -0
  196. package/lib/network/response.js +4 -137
  197. package/lib/network/response.js.map +1 -1
  198. package/lib/network/utils.js +2 -0
  199. package/lib/network/utils.js.map +1 -0
  200. package/lib/resolvers/aws-context/aws-context.resolver.js +2 -59
  201. package/lib/resolvers/aws-context/aws-context.resolver.js.map +1 -1
  202. package/lib/resolvers/aws-context/index.js +2 -18
  203. package/lib/resolvers/aws-context/index.js.map +1 -1
  204. package/lib/resolvers/callback/callback.resolver.js +2 -53
  205. package/lib/resolvers/callback/callback.resolver.js.map +1 -1
  206. package/lib/resolvers/callback/index.js +2 -18
  207. package/lib/resolvers/callback/index.js.map +1 -1
  208. package/lib/resolvers/dummy/dummy.resolver.js +2 -24
  209. package/lib/resolvers/dummy/dummy.resolver.js.map +1 -1
  210. package/lib/resolvers/dummy/index.js +2 -18
  211. package/lib/resolvers/dummy/index.js.map +1 -1
  212. package/lib/resolvers/promise/index.js +2 -18
  213. package/lib/resolvers/promise/index.js.map +1 -1
  214. package/lib/resolvers/promise/promise.resolver.js +2 -48
  215. package/lib/resolvers/promise/promise.resolver.js.map +1 -1
  216. package/lib/serverless-adapter.js +2 -176
  217. package/lib/serverless-adapter.js.map +1 -1
  218. package/package.json +61 -79
  219. package/lib/@types/binary-settings.d.ts +0 -43
  220. package/lib/@types/digital-ocean/digital-ocean-http-event.d.ts +0 -37
  221. package/lib/@types/digital-ocean/digital-ocean-http-response.d.ts +0 -22
  222. package/lib/@types/digital-ocean/index.d.ts +0 -1
  223. package/lib/@types/headers.d.ts +0 -39
  224. package/lib/@types/helpers.d.ts +0 -10
  225. package/lib/@types/huawei/huawei-api-gateway-event.d.ts +0 -84
  226. package/lib/@types/huawei/huawei-api-gateway-response.d.ts +0 -27
  227. package/lib/@types/huawei/huawei-context.d.ts +0 -203
  228. package/lib/@types/huawei/index.d.ts +0 -3
  229. package/lib/@types/index.d.ts +0 -3
  230. package/lib/adapters/apollo-server/apollo-server-mutation.adapter.d.ts +0 -56
  231. package/lib/adapters/apollo-server/index.d.ts +0 -1
  232. package/lib/adapters/aws/alb.adapter.d.ts +0 -66
  233. package/lib/adapters/aws/api-gateway-v1.adapter.d.ts +0 -71
  234. package/lib/adapters/aws/api-gateway-v2.adapter.d.ts +0 -69
  235. package/lib/adapters/aws/base/aws-simple-adapter.d.ts +0 -85
  236. package/lib/adapters/aws/base/index.d.ts +0 -1
  237. package/lib/adapters/aws/dynamodb.adapter.d.ts +0 -56
  238. package/lib/adapters/aws/event-bridge.adapter.d.ts +0 -64
  239. package/lib/adapters/aws/index.d.ts +0 -10
  240. package/lib/adapters/aws/lambda-edge.adapter.d.ts +0 -213
  241. package/lib/adapters/aws/s3.adapter.d.ts +0 -56
  242. package/lib/adapters/aws/sns.adapter.d.ts +0 -56
  243. package/lib/adapters/aws/sqs.adapter.d.ts +0 -56
  244. package/lib/adapters/azure/http-trigger-v4.adapter.d.ts +0 -81
  245. package/lib/adapters/azure/index.d.ts +0 -1
  246. package/lib/adapters/digital-ocean/http-function.adapter.d.ts +0 -65
  247. package/lib/adapters/digital-ocean/index.d.ts +0 -1
  248. package/lib/adapters/dummy/dummy.adapter.d.ts +0 -30
  249. package/lib/adapters/dummy/index.d.ts +0 -1
  250. package/lib/adapters/huawei/huawei-api-gateway.adapter.d.ts +0 -66
  251. package/lib/adapters/huawei/index.d.ts +0 -1
  252. package/lib/contracts/adapter.contract.d.ts +0 -155
  253. package/lib/contracts/framework.contract.d.ts +0 -19
  254. package/lib/contracts/handler.contract.d.ts +0 -26
  255. package/lib/contracts/index.d.ts +0 -4
  256. package/lib/contracts/resolver.contract.d.ts +0 -86
  257. package/lib/core/base-handler.d.ts +0 -31
  258. package/lib/core/constants.d.ts +0 -31
  259. package/lib/core/current-invoke.d.ts +0 -48
  260. package/lib/core/event-body.d.ts +0 -21
  261. package/lib/core/headers.d.ts +0 -37
  262. package/lib/core/index.d.ts +0 -11
  263. package/lib/core/is-binary.d.ts +0 -72
  264. package/lib/core/logger.d.ts +0 -67
  265. package/lib/core/no-op.d.ts +0 -7
  266. package/lib/core/optional.d.ts +0 -21
  267. package/lib/core/path.d.ts +0 -36
  268. package/lib/core/stream.d.ts +0 -20
  269. package/lib/frameworks/apollo-server/apollo-server.framework.d.ts +0 -71
  270. package/lib/frameworks/apollo-server/index.d.ts +0 -1
  271. package/lib/frameworks/body-parser/base-body-parser.framework.d.ts +0 -69
  272. package/lib/frameworks/body-parser/index.d.ts +0 -5
  273. package/lib/frameworks/body-parser/json-body-parser.framework.d.ts +0 -26
  274. package/lib/frameworks/body-parser/raw-body-parser.framework.d.ts +0 -26
  275. package/lib/frameworks/body-parser/text-body-parser.framework.d.ts +0 -26
  276. package/lib/frameworks/body-parser/urlencoded-body-parser.framework.d.ts +0 -26
  277. package/lib/frameworks/cors/cors.framework.d.ts +0 -78
  278. package/lib/frameworks/cors/index.d.ts +0 -1
  279. package/lib/frameworks/deepkit/http-deepkit.framework.d.ts +0 -17
  280. package/lib/frameworks/deepkit/index.d.ts +0 -1
  281. package/lib/frameworks/express/express.framework.d.ts +0 -16
  282. package/lib/frameworks/express/index.d.ts +0 -1
  283. package/lib/frameworks/fastify/fastify.framework.d.ts +0 -16
  284. package/lib/frameworks/fastify/helpers/no-op-content-parser.d.ts +0 -13
  285. package/lib/frameworks/fastify/index.d.ts +0 -1
  286. package/lib/frameworks/hapi/hapi.framework.d.ts +0 -16
  287. package/lib/frameworks/hapi/index.d.ts +0 -1
  288. package/lib/frameworks/koa/index.d.ts +0 -1
  289. package/lib/frameworks/koa/koa.framework.d.ts +0 -16
  290. package/lib/frameworks/lazy/index.d.ts +0 -1
  291. package/lib/frameworks/lazy/lazy.framework.d.ts +0 -55
  292. package/lib/frameworks/trpc/index.d.ts +0 -1
  293. package/lib/frameworks/trpc/trpc.framework.d.ts +0 -154
  294. package/lib/handlers/azure/azure.handler.d.ts +0 -45
  295. package/lib/handlers/azure/index.d.ts +0 -1
  296. package/lib/handlers/base/index.d.ts +0 -1
  297. package/lib/handlers/base/raw-request.d.ts +0 -30
  298. package/lib/handlers/default/default.handler.d.ts +0 -87
  299. package/lib/handlers/default/index.d.ts +0 -1
  300. package/lib/handlers/digital-ocean/digital-ocean.handler.d.ts +0 -16
  301. package/lib/handlers/digital-ocean/index.d.ts +0 -1
  302. package/lib/handlers/firebase/http-firebase-v2.handler.d.ts +0 -26
  303. package/lib/handlers/firebase/http-firebase.handler.d.ts +0 -18
  304. package/lib/handlers/firebase/index.d.ts +0 -2
  305. package/lib/handlers/gcp/gcp.handler.d.ts +0 -25
  306. package/lib/handlers/gcp/index.d.ts +0 -1
  307. package/lib/handlers/huawei/http-huawei.handler.d.ts +0 -59
  308. package/lib/handlers/huawei/index.d.ts +0 -1
  309. package/lib/index.d.ts +0 -5
  310. package/lib/network/index.d.ts +0 -2
  311. package/lib/network/request.d.ts +0 -44
  312. package/lib/network/response.d.ts +0 -48
  313. package/lib/resolvers/aws-context/aws-context.resolver.d.ts +0 -18
  314. package/lib/resolvers/aws-context/index.d.ts +0 -1
  315. package/lib/resolvers/callback/callback.resolver.d.ts +0 -23
  316. package/lib/resolvers/callback/index.d.ts +0 -1
  317. package/lib/resolvers/dummy/dummy.resolver.d.ts +0 -13
  318. package/lib/resolvers/dummy/index.d.ts +0 -1
  319. package/lib/resolvers/promise/index.d.ts +0 -1
  320. package/lib/resolvers/promise/promise.resolver.d.ts +0 -13
  321. package/lib/serverless-adapter.d.ts +0 -118
@@ -1,176 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ServerlessAdapter = void 0;
4
- const { __ΩBinarySettings } = require('./@types');
5
- const { __ΩILogger } = require('./core');
6
- const { __ΩAdapterContract } = require('./contracts');
7
- const { __ΩFrameworkContract } = require('./contracts');
8
- const { __ΩResolverContract } = require('./contracts');
9
- const { __ΩHandlerContract } = require('./contracts');
10
- const { __ΩServerlessHandler } = require('./contracts');
11
- const __ΩExclude = ['T', 'U', 'l6!Re$!RPe#!e$"qk#%QRb!b"Pde"!p)'];
12
- const __ΩOmit = ['T', 'K', () => __ΩPick, () => __ΩExclude, 'b!b"e!!e!!ge!"o$#o##'];
13
- const __ΩPick = ['T', 'K', 'l+e#!e"!fRb!b"Pde""N#!'];
14
- const core_1 = require("./core");
15
- //#endregion
16
- /**
17
- * The class used to build the serverless handler.
18
- *
19
- * @example
20
- * ```typescript
21
- * const app = express();
22
- * export const handler = ServerlessAdapter.new(app)
23
- * .setFramework(new ExpressFramework())
24
- * .setHandler(new DefaultHandler())
25
- * .setResolver(new PromiseResolver())
26
- * .setRespondWithErrors(true)
27
- * .addAdapter(new AlbAdapter())
28
- * .addAdapter(new SQSAdapter())
29
- * .addAdapter(new SNSAdapter())
30
- * .build();
31
- * ```
32
- *
33
- * @breadcrumb ServerlessAdapter
34
- * @public
35
- */
36
- class ServerlessAdapter {
37
- //#region Constructor
38
- /**
39
- * Default constructor
40
- */
41
- constructor(app) {
42
- //#endregion
43
- //#region Protected Properties
44
- /**
45
- * Settings for whether the response should be treated as binary or not
46
- *
47
- * @defaultValue `contentEncodings` and `contentTypes` are set with {@link DEFAULT_BINARY_ENCODINGS} and {@link DEFAULT_BINARY_CONTENT_TYPES}, respectively.
48
- */
49
- this.binarySettings = {
50
- contentEncodings: core_1.DEFAULT_BINARY_ENCODINGS,
51
- contentTypes: core_1.DEFAULT_BINARY_CONTENT_TYPES,
52
- };
53
- /**
54
- * Indicates whether the error stack should be included in the response or not
55
- *
56
- * @remarks These errors will only be included when an error occurs while forwarding the event to the framework
57
- * @defaultValue True when NODE_ENV is equal to `development`
58
- */
59
- this.respondWithErrors = process.env.NODE_ENV === 'development';
60
- /**
61
- * The instance of the logger service
62
- */
63
- this.log = (0, core_1.createDefaultLogger)();
64
- /**
65
- * The list of adapters used to handle an event's request and response
66
- */
67
- this.adapters = [];
68
- this.app = app;
69
- }
70
- //#endregion
71
- //#region Static Methods
72
- /**
73
- * Creates a new instance of the builder with app (express, hapi, koa, etc...)
74
- *
75
- * @param app - The instance of the app
76
- */
77
- static new(app) {
78
- return new ServerlessAdapter(app);
79
- }
80
- //#endregion
81
- //#region Builder Methods
82
- /**
83
- * Defines the handler that will get the event, context and callback and pass it to the adapter and framework
84
- *
85
- * @param handler - The implementation of the handler contract
86
- */
87
- setHandler(handler) {
88
- if (this.handler)
89
- throw new Error('SERVERLESS_ADAPTER: The handler should not set twice.');
90
- this.handler = handler;
91
- return this;
92
- }
93
- /**
94
- * Defines the resolver that aims to resolve the response to serverless and stop its execution when the request ends
95
- *
96
- * @param resolver - The implementation of the resolver contract
97
- */
98
- setResolver(resolver) {
99
- if (this.resolver)
100
- throw new Error('SERVERLESS_ADAPTER: The resolver should not set twice.');
101
- this.resolver = resolver;
102
- return this;
103
- }
104
- /**
105
- * Defines the framework that will process requests
106
- *
107
- * @param framework - The implementation of the framework contract
108
- */
109
- setFramework(framework) {
110
- if (this.framework) {
111
- throw new Error('SERVERLESS_ADAPTER: The framework should not set twice.');
112
- }
113
- this.framework = framework;
114
- return this;
115
- }
116
- /**
117
- * Defines the logger service used during the execution of the handler
118
- *
119
- * @param logger - The implementation of the logger
120
- */
121
- setLogger(logger) {
122
- this.log = logger;
123
- return this;
124
- }
125
- /**
126
- * Defines the binary settings for whether the response should be treated as binary or not
127
- *
128
- * @param binarySettings - The binary settings
129
- */
130
- setBinarySettings(binarySettings) {
131
- this.binarySettings = binarySettings;
132
- return this;
133
- }
134
- /**
135
- * Defines the responseWithErrors, a property that indicates whether the error stack should be included in the response or not
136
- *
137
- * @param respondWithErrors - Should include or not the errors in response
138
- */
139
- setRespondWithErrors(respondWithErrors) {
140
- this.respondWithErrors = respondWithErrors;
141
- return this;
142
- }
143
- /**
144
- * Add an adapter to the adapters list to handle the event coming from any serverless event source
145
- *
146
- * @param adapter - The implementation of the adapter contract
147
- */
148
- addAdapter(adapter) {
149
- this.adapters.push(adapter);
150
- return this;
151
- }
152
- /**
153
- * The builder method that returns the handler function to be exported for serverless consumption
154
- */
155
- build() {
156
- if (!this.resolver) {
157
- throw new Error('SERVERLESS_ADAPTER: Is required to set a resolver before build.');
158
- }
159
- if (!this.framework) {
160
- throw new Error('SERVERLESS_ADAPTER: Is required to set a framework before build.');
161
- }
162
- if (!this.handler) {
163
- throw new Error('SERVERLESS_ADAPTER: Is required to set a handler before build.');
164
- }
165
- if (this.adapters.length === 0) {
166
- throw new Error('SERVERLESS_ADAPTER: Is required to set at least one adapter.');
167
- }
168
- return this.handler.getHandler(this.app, this.framework, this.adapters, this.resolver, this.binarySettings, this.respondWithErrors, this.log);
169
- }
170
- }
171
- exports.ServerlessAdapter = ServerlessAdapter;
172
- ServerlessAdapter.__type = ['TApp', 'TEvent', 'TContext', 'TCallback', 'TResponse', 'TReturn', 'app', 'constructor', () => __ΩBinarySettings, 'binarySettings', function () { return {
173
- contentEncodings: core_1.DEFAULT_BINARY_ENCODINGS,
174
- contentTypes: core_1.DEFAULT_BINARY_CONTENT_TYPES,
175
- }; }, 'respondWithErrors', function () { return process.env.NODE_ENV === 'development'; }, () => __ΩILogger, 'log', function () { return (0, core_1.createDefaultLogger)(); }, () => __ΩAdapterContract, 'adapters', function () { return []; }, () => __ΩFrameworkContract, 'framework', () => __ΩResolverContract, 'resolver', () => __ΩHandlerContract, 'handler', () => ServerlessAdapter, 'new', () => __ΩHandlerContract, () => __ΩOmit, "setHandler", 'setHandler', () => __ΩResolverContract, () => __ΩOmit, "setResolver", 'setResolver', () => __ΩFrameworkContract, () => __ΩOmit, "setFramework", 'setFramework', () => __ΩILogger, 'logger', () => __ΩOmit, "setLogger", 'setLogger', () => __ΩBinarySettings, () => __ΩOmit, "setBinarySettings", 'setBinarySettings', () => __ΩOmit, "setRespondWithErrors", 'setRespondWithErrors', () => __ΩAdapterContract, 'adapter', () => __ΩPick, "addAdapter", "build", 'addAdapter', () => __ΩServerlessHandler, 'build', 'b!b"b#b$b%b&Pe"!2\'"0(e!!3\'<n)3*<>+)3,<>-n.3/<>0e!"e!#e!%o1$F32<>3e!!o4"358<e!"e!#e!$e!%e!&o6&378<e!!e!"e!#e!$e!%e!&o8\'398<Pe"!2\'Pe#!e#"e##e#$e#%e#&7:0;sPe"!e""e"#e"$e"%e"&o<\'29!.>o=#0?Pe""e"#e"$e"%e"&o@&27!.BoA#0CPe"!oD"25!.FoE#0GPnH2I!.KoJ#0LPnM2*!.OoN#0PP)2,!.RoQ#0SPe""e"#e"%oT$2U!P.W.XJoV#0YPe"&oZ"0[5'];
176
- //# sourceMappingURL=serverless-adapter.js.map
1
+ "use strict";var i=Object.defineProperty,E=Object.getOwnPropertyDescriptor,p=Object.getOwnPropertyNames,l=Object.prototype.hasOwnProperty,d=(e,r)=>{for(var s in r)i(e,s,{get:r[s],enumerable:!0})},u=(e,r,s,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of p(r))!l.call(e,t)&&t!==s&&i(e,t,{get:()=>r[t],enumerable:!(a=E(r,t))||a.enumerable});return e},w=e=>u(i({},"__esModule",{value:!0}),e),h={};d(h,{ServerlessAdapter:()=>n});module.exports=w(h);var o=require("./core");class n{constructor(r){this.binarySettings={contentEncodings:o.DEFAULT_BINARY_ENCODINGS,contentTypes:o.DEFAULT_BINARY_CONTENT_TYPES},this.respondWithErrors=process.env.NODE_ENV==="development",this.log=(0,o.createDefaultLogger)(),this.adapters=[],this.app=r}static new(r){return new n(r)}setHandler(r){if(this.handler)throw new Error("SERVERLESS_ADAPTER: The handler should not set twice.");return this.handler=r,this}setResolver(r){if(this.resolver)throw new Error("SERVERLESS_ADAPTER: The resolver should not set twice.");return this.resolver=r,this}setFramework(r){if(this.framework)throw new Error("SERVERLESS_ADAPTER: The framework should not set twice.");return this.framework=r,this}setLogger(r){return this.log=r,this}setBinarySettings(r){return this.binarySettings={...this.binarySettings,...r},this}setRespondWithErrors(r){return this.respondWithErrors=r,this}addAdapter(r){return this.adapters.push(r),this}build(){if(!this.resolver)throw new Error("SERVERLESS_ADAPTER: Is required to set a resolver before build.");if(!this.framework)throw new Error("SERVERLESS_ADAPTER: Is required to set a framework before build.");if(!this.handler)throw new Error("SERVERLESS_ADAPTER: Is required to set a handler before build.");if(this.adapters.length===0)throw new Error("SERVERLESS_ADAPTER: Is required to set at least one adapter.");return this.handler.getHandler(this.app,this.framework,this.adapters,this.resolver,this.binarySettings,this.respondWithErrors,this.log)}}
2
+ //# sourceMappingURL=serverless-adapter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"serverless-adapter.js","sourceRoot":"","sources":["../src/serverless-adapter.ts"],"names":[],"mappings":";;;sCAE+B,UAAU;+BAalC,QAAQ;uCANR,aAAa;yCAAb,aAAa;wCAAb,aAAa;uCAAb,aAAa;yCAAb,aAAa;;;;AACpB,iCAKgB;AAEhB,YAAY;AAEZ;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAa,iBAAiB;IAQ5B,qBAAqB;IAErB;;OAEG;IACH,YAAoB,GAAS;QAa7B,YAAY;QAEZ,8BAA8B;QAE9B;;;;WAIG;QACO,mBAAc,GAAmB;YACzC,gBAAgB,EAAE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ourcesContent":["//#region Imports\n\nimport { BinarySettings } from './@types';\nimport {\n AdapterContract,\n FrameworkContract,\n HandlerContract,\n ResolverContract,\n ServerlessHandler,\n} from './contracts';\nimport {\n DEFAULT_BINARY_CONTENT_TYPES,\n DEFAULT_BINARY_ENCODINGS,\n ILogger,\n createDefaultLogger,\n} from './core';\n\n//#endregion\n\n/**\n * The class used to build the serverless handler.\n *\n * @example\n * ```typescript\n * const app = express();\n * export const handler = ServerlessAdapter.new(app)\n * .setFramework(new ExpressFramework())\n * .setHandler(new DefaultHandler())\n * .setResolver(new PromiseResolver())\n * .setRespondWithErrors(true)\n * .addAdapter(new AlbAdapter())\n * .addAdapter(new SQSAdapter())\n * .addAdapter(new SNSAdapter())\n * .build();\n * ```\n *\n * @breadcrumb ServerlessAdapter\n * @public\n */\nexport class ServerlessAdapter<\n TApp,\n TEvent,\n TContext,\n TCallback,\n TResponse,\n TReturn,\n> {\n //#region Constructor\n\n /**\n * Default constructor\n */\n private constructor(app: TApp) {\n this.app = app;\n }\n\n //#endregion\n\n //#region Protected Properties\n\n /**\n * The instance of the app (express, hapi, koa, etc...)\n */\n protected app: TApp;\n\n //#endregion\n\n //#region Protected Properties\n\n /**\n * Settings for whether the response should be treated as binary or not\n *\n * @defaultValue `contentEncodings` and `contentTypes` are set with {@link DEFAULT_BINARY_ENCODINGS} and {@link DEFAULT_BINARY_CONTENT_TYPES}, respectively.\n */\n protected binarySettings: BinarySettings = {\n contentEncodings: DEFAULT_BINARY_ENCODINGS,\n contentTypes: DEFAULT_BINARY_CONTENT_TYPES,\n };\n\n /**\n * Indicates whether the error stack should be included in the response or not\n *\n * @remarks These errors will only be included when an error occurs while forwarding the event to the framework\n * @defaultValue True when NODE_ENV is equal to `development`\n */\n protected respondWithErrors: boolean = process.env.NODE_ENV === 'development';\n\n /**\n * The instance of the logger service\n */\n protected log: ILogger = createDefaultLogger();\n\n /**\n * The list of adapters used to handle an event's request and response\n */\n protected adapters: AdapterContract<TEvent, TContext, TResponse>[] = [];\n\n /**\n * The framework that will process requests\n */\n protected framework?: FrameworkContract<TApp>;\n\n /**\n * The resolver that aims to resolve the response to serverless and stop its execution when the request ends\n */\n protected resolver?: ResolverContract<\n TEvent,\n TContext,\n TCallback,\n TResponse,\n TReturn\n >;\n\n /**\n * The handler that will get the event, context and callback and pass it to the adapter and framework\n */\n protected handler?: HandlerContract<\n TApp,\n TEvent,\n TContext,\n TCallback,\n TResponse,\n TReturn\n >;\n\n //#endregion\n\n //#region Static Methods\n\n /**\n * Creates a new instance of the builder with app (express, hapi, koa, etc...)\n *\n * @param app - The instance of the app\n */\n public static new<\n TApp,\n TEvent,\n TContext = any,\n TCallback = any,\n TResponse = any,\n TReturn = any,\n >(\n app: TApp,\n ): ServerlessAdapter<TApp, TEvent, TContext, TCallback, TResponse, TReturn> {\n return new ServerlessAdapter(app);\n }\n\n //#endregion\n\n //#region Builder Methods\n\n /**\n * Defines the handler that will get the event, context and callback and pass it to the adapter and framework\n *\n * @param handler - The implementation of the handler contract\n */\n public setHandler(\n handler: HandlerContract<\n TApp,\n TEvent,\n TContext,\n TCallback,\n TResponse,\n TReturn\n >,\n ): Omit<this, 'setHandler'> {\n if (this.handler)\n throw new Error('SERVERLESS_ADAPTER: The handler should not set twice.');\n\n this.handler = handler;\n\n return this;\n }\n\n /**\n * Defines the resolver that aims to resolve the response to serverless and stop its execution when the request ends\n *\n * @param resolver - The implementation of the resolver contract\n */\n public setResolver(\n resolver: ResolverContract<TEvent, TContext, TCallback, TResponse, TReturn>,\n ): Omit<this, 'setResolver'> {\n if (this.resolver)\n throw new Error('SERVERLESS_ADAPTER: The resolver should not set twice.');\n\n this.resolver = resolver;\n\n return this;\n }\n\n /**\n * Defines the framework that will process requests\n *\n * @param framework - The implementation of the framework contract\n */\n public setFramework(\n framework: FrameworkContract<TApp>,\n ): Omit<this, 'setFramework'> {\n if (this.framework) {\n throw new Error(\n 'SERVERLESS_ADAPTER: The framework should not set twice.',\n );\n }\n\n this.framework = framework;\n\n return this;\n }\n\n /**\n * Defines the logger service used during the execution of the handler\n *\n * @param logger - The implementation of the logger\n */\n public setLogger(logger: ILogger): Omit<this, 'setLogger'> {\n this.log = logger;\n\n return this;\n }\n\n /**\n * Defines the binary settings for whether the response should be treated as binary or not\n *\n * @param binarySettings - The binary settings\n */\n public setBinarySettings(\n binarySettings: BinarySettings,\n ): Omit<this, 'setBinarySettings'> {\n this.binarySettings = {\n ...this.binarySettings,\n ...binarySettings,\n };\n\n return this;\n }\n\n /**\n * Defines the responseWithErrors, a property that indicates whether the error stack should be included in the response or not\n *\n * @param respondWithErrors - Should include or not the errors in response\n */\n public setRespondWithErrors(\n respondWithErrors: boolean,\n ): Omit<this, 'setRespondWithErrors'> {\n this.respondWithErrors = respondWithErrors;\n\n return this;\n }\n\n /**\n * Add an adapter to the adapters list to handle the event coming from any serverless event source\n *\n * @param adapter - The implementation of the adapter contract\n */\n public addAdapter(\n adapter: AdapterContract<TEvent, TContext, TResponse>,\n ): Pick<this, 'addAdapter' | 'build'> {\n this.adapters.push(adapter);\n\n return this;\n }\n\n /**\n * The builder method that returns the handler function to be exported for serverless consumption\n */\n public build(): ServerlessHandler<TReturn> {\n if (!this.resolver) {\n throw new Error(\n 'SERVERLESS_ADAPTER: Is required to set a resolver before build.',\n );\n }\n\n if (!this.framework) {\n throw new Error(\n 'SERVERLESS_ADAPTER: Is required to set a framework before build.',\n );\n }\n\n if (!this.handler) {\n throw new Error(\n 'SERVERLESS_ADAPTER: Is required to set a handler before build.',\n );\n }\n\n if (this.adapters.length === 0) {\n throw new Error(\n 'SERVERLESS_ADAPTER: Is required to set at least one adapter.',\n );\n }\n\n return this.handler.getHandler(\n this.app,\n this.framework,\n this.adapters,\n this.resolver,\n this.binarySettings,\n this.respondWithErrors,\n this.log,\n );\n }\n\n //#endregion\n}\n"],"names":["serverless_adapter_exports","__export","ServerlessAdapter","__toCommonJS","import_core","app","handler","resolver","framework","logger","binarySettings","respondWithErrors","adapter"],"mappings":"qZAAAA,E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AAQ,WAClB,KAAK,IACL,KAAK,UACL,KAAK,SACL,KAAK,SACL,KAAK,eACL,KAAK,kBACL,KAAK,GAAA,CAET,CAGF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h4ad/serverless-adapter",
3
- "version": "2.16.0",
3
+ "version": "3.0.0",
4
4
  "description": "Run REST APIs and other web applications using your existing Node.js application framework (NestJS, Express, Koa, Hapi, Fastify and many others), on top of AWS, Azure, Digital Ocean and many other clouds.",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -8,8 +8,9 @@
8
8
  ],
9
9
  "scripts": {
10
10
  "prepare": "husky install",
11
- "build": "tsc -p tsconfig.build.json",
12
- "build:docs": "tsc -p tsconfig.doc.json",
11
+ "build": "vite build",
12
+ "postbuild": "tsc -p tsconfig.build.json --emitDeclarationOnly",
13
+ "build:docs": "tsc -p tsconfig.doc.json --emitDeclarationOnly",
13
14
  "clean": "rm -rf ./lib/",
14
15
  "cm": "cz",
15
16
  "coverage": "codecov",
@@ -19,8 +20,8 @@
19
20
  "docs:generate:parsing": "npm run build:docs && ts-node scripts/parse-docs.ts",
20
21
  "docs:generate:markdown": "ts-node scripts/generate-markdown.ts",
21
22
  "docs:generate:api-pages": "ts-node scripts/generate-api-pages.ts",
22
- "test:watch": "jest --watch",
23
- "test": "jest --coverage",
23
+ "test:watch": "vitest --watch",
24
+ "test": "vitest --run --coverage",
24
25
  "typecheck": "tsc --noEmit"
25
26
  },
26
27
  "repository": {
@@ -34,7 +35,7 @@
34
35
  "url": "https://github.com/H4ad"
35
36
  },
36
37
  "engines": {
37
- "node": ">=12.0"
38
+ "node": ">=18.0.0"
38
39
  },
39
40
  "keywords": [
40
41
  "aws",
@@ -74,84 +75,79 @@
74
75
  },
75
76
  "homepage": "https://github.com/H4ad/serverless-adapter#readme",
76
77
  "devDependencies": {
77
- "@apollo/server": "*",
78
- "@azure/functions": "^3.2.0",
79
- "@deepkit/app": ">= 1.0.1-alpha.74",
80
- "@deepkit/core": ">= 1.0.1-alpha.74",
81
- "@deepkit/framework": ">= 1.0.1-alpha.74",
82
- "@deepkit/http": ">= 1.0.1-alpha.74",
83
- "@deepkit/type": ">= 1.0.1-alpha.74",
84
- "@deepkit/type-compiler": ">= 1.0.1-alpha.74",
85
- "@google-cloud/functions-framework": "^3.1.3",
86
- "@hapi/hapi": "^20.2.2",
87
- "@microsoft/api-documenter": "7.19.24",
88
- "@microsoft/api-extractor": "7.33.6",
89
- "@microsoft/api-extractor-model": "7.25.2",
78
+ "@apollo/server": "^4.7.1",
79
+ "@azure/functions": "^3.5.1",
80
+ "@deepkit/app": "1.0.1-alpha.98",
81
+ "@deepkit/framework": "1.0.1-alpha.99",
82
+ "@deepkit/http": "1.0.1-alpha.98",
83
+ "@deepkit/workflow": "1.0.1-alpha.97",
84
+ "@google-cloud/functions-framework": "^3.2.0",
85
+ "@hapi/hapi": "^21.3.2",
86
+ "@microsoft/api-documenter": "7.22.4",
87
+ "@microsoft/api-extractor": "7.34.8",
88
+ "@microsoft/api-extractor-model": "7.26.8",
90
89
  "@microsoft/tsdoc": "0.14.2",
91
- "@rushstack/node-core-library": "3.53.2",
92
- "@trpc/server": "^9.26.2",
93
- "@types/aws-lambda": "^8.10.92",
90
+ "@rushstack/node-core-library": "3.58.0",
91
+ "@semantic-release/changelog": "^6.0.3",
92
+ "@semantic-release/exec": "^6.0.3",
93
+ "@semantic-release/git": "^10.0.1",
94
+ "@semantic-release/github": "^9.0.2",
95
+ "@trpc/server": "^10.29.1",
96
+ "@types/aws-lambda": "^8.10.115",
94
97
  "@types/body-parser": "^1.19.2",
95
- "@types/cors": "^2.8.12",
96
- "@types/express": "^4.17.13",
97
- "@types/hapi": "^18.0.7",
98
- "@types/jest": "^28.1.6",
99
- "@types/koa": "^2.13.5",
100
- "@types/node": "12.20.43",
98
+ "@types/cors": "^2.8.13",
99
+ "@types/express": "^4.17.17",
100
+ "@types/koa": "^2.13.6",
101
+ "@types/node": "18.16.5",
101
102
  "@types/supertest": "^2.0.12",
102
- "@typescript-eslint/eslint-plugin": "^5.12.1",
103
- "@typescript-eslint/parser": "^5.12.1",
104
- "body-parser": "^1.20.1",
105
- "codecov": "^3.8.1",
106
- "commitizen": "^4.2.4",
103
+ "@typescript-eslint/eslint-plugin": "^5.59.2",
104
+ "@typescript-eslint/parser": "^5.59.2",
105
+ "@vitest/coverage-c8": "^0.31.0",
106
+ "body-parser": "^1.20.2",
107
+ "codecov": "^3.8.3",
108
+ "commitizen": "^4.3.0",
107
109
  "cors": "^2.8.5",
108
110
  "cz-conventional-changelog": "^3.3.0",
109
- "ejs": "^3.1.6",
110
- "eslint": "^8.9.0",
111
- "eslint-config-prettier": "^8.4.0",
112
- "eslint-plugin-import": "^2.25.4",
111
+ "eslint": "^8.40.0",
112
+ "eslint-config-prettier": "^8.8.0",
113
+ "eslint-plugin-import": "^2.27.5",
113
114
  "eslint-plugin-node": "^11.1.0",
114
- "eslint-plugin-prettier": "^4.0.0",
115
- "eslint-plugin-tsdoc": "^0.2.14",
116
- "express": "^4.18.1",
117
- "fastify": "^4.10.2",
118
- "fastify-3": "npm:fastify@3.29.0",
119
- "firebase-admin": "^11.0.1",
120
- "firebase-admin-8": "npm:firebase-admin@^8.0.0",
121
- "firebase-functions": "^3.22.0",
122
- "husky": "^6.0.0",
123
- "jest": "^28.1.3",
124
- "koa": "^2.13.4",
125
- "lint-staged": "^10.5.4",
126
- "prettier": "^2.5.1",
127
- "semantic-release": "^19.0.3",
128
- "stream-mock": "^2.0.5",
129
- "supertest": "^6.2.3",
130
- "ts-jest": "^28.0.7",
131
- "ts-node": "^10.9.1",
132
- "typedoc": "^0.23.21",
133
- "typescript": "~4.7.4"
115
+ "eslint-plugin-prettier": "^4.2.1",
116
+ "eslint-plugin-tsdoc": "^0.2.17",
117
+ "express": "^4.18.2",
118
+ "fastify": "^4.17.0",
119
+ "firebase-admin": "^11.8.0",
120
+ "firebase-functions": "^3.24.1",
121
+ "glob": "^10.2.2",
122
+ "husky": "^8.0.3",
123
+ "koa": "^2.14.2",
124
+ "prettier": "~2.8.8",
125
+ "semantic-release": "~21.0.2",
126
+ "stream-mock": "~2.0.5",
127
+ "supertest": "~6.3.3",
128
+ "ts-node": "~10.9.1",
129
+ "typedoc": "~0.24.6",
130
+ "typescript": "~4.9.5",
131
+ "vite": "^4.3.5",
132
+ "vitest": "^0.31.0"
134
133
  },
135
134
  "peerDependencies": {
136
135
  "@apollo/server": ">= 4.0.0",
137
136
  "@azure/functions": ">= 2.0.0",
138
- "@deepkit/http": ">= 1.0.1-alpha.74",
137
+ "@deepkit/http": ">= 1.0.1-alpha.94",
139
138
  "@google-cloud/functions-framework": ">= 3.0.0",
140
- "@hapi/hapi": ">= 20.0.0",
141
- "@trpc/server": ">= 9.0.0",
139
+ "@hapi/hapi": ">= 21.0.0",
140
+ "@trpc/server": ">= 10.0.0",
142
141
  "@types/aws-lambda": ">= 8.10.92",
143
142
  "@types/body-parser": ">= 1.19.2",
144
143
  "@types/cors": ">= 2.8.12",
145
144
  "@types/express": ">= 4.15.4",
146
- "@types/hapi": ">= 18.0.7",
147
145
  "@types/koa": ">= 2.11.2",
148
146
  "body-parser": ">= 1.20.0",
149
147
  "cors": ">= 2.8.5",
150
148
  "express": ">= 4.15.4",
151
- "fastify": ">= 3.0.0",
152
- "fastify-3": "npm:fastify@3.29.0",
153
- "firebase-admin": ">= 8.0.0",
154
- "firebase-admin-8": "npm:firebase-admin@^8.0.0",
149
+ "fastify": ">= 4.0.0",
150
+ "firebase-admin": ">= 11.0.0",
155
151
  "firebase-functions": ">= 3.0.0",
156
152
  "http-errors": ">= 2.0.0",
157
153
  "koa": ">= 2.5.1",
@@ -200,15 +196,9 @@
200
196
  "fastify": {
201
197
  "optional": true
202
198
  },
203
- "fastify-3": {
204
- "optional": true
205
- },
206
199
  "firebase-admin": {
207
200
  "optional": true
208
201
  },
209
- "firebase-admin-8": {
210
- "optional": true
211
- },
212
202
  "firebase-functions": {
213
203
  "optional": true
214
204
  },
@@ -227,14 +217,6 @@
227
217
  "path": "./node_modules/cz-conventional-changelog"
228
218
  }
229
219
  },
230
- "lint-staged": {
231
- "*.ts": "eslint --cache --cache-location .eslintcache --fix"
232
- },
233
- "release": {
234
- "branches": [
235
- "main"
236
- ]
237
- },
238
220
  "publishConfig": {
239
221
  "access": "public"
240
222
  }
@@ -1,43 +0,0 @@
1
- /**
2
- * The interface representing the binary settings implementation by function
3
- *
4
- * @breadcrumb Types / BinarySettings
5
- * @public
6
- */
7
- export interface BinarySettingsFunction {
8
- /**
9
- * This property can be a function that receives the response headers and returns whether that response should be encoded as binary.
10
- * Otherwise, you can specify not to treat any response as binary by putting `false` in this property.
11
- *
12
- * @remarks Setting this property prevents the `contentTypes` and `contentEncodings` properties from being used.
13
- */
14
- isBinary: ((headers: Record<string, string | string[] | undefined>) => boolean) | false;
15
- }
16
- /**
17
- * The interface representing the binary settings implementation by looking inside the headers
18
- *
19
- * @breadcrumb Types / BinarySettings
20
- * @public
21
- */
22
- export interface BinarySettingsContentHeaders {
23
- /**
24
- * The list of content types that will be treated as binary
25
- */
26
- contentTypes: (string | RegExp)[];
27
- /**
28
- * The list of content encodings that will be treated as binary
29
- */
30
- contentEncodings: string[];
31
- }
32
- /**
33
- * The interface representing the settings for whether the response should be treated as binary or not
34
- *
35
- * @remarks Encoded as binary means the response body will be converted to base64
36
- *
37
- * @breadcrumb Types / BinarySettings
38
- * @public
39
- */
40
- export declare type BinarySettings = BinarySettingsFunction | BinarySettingsContentHeaders;
41
- export declare type __ΩBinarySettingsFunction = any[];
42
- export declare type __ΩBinarySettingsContentHeaders = any[];
43
- export declare type __ΩBinarySettings = any[];
@@ -1,37 +0,0 @@
1
- import { SingleValueHeaders } from '../headers';
2
- /**
3
- * The interface to represents the values of args send when someone calls a function using HTTP Endpoint.
4
- * To be able to receive this event, inside your `project.yml`, instead of `web: true` change to `web: 'raw'`.
5
- *
6
- * {@link https://www.digitalocean.com/community/questions/digitalocean-functions-how-to-differentiate-query-params-from-body-params | Reference}
7
- *
8
- * @public
9
- * @breadcrumb Types / Digital Ocean / DigitalOceanHttpEvent
10
- */
11
- export interface DigitalOceanHttpEvent {
12
- /**
13
- * The HTTP Method of the request
14
- */
15
- __ow_method: string;
16
- /**
17
- * The query porams of the request
18
- */
19
- __ow_query: string;
20
- /**
21
- * The body of the request.
22
- */
23
- __ow_body?: string;
24
- /**
25
- * Indicates if body is base64 string
26
- */
27
- __ow_isBase64Encoded?: boolean;
28
- /**
29
- * The HTTP Headers of the request
30
- */
31
- __ow_headers: SingleValueHeaders;
32
- /**
33
- * The path in the request
34
- */
35
- __ow_path: string;
36
- }
37
- export declare type __ΩDigitalOceanHttpEvent = any[];
@@ -1,22 +0,0 @@
1
- import { SingleValueHeaders } from '../headers';
2
- /**
3
- * The interface to represents the response of Digital Ocean Function.
4
- *
5
- * @public
6
- * @breadcrumb Types / Digital Ocean / DigitalOceanHttpResponse
7
- */
8
- export interface DigitalOceanHttpResponse {
9
- /**
10
- * The HTTP Headers of the response
11
- */
12
- headers?: SingleValueHeaders;
13
- /**
14
- * The body of the response
15
- */
16
- body: unknown;
17
- /**
18
- * The HTTP Status code of the response
19
- */
20
- statusCode: number;
21
- }
22
- export declare type __ΩDigitalOceanHttpResponse = any[];
@@ -1 +0,0 @@
1
- export * from './digital-ocean-http-event';
@@ -1,39 +0,0 @@
1
- /**
2
- * The record that represents the headers that doesn't have multiple values in the value
3
- *
4
- * @example
5
- * ```typescript
6
- * { 'Accept-Encoding': 'gzip, deflate, br' }
7
- * ```
8
- *
9
- * @breadcrumb Types
10
- * @public
11
- */
12
- export declare type SingleValueHeaders = Record<string, string | undefined>;
13
- /**
14
- * The record that represents the headers that have multiple values in the value
15
- *
16
- * @example
17
- * ```typescript
18
- * { 'Accept-Encoding': ['gzip', 'deflate', 'br'] }
19
- * ```
20
- *
21
- * @breadcrumb Types
22
- * @public
23
- */
24
- export declare type MultiValueHeaders = Record<string, string[] | undefined>;
25
- /**
26
- * The record that represents the headers that can both single or multiple values in the value
27
- *
28
- * @example
29
- * ```typescript
30
- * { 'Accept-Encoding': ['gzip', 'deflate', 'br'], 'Host': 'xyz.execute-api.us-east-1.amazonaws.com' }
31
- * ```
32
- *
33
- * @breadcrumb Types
34
- * @public
35
- */
36
- export declare type BothValueHeaders = Record<string, string | string[] | undefined>;
37
- export declare type __ΩSingleValueHeaders = any[];
38
- export declare type __ΩMultiValueHeaders = any[];
39
- export declare type __ΩBothValueHeaders = any[];
@@ -1,10 +0,0 @@
1
- /**
2
- * Removes 'optional' attributes from a type's properties
3
- *
4
- * @breadcrumb Types
5
- * @public
6
- */
7
- export declare type Concrete<Type> = {
8
- [Property in keyof Type]-?: Type[Property];
9
- };
10
- export declare type __ΩConcrete = any[];