@encore.dev/sdk 2.0.0-beta.14 → 2.0.0-beta.16

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 (269) hide show
  1. package/README.md +144 -90
  2. package/app_meta.ts +56 -54
  3. package/config/config.test.ts +47 -13
  4. package/config/config.ts +60 -57
  5. package/config/secrets.ts +47 -50
  6. package/config/value.ts +23 -26
  7. package/cron/mod.test.ts +12 -0
  8. package/cron/mod.ts +37 -22
  9. package/dist/app_meta.d.ts +52 -50
  10. package/dist/app_meta.d.ts.map +1 -1
  11. package/dist/app_meta.js +2 -2
  12. package/dist/app_meta.js.map +1 -1
  13. package/dist/config/config.d.ts +58 -55
  14. package/dist/config/config.d.ts.map +1 -1
  15. package/dist/config/config.js +8 -9
  16. package/dist/config/config.js.map +1 -1
  17. package/dist/config/secrets.d.ts +45 -50
  18. package/dist/config/secrets.d.ts.map +1 -1
  19. package/dist/config/secrets.js +11 -9
  20. package/dist/config/secrets.js.map +1 -1
  21. package/dist/config/value.d.ts +20 -23
  22. package/dist/config/value.d.ts.map +1 -1
  23. package/dist/config/value.js +20 -23
  24. package/dist/config/value.js.map +1 -1
  25. package/dist/cron/mod.d.ts +34 -20
  26. package/dist/cron/mod.d.ts.map +1 -1
  27. package/dist/cron/mod.js +13 -13
  28. package/dist/cron/mod.js.map +1 -1
  29. package/dist/frontends/mod.d.ts +20 -19
  30. package/dist/frontends/mod.d.ts.map +1 -1
  31. package/dist/frontends/mod.js +20 -19
  32. package/dist/frontends/mod.js.map +1 -1
  33. package/dist/gateway/errors.d.ts +28 -30
  34. package/dist/gateway/errors.d.ts.map +1 -1
  35. package/dist/gateway/errors.js +29 -31
  36. package/dist/gateway/errors.js.map +1 -1
  37. package/dist/gateway/match.d.ts +54 -54
  38. package/dist/gateway/match.d.ts.map +1 -1
  39. package/dist/gateway/match.js +56 -56
  40. package/dist/gateway/match.js.map +1 -1
  41. package/dist/gateway/middleware.d.ts +62 -64
  42. package/dist/gateway/middleware.d.ts.map +1 -1
  43. package/dist/gateway/middleware.js +1 -1
  44. package/dist/gateway/middleware.js.map +1 -1
  45. package/dist/gateway/mod.d.ts +64 -67
  46. package/dist/gateway/mod.d.ts.map +1 -1
  47. package/dist/gateway/mod.js +72 -76
  48. package/dist/gateway/mod.js.map +1 -1
  49. package/dist/gateway/request.d.ts +138 -134
  50. package/dist/gateway/request.d.ts.map +1 -1
  51. package/dist/gateway/request.js +117 -108
  52. package/dist/gateway/request.js.map +1 -1
  53. package/dist/gateway/serve.d.ts +29 -34
  54. package/dist/gateway/serve.d.ts.map +1 -1
  55. package/dist/gateway/serve.js +51 -56
  56. package/dist/gateway/serve.js.map +1 -1
  57. package/dist/gateways/mod.d.ts +23 -21
  58. package/dist/gateways/mod.d.ts.map +1 -1
  59. package/dist/gateways/mod.js +25 -23
  60. package/dist/gateways/mod.js.map +1 -1
  61. package/dist/internal/otel/http.d.ts +4 -2
  62. package/dist/internal/otel/http.d.ts.map +1 -1
  63. package/dist/internal/otel/http.js +32 -5
  64. package/dist/internal/otel/http.js.map +1 -1
  65. package/dist/internal/runtime/napi/napi.cjs +6 -5
  66. package/dist/internal/runtime/napi/napi.d.cts +58 -16
  67. package/dist/internal/runtime/shutdown.d.ts +75 -57
  68. package/dist/internal/runtime/shutdown.d.ts.map +1 -1
  69. package/dist/internal/runtime/shutdown.js +88 -84
  70. package/dist/internal/runtime/shutdown.js.map +1 -1
  71. package/dist/log/logger.d.ts +43 -37
  72. package/dist/log/logger.d.ts.map +1 -1
  73. package/dist/log/logger.js +26 -25
  74. package/dist/log/logger.js.map +1 -1
  75. package/dist/metrics/mod.d.ts +133 -114
  76. package/dist/metrics/mod.d.ts.map +1 -1
  77. package/dist/metrics/mod.js +109 -101
  78. package/dist/metrics/mod.js.map +1 -1
  79. package/dist/otel.d.ts +6 -3
  80. package/dist/otel.d.ts.map +1 -1
  81. package/dist/otel.js +6 -3
  82. package/dist/otel.js.map +1 -1
  83. package/dist/pubsub/subscription.d.ts +88 -116
  84. package/dist/pubsub/subscription.d.ts.map +1 -1
  85. package/dist/pubsub/subscription.js +14 -17
  86. package/dist/pubsub/subscription.js.map +1 -1
  87. package/dist/pubsub/topic.d.ts +86 -113
  88. package/dist/pubsub/topic.d.ts.map +1 -1
  89. package/dist/pubsub/topic.js +68 -82
  90. package/dist/pubsub/topic.js.map +1 -1
  91. package/dist/redaction/mod.d.ts +62 -0
  92. package/dist/redaction/mod.d.ts.map +1 -0
  93. package/dist/redaction/mod.js +102 -0
  94. package/dist/redaction/mod.js.map +1 -0
  95. package/dist/reqctx/mod.d.ts +83 -86
  96. package/dist/reqctx/mod.d.ts.map +1 -1
  97. package/dist/reqctx/mod.js +39 -41
  98. package/dist/reqctx/mod.js.map +1 -1
  99. package/dist/services/index.d.ts +76 -75
  100. package/dist/services/index.d.ts.map +1 -1
  101. package/dist/services/index.js +73 -71
  102. package/dist/services/index.js.map +1 -1
  103. package/dist/shutdown/mod.d.ts +26 -25
  104. package/dist/shutdown/mod.d.ts.map +1 -1
  105. package/dist/shutdown/mod.js +26 -25
  106. package/dist/shutdown/mod.js.map +1 -1
  107. package/dist/storage/clickhouse/database.d.ts +113 -115
  108. package/dist/storage/clickhouse/database.d.ts.map +1 -1
  109. package/dist/storage/clickhouse/database.js +65 -79
  110. package/dist/storage/clickhouse/database.js.map +1 -1
  111. package/dist/storage/clickhouse/errors.d.ts +25 -26
  112. package/dist/storage/clickhouse/errors.d.ts.map +1 -1
  113. package/dist/storage/clickhouse/errors.js +15 -17
  114. package/dist/storage/clickhouse/errors.js.map +1 -1
  115. package/dist/storage/clickhouse/mod.d.ts +10 -10
  116. package/dist/storage/clickhouse/mod.js +10 -10
  117. package/dist/storage/objects/bucket.d.ts +230 -203
  118. package/dist/storage/objects/bucket.d.ts.map +1 -1
  119. package/dist/storage/objects/bucket.js +146 -106
  120. package/dist/storage/objects/bucket.js.map +1 -1
  121. package/dist/storage/objects/error.d.ts +4 -4
  122. package/dist/storage/objects/error.js +4 -4
  123. package/dist/storage/objects/mod.d.ts +1 -1
  124. package/dist/storage/objects/mod.d.ts.map +1 -1
  125. package/dist/storage/objects/mod.js.map +1 -1
  126. package/dist/storage/objects/refs.d.ts +2 -5
  127. package/dist/storage/objects/refs.d.ts.map +1 -1
  128. package/dist/storage/objects/refs.js.map +1 -1
  129. package/dist/storage/postgres/database.d.ts +124 -149
  130. package/dist/storage/postgres/database.d.ts.map +1 -1
  131. package/dist/storage/postgres/database.js +98 -135
  132. package/dist/storage/postgres/database.js.map +1 -1
  133. package/dist/storage/postgres/errors.d.ts +42 -48
  134. package/dist/storage/postgres/errors.d.ts.map +1 -1
  135. package/dist/storage/postgres/errors.js +44 -51
  136. package/dist/storage/postgres/errors.js.map +1 -1
  137. package/dist/storage/postgres/interval.d.ts +19 -19
  138. package/dist/storage/postgres/interval.d.ts.map +1 -1
  139. package/dist/storage/postgres/interval.js +21 -21
  140. package/dist/storage/postgres/interval.js.map +1 -1
  141. package/dist/storage/redis/bitfield.d.ts +48 -23
  142. package/dist/storage/redis/bitfield.d.ts.map +1 -1
  143. package/dist/storage/redis/bitfield.js +38 -19
  144. package/dist/storage/redis/bitfield.js.map +1 -1
  145. package/dist/storage/redis/command.d.ts +16 -12
  146. package/dist/storage/redis/command.d.ts.map +1 -1
  147. package/dist/storage/redis/command.js +16 -12
  148. package/dist/storage/redis/command.js.map +1 -1
  149. package/dist/storage/redis/commands.d.ts +99 -100
  150. package/dist/storage/redis/commands.d.ts.map +1 -1
  151. package/dist/storage/redis/commands.js +84 -85
  152. package/dist/storage/redis/commands.js.map +1 -1
  153. package/dist/storage/redis/database.d.ts +138 -122
  154. package/dist/storage/redis/database.d.ts.map +1 -1
  155. package/dist/storage/redis/database.js +120 -101
  156. package/dist/storage/redis/database.js.map +1 -1
  157. package/dist/storage/redis/mod.d.ts +52 -48
  158. package/dist/storage/redis/mod.d.ts.map +1 -1
  159. package/dist/storage/redis/mod.js +52 -48
  160. package/dist/storage/redis/mod.js.map +1 -1
  161. package/dist/storage/redis/options.d.ts +26 -24
  162. package/dist/storage/redis/options.d.ts.map +1 -1
  163. package/dist/storage/redis/options.js.map +1 -1
  164. package/dist/storage/redis/pubsub.d.ts +16 -16
  165. package/dist/storage/redis/pubsub.d.ts.map +1 -1
  166. package/dist/storage/redis/pubsub.js +14 -14
  167. package/dist/storage/redis/pubsub.js.map +1 -1
  168. package/dist/storage/redis/reply.d.ts +80 -72
  169. package/dist/storage/redis/reply.d.ts.map +1 -1
  170. package/dist/storage/redis/reply.js +53 -46
  171. package/dist/storage/redis/reply.js.map +1 -1
  172. package/dist/storage/redis/scan.d.ts +4 -4
  173. package/dist/storage/redis/scan.d.ts.map +1 -1
  174. package/dist/storage/redis/scan.js +6 -6
  175. package/dist/storage/redis/scan.js.map +1 -1
  176. package/dist/storage/redis/script.d.ts +28 -21
  177. package/dist/storage/redis/script.d.ts.map +1 -1
  178. package/dist/storage/redis/script.js +29 -22
  179. package/dist/storage/redis/script.js.map +1 -1
  180. package/dist/storage/redis/target.d.ts +17 -1
  181. package/dist/storage/redis/target.d.ts.map +1 -1
  182. package/dist/storage/redis/target.js +30 -1
  183. package/dist/storage/redis/target.js.map +1 -1
  184. package/dist/storage/redis/wire.d.ts +6 -6
  185. package/dist/storage/redis/wire.d.ts.map +1 -1
  186. package/dist/storage/redis/wire.js +6 -6
  187. package/dist/storage/redis/wire.js.map +1 -1
  188. package/dist/testing/mod.d.ts +83 -88
  189. package/dist/testing/mod.d.ts.map +1 -1
  190. package/dist/testing/mod.js +75 -81
  191. package/dist/testing/mod.js.map +1 -1
  192. package/dist/testing/playwright.d.ts +28 -32
  193. package/dist/testing/playwright.d.ts.map +1 -1
  194. package/dist/testing/playwright.js +22 -27
  195. package/dist/testing/playwright.js.map +1 -1
  196. package/dist/testing/puppeteer.d.ts +11 -12
  197. package/dist/testing/puppeteer.d.ts.map +1 -1
  198. package/dist/testing/puppeteer.js +17 -18
  199. package/dist/testing/puppeteer.js.map +1 -1
  200. package/dist/testing/system.d.ts +72 -90
  201. package/dist/testing/system.d.ts.map +1 -1
  202. package/dist/testing/system.js +90 -107
  203. package/dist/testing/system.js.map +1 -1
  204. package/dist/tracing/http.d.ts +2 -1
  205. package/dist/tracing/http.d.ts.map +1 -1
  206. package/dist/tracing/http.js +2 -1
  207. package/dist/tracing/http.js.map +1 -1
  208. package/dist/tracing/node.d.ts.map +1 -1
  209. package/dist/tracing/node.js +1 -1
  210. package/dist/tracing/node.js.map +1 -1
  211. package/dist/tsconfig.build.tsbuildinfo +1 -1
  212. package/frontends/mod.test.ts +6 -2
  213. package/frontends/mod.ts +20 -19
  214. package/gateway/errors.ts +30 -32
  215. package/gateway/match.ts +61 -57
  216. package/gateway/middleware.ts +62 -64
  217. package/gateway/mod.ts +73 -76
  218. package/gateway/request.ts +143 -140
  219. package/gateway/serve.ts +58 -63
  220. package/gateways/mod.ts +25 -23
  221. package/internal/otel/http.test.ts +50 -0
  222. package/internal/otel/http.ts +40 -5
  223. package/internal/runtime/napi/napi.cjs +6 -5
  224. package/internal/runtime/napi/napi.d.cts +58 -16
  225. package/internal/runtime/shutdown.ts +113 -101
  226. package/log/logger.test.ts +8 -0
  227. package/log/logger.ts +48 -45
  228. package/metrics/mod.ts +138 -122
  229. package/otel.ts +6 -3
  230. package/package.json +6 -1
  231. package/pubsub/subscription.ts +93 -123
  232. package/pubsub/topic.ts +96 -130
  233. package/redaction/bridge.test.ts +99 -0
  234. package/redaction/mod.test.ts +188 -0
  235. package/redaction/mod.ts +226 -0
  236. package/reqctx/mod.ts +83 -86
  237. package/services/index.ts +78 -78
  238. package/shutdown/mod.ts +26 -25
  239. package/storage/clickhouse/database.ts +115 -129
  240. package/storage/clickhouse/errors.ts +27 -29
  241. package/storage/clickhouse/mod.ts +10 -10
  242. package/storage/objects/bucket.test.ts +168 -16
  243. package/storage/objects/bucket.ts +336 -247
  244. package/storage/objects/error.ts +4 -4
  245. package/storage/objects/mod.ts +1 -0
  246. package/storage/objects/refs.ts +2 -5
  247. package/storage/postgres/database.ts +131 -164
  248. package/storage/postgres/errors.ts +45 -52
  249. package/storage/postgres/interval.ts +21 -21
  250. package/storage/redis/bitfield.ts +51 -26
  251. package/storage/redis/command.ts +16 -12
  252. package/storage/redis/commands.ts +99 -100
  253. package/storage/redis/database.ts +145 -123
  254. package/storage/redis/mod.ts +52 -48
  255. package/storage/redis/options.ts +26 -24
  256. package/storage/redis/pubsub.ts +14 -14
  257. package/storage/redis/redis.test.ts +17 -2
  258. package/storage/redis/reply.ts +85 -77
  259. package/storage/redis/scan.ts +6 -6
  260. package/storage/redis/script.ts +29 -22
  261. package/storage/redis/target.ts +34 -1
  262. package/storage/redis/wire.ts +8 -8
  263. package/testing/mod.ts +99 -105
  264. package/testing/playwright.ts +32 -37
  265. package/testing/puppeteer.ts +22 -23
  266. package/testing/system.ts +117 -133
  267. package/tracing/http.ts +2 -1
  268. package/tracing/native.test.ts +158 -8
  269. package/tracing/node.ts +1 -0
@@ -1,12 +1,12 @@
1
1
  /**
2
- * Code in an application's gateway: Middleware that authenticates,
3
- * authorizes, limits, logs or meters the public requests the gateway serves,
4
- * before they reach a service and after they return.
2
+ * Gateway middleware for authenticating, authorizing, rate-limiting, logging,
3
+ * or metering public requests before they reach a service and after responses
4
+ * return.
5
5
  *
6
- * A gateway with code is a service that hosts it, declared by a `gateway`
7
- * section in the service's `encore.service.json`. The section takes what
8
- * `encore.gateway.json` takes but the name: the gateway is named after its
9
- * service.
6
+ * A gateway with custom middleware is hosted by a service that includes a
7
+ * `gateway` section in its `encore.service.json`. The section accepts the same
8
+ * options as `encore.gateway.json` except `name`, since the gateway takes the
9
+ * name of its hosting service:
10
10
  *
11
11
  * ```json
12
12
  * {
@@ -17,9 +17,9 @@
17
17
  * }
18
18
  * ```
19
19
  *
20
- * The service's program serves the gateway with its Middleware, and nothing
21
- * else. As any service, it has its own secrets, caches, databases, topics
22
- * and configs, and may call other services.
20
+ * The service's entry point serves the gateway with its middleware and nothing
21
+ * else. Like any Encore service, it can declare its own secrets, caches,
22
+ * databases, Pub/Sub topics, and configs, and call other services.
23
23
  *
24
24
  * ```typescript
25
25
  * import * as gateway from "@encore.dev/sdk/gateway";
@@ -43,64 +43,62 @@
43
43
  *
44
44
  * ## Hooks
45
45
  *
46
- * A {@link Middleware} is called at the hooks it has, and no others:
46
+ * A {@link Middleware} is invoked only for the hooks it defines:
47
47
  *
48
- * - `onRequest`, before the request is forwarded: it lets the request
49
- * through, edited, or answers it itself;
50
- * - `onRequestBody` and `onResponseBody`, with each chunk of the bodies, to
51
- * observe;
52
- * - `onResponse`, before the response is written, to edit its headers;
53
- * - `onComplete`, once the request is done, off its path: where to log,
54
- * meter or bill it.
48
+ * - `onRequest`: runs before the request is forwarded; can allow it through
49
+ * (optionally modified) or answer it directly.
50
+ * - `onRequestBody` and `onResponseBody`: observe each chunk of the request or
51
+ * response body as it streams.
52
+ * - `onResponse`: runs before the response is sent to the client; can edit
53
+ * response headers.
54
+ * - `onComplete`: runs asynchronously after the request finishes; ideal for
55
+ * logging, metrics, or billing.
55
56
  *
56
- * A Middleware is called only for the requests its `match` matches. Encore
57
- * checks it before a request reaches JavaScript, so a request no Middleware
58
- * is interested in costs the program nothing, and one whose only Middleware
59
- * takes `onComplete` costs nothing on its way. A hook may read any of the
60
- * request's headers, query parameters and cookies; each reaches JavaScript
61
- * only as the hook reads it.
57
+ * Encore evaluates each middleware's `match` condition before dispatching to
58
+ * JavaScript, so unmatched requests incur no JS overhead, and a middleware
59
+ * that only defines `onComplete` adds no latency to the request path. Headers,
60
+ * query parameters, and cookies are passed into JavaScript lazily when read.
62
61
  *
63
- * Middleware see only public requests the gateway routes: calls between
64
- * services, Pub/Sub pushes and requests for paths the gateway does not
65
- * expose are Encore's alone, and so are CORS preflights, but for a gateway
66
- * whose CORS is off (`"cors": false`), which routes them as any request.
62
+ * Middleware only sees public requests routed by the gateway. Service-to-service
63
+ * calls, Pub/Sub pushes, and unexposed paths are handled internally by Encore,
64
+ * as are CORS preflight requests (unless CORS is disabled via `"cors": false`,
65
+ * in which case preflights are routed like any other request).
67
66
  *
68
67
  * ## Answering a request
69
68
  *
70
- * `onRequest` returns nothing to let the request through, or a
71
- * {@link Rejection} to answer it, returned or thrown: {@link reject}
72
- * answers with an Encore error, as a service does, and {@link respond} with
73
- * any response. Any other error, or a timeout, fails the hook, and the
74
- * Middleware's `onError` says what happens to the request: `"failClosed"`
75
- * refuses it, `"failOpen"` lets it through.
69
+ * `onRequest` returns nothing (`void` / `undefined`) to allow the request
70
+ * through, or returns or throws a {@link Rejection} to answer it immediately.
71
+ * Use {@link reject} to respond with a standard Encore error, or {@link respond}
72
+ * for any custom HTTP response (such as a redirect). Any other thrown error or
73
+ * timeout fails the hook, and the middleware's `onError` policy decides what
74
+ * happens next: `"failClosed"` rejects the request, while `"failOpen"` lets it
75
+ * through.
76
76
  *
77
77
  * ## Request Context
78
78
  *
79
- * `onRequest` sets the request's Request Context fields
80
- * (`@encore.dev/sdk/reqctx`) with {@link Request.set}: the Middleware after
81
- * it, the service the request reaches and the services that one calls with
82
- * the request's context read them, as `currentUser.get()`. No client can set
83
- * one. Every hook runs in its request's context, so it reads them with
84
- * `field.get()` too, or {@link Request.get}: `onComplete` as the request was
85
- * forwarded.
79
+ * `onRequest` can populate Request Context fields (`@encore.dev/sdk/reqctx`)
80
+ * with {@link Request.set}. Subsequent middleware, the target service, and
81
+ * downstream services called with that request context can read them via
82
+ * `field.get()`. Clients cannot forge Request Context fields. Every hook runs
83
+ * inside its request's context and can read fields with either `field.get()`
84
+ * or {@link Request.get} (in `onComplete`, reflecting the forwarded state).
86
85
  *
87
86
  * ## Concurrency
88
87
  *
89
- * Hooks run on the event loop. One Middleware's hooks for one request are
90
- * called one at a time, in the order of the request's life; hooks for
91
- * different requests run concurrently. A hook that blocks the event loop
92
- * delays every request. `onRequest` and `onResponse` have a timeout
93
- * (`timeoutMs`); {@link Request.signal} aborts when it passes, for the work
94
- * the hook awaits to stop too.
88
+ * Hooks run on the JavaScript event loop. For a single request, a middleware's
89
+ * hooks execute sequentially in lifecycle order; hooks for different requests
90
+ * run concurrently. Avoid blocking the event loop, as doing so stalls other
91
+ * requests. `onRequest` and `onResponse` enforce `timeoutMs` and abort
92
+ * {@link Request.signal} on expiry so awaited work can cancel cleanly.
95
93
  *
96
- * Should JavaScript fall far behind the requests, the gateway refuses the
97
- * hooks it cannot queue, as failures `onError` handles, rather than holding
98
- * requests without limit.
94
+ * If JavaScript falls too far behind incoming traffic, the gateway rejects
95
+ * hooks it cannot queue (handled according to `onError`) rather than buffering
96
+ * requests unboundedly.
99
97
  *
100
- * While a hook runs, the request's trace and Request Context are the
101
- * current ones: spans it starts are part of the trace, `field.get()` reads
102
- * the request's fields, and calls it makes to services carry both, with the
103
- * fields `onRequest` has set so far.
98
+ * While a hook executes, the request's trace context and Request Context are
99
+ * active: newly created spans attach to the trace, `field.get()` reads the
100
+ * request's fields, and outgoing service calls propagate both (including any
101
+ * fields set so far in `onRequest`).
104
102
  *
105
103
  * @module
106
104
  */
@@ -112,19 +110,18 @@ export { Hook, Request, Response } from './request.js';
112
110
  export type { AttributeValue, Completed, Hooks } from './request.js';
113
111
  export type { Decision, ErrorPolicy, Middleware } from './middleware.js';
114
112
  /**
115
- * Serves the gateway this service hosts, with `middleware` in order, until
116
- * Encore shuts the process down. Call it once, at the end of the program's
117
- * entry point.
118
- *
119
- * While the gateway drains on the first SIGTERM, the hooks keep running; a
120
- * second SIGTERM hurries the shutdown. The promise resolves once the gateway
121
- * has stopped and every hook it queued has been called; Encore exits the
122
- * process once its shutdown completes.
123
- *
124
- * It rejects with a {@link GatewayError} when the process is not a gateway
125
- * program Encore runs, as under `encore run`; a Middleware is invalid, such
126
- * as a name repeated, or a `match` the gateway refuses, such as an invalid
127
- * regular expression; or the gateway is already served.
113
+ * Starts serving the gateway hosted by this service with the given `middleware`
114
+ * in order, running until Encore shuts the process down. Call this once at the
115
+ * end of the service's entry point.
116
+ *
117
+ * On the first `SIGTERM`, the gateway stops accepting new connections while
118
+ * draining in-flight hooks; a second `SIGTERM` accelerates shutdown. The
119
+ * returned promise resolves after the gateway stops and all queued hooks have
120
+ * finished, at which point Encore exits the process.
121
+ *
122
+ * Rejects with {@link GatewayError} if the process is not running as an Encore
123
+ * gateway, if any middleware definition or matcher is invalid (such as a
124
+ * duplicate name or invalid regex), or if `serve` has already been called.
128
125
  */
129
126
  export declare function serve(...middleware: Middleware[]): Promise<void>;
130
127
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../gateway/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyGG;AAOH,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAS7C,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,YAAY,EAAC,IAAI,EAAE,OAAO,EAAC,MAAM,SAAS,CAAC;AAC3C,OAAO,EACL,OAAO,EACP,YAAY,EACZ,SAAS,EACT,UAAU,EACV,MAAM,EACN,OAAO,EACP,KAAK,OAAO,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAC;AAClD,YAAY,EAAC,cAAc,EAAE,SAAS,EAAE,KAAK,EAAC,MAAM,WAAW,CAAC;AAChE,YAAY,EAAC,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AAkBpE;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,KAAK,CAAC,GAAG,UAAU,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA2CtE"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../gateway/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuGG;AAOH,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAS7C,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,YAAY,EAAC,IAAI,EAAE,OAAO,EAAC,MAAM,SAAS,CAAC;AAC3C,OAAO,EACL,OAAO,EACP,YAAY,EACZ,SAAS,EACT,UAAU,EACV,MAAM,EACN,OAAO,EACP,KAAK,OAAO,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAC;AAClD,YAAY,EAAC,cAAc,EAAE,SAAS,EAAE,KAAK,EAAC,MAAM,WAAW,CAAC;AAChE,YAAY,EAAC,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AAiBpE;;;;;;;;;;;;;GAaG;AACH,wBAAsB,KAAK,CAAC,GAAG,UAAU,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA4CtE"}
@@ -1,12 +1,12 @@
1
1
  /**
2
- * Code in an application's gateway: Middleware that authenticates,
3
- * authorizes, limits, logs or meters the public requests the gateway serves,
4
- * before they reach a service and after they return.
2
+ * Gateway middleware for authenticating, authorizing, rate-limiting, logging,
3
+ * or metering public requests before they reach a service and after responses
4
+ * return.
5
5
  *
6
- * A gateway with code is a service that hosts it, declared by a `gateway`
7
- * section in the service's `encore.service.json`. The section takes what
8
- * `encore.gateway.json` takes but the name: the gateway is named after its
9
- * service.
6
+ * A gateway with custom middleware is hosted by a service that includes a
7
+ * `gateway` section in its `encore.service.json`. The section accepts the same
8
+ * options as `encore.gateway.json` except `name`, since the gateway takes the
9
+ * name of its hosting service:
10
10
  *
11
11
  * ```json
12
12
  * {
@@ -17,9 +17,9 @@
17
17
  * }
18
18
  * ```
19
19
  *
20
- * The service's program serves the gateway with its Middleware, and nothing
21
- * else. As any service, it has its own secrets, caches, databases, topics
22
- * and configs, and may call other services.
20
+ * The service's entry point serves the gateway with its middleware and nothing
21
+ * else. Like any Encore service, it can declare its own secrets, caches,
22
+ * databases, Pub/Sub topics, and configs, and call other services.
23
23
  *
24
24
  * ```typescript
25
25
  * import * as gateway from "@encore.dev/sdk/gateway";
@@ -43,64 +43,62 @@
43
43
  *
44
44
  * ## Hooks
45
45
  *
46
- * A {@link Middleware} is called at the hooks it has, and no others:
46
+ * A {@link Middleware} is invoked only for the hooks it defines:
47
47
  *
48
- * - `onRequest`, before the request is forwarded: it lets the request
49
- * through, edited, or answers it itself;
50
- * - `onRequestBody` and `onResponseBody`, with each chunk of the bodies, to
51
- * observe;
52
- * - `onResponse`, before the response is written, to edit its headers;
53
- * - `onComplete`, once the request is done, off its path: where to log,
54
- * meter or bill it.
48
+ * - `onRequest`: runs before the request is forwarded; can allow it through
49
+ * (optionally modified) or answer it directly.
50
+ * - `onRequestBody` and `onResponseBody`: observe each chunk of the request or
51
+ * response body as it streams.
52
+ * - `onResponse`: runs before the response is sent to the client; can edit
53
+ * response headers.
54
+ * - `onComplete`: runs asynchronously after the request finishes; ideal for
55
+ * logging, metrics, or billing.
55
56
  *
56
- * A Middleware is called only for the requests its `match` matches. Encore
57
- * checks it before a request reaches JavaScript, so a request no Middleware
58
- * is interested in costs the program nothing, and one whose only Middleware
59
- * takes `onComplete` costs nothing on its way. A hook may read any of the
60
- * request's headers, query parameters and cookies; each reaches JavaScript
61
- * only as the hook reads it.
57
+ * Encore evaluates each middleware's `match` condition before dispatching to
58
+ * JavaScript, so unmatched requests incur no JS overhead, and a middleware
59
+ * that only defines `onComplete` adds no latency to the request path. Headers,
60
+ * query parameters, and cookies are passed into JavaScript lazily when read.
62
61
  *
63
- * Middleware see only public requests the gateway routes: calls between
64
- * services, Pub/Sub pushes and requests for paths the gateway does not
65
- * expose are Encore's alone, and so are CORS preflights, but for a gateway
66
- * whose CORS is off (`"cors": false`), which routes them as any request.
62
+ * Middleware only sees public requests routed by the gateway. Service-to-service
63
+ * calls, Pub/Sub pushes, and unexposed paths are handled internally by Encore,
64
+ * as are CORS preflight requests (unless CORS is disabled via `"cors": false`,
65
+ * in which case preflights are routed like any other request).
67
66
  *
68
67
  * ## Answering a request
69
68
  *
70
- * `onRequest` returns nothing to let the request through, or a
71
- * {@link Rejection} to answer it, returned or thrown: {@link reject}
72
- * answers with an Encore error, as a service does, and {@link respond} with
73
- * any response. Any other error, or a timeout, fails the hook, and the
74
- * Middleware's `onError` says what happens to the request: `"failClosed"`
75
- * refuses it, `"failOpen"` lets it through.
69
+ * `onRequest` returns nothing (`void` / `undefined`) to allow the request
70
+ * through, or returns or throws a {@link Rejection} to answer it immediately.
71
+ * Use {@link reject} to respond with a standard Encore error, or {@link respond}
72
+ * for any custom HTTP response (such as a redirect). Any other thrown error or
73
+ * timeout fails the hook, and the middleware's `onError` policy decides what
74
+ * happens next: `"failClosed"` rejects the request, while `"failOpen"` lets it
75
+ * through.
76
76
  *
77
77
  * ## Request Context
78
78
  *
79
- * `onRequest` sets the request's Request Context fields
80
- * (`@encore.dev/sdk/reqctx`) with {@link Request.set}: the Middleware after
81
- * it, the service the request reaches and the services that one calls with
82
- * the request's context read them, as `currentUser.get()`. No client can set
83
- * one. Every hook runs in its request's context, so it reads them with
84
- * `field.get()` too, or {@link Request.get}: `onComplete` as the request was
85
- * forwarded.
79
+ * `onRequest` can populate Request Context fields (`@encore.dev/sdk/reqctx`)
80
+ * with {@link Request.set}. Subsequent middleware, the target service, and
81
+ * downstream services called with that request context can read them via
82
+ * `field.get()`. Clients cannot forge Request Context fields. Every hook runs
83
+ * inside its request's context and can read fields with either `field.get()`
84
+ * or {@link Request.get} (in `onComplete`, reflecting the forwarded state).
86
85
  *
87
86
  * ## Concurrency
88
87
  *
89
- * Hooks run on the event loop. One Middleware's hooks for one request are
90
- * called one at a time, in the order of the request's life; hooks for
91
- * different requests run concurrently. A hook that blocks the event loop
92
- * delays every request. `onRequest` and `onResponse` have a timeout
93
- * (`timeoutMs`); {@link Request.signal} aborts when it passes, for the work
94
- * the hook awaits to stop too.
88
+ * Hooks run on the JavaScript event loop. For a single request, a middleware's
89
+ * hooks execute sequentially in lifecycle order; hooks for different requests
90
+ * run concurrently. Avoid blocking the event loop, as doing so stalls other
91
+ * requests. `onRequest` and `onResponse` enforce `timeoutMs` and abort
92
+ * {@link Request.signal} on expiry so awaited work can cancel cleanly.
95
93
  *
96
- * Should JavaScript fall far behind the requests, the gateway refuses the
97
- * hooks it cannot queue, as failures `onError` handles, rather than holding
98
- * requests without limit.
94
+ * If JavaScript falls too far behind incoming traffic, the gateway rejects
95
+ * hooks it cannot queue (handled according to `onError`) rather than buffering
96
+ * requests unboundedly.
99
97
  *
100
- * While a hook runs, the request's trace and Request Context are the
101
- * current ones: spans it starts are part of the trace, `field.get()` reads
102
- * the request's fields, and calls it makes to services carry both, with the
103
- * fields `onRequest` has set so far.
98
+ * While a hook executes, the request's trace context and Request Context are
99
+ * active: newly created spans attach to the trace, `field.get()` reads the
100
+ * request's fields, and outgoing service calls propagate both (including any
101
+ * fields set so far in `onRequest`).
104
102
  *
105
103
  * @module
106
104
  */
@@ -114,37 +112,35 @@ export * as match from './match.js';
114
112
  export { ErrCode, GatewayError, Rejection, httpStatus, reject, respond, } from './errors.js';
115
113
  export { Hook, Request, Response } from './request.js';
116
114
  let served = false;
117
- /** The runtime's gateway functions, of its gateway variant, which a gateway
118
- * program loads. */
115
+ /** Returns the native gateway bindings loaded by the gateway runtime variant. */
119
116
  function native() {
120
117
  const n = napi;
121
118
  if (typeof n.gatewayServe !== 'function') {
122
- throw new GatewayError('this process does not run the gateway variant of the Encore runtime: Encore runs a ' +
123
- 'service with a "gateway" section in its encore.service.json on it, telling it where ' +
124
- 'to serve the gateway in ENCORE_GATEWAY_LISTEN');
119
+ throw new GatewayError('this process is not running the gateway variant of the Encore runtime: ' +
120
+ 'add a "gateway" section to encore.service.json so Encore starts it as a gateway ' +
121
+ '(with ENCORE_GATEWAY_LISTEN set)');
125
122
  }
126
123
  return n;
127
124
  }
128
125
  /**
129
- * Serves the gateway this service hosts, with `middleware` in order, until
130
- * Encore shuts the process down. Call it once, at the end of the program's
131
- * entry point.
132
- *
133
- * While the gateway drains on the first SIGTERM, the hooks keep running; a
134
- * second SIGTERM hurries the shutdown. The promise resolves once the gateway
135
- * has stopped and every hook it queued has been called; Encore exits the
136
- * process once its shutdown completes.
137
- *
138
- * It rejects with a {@link GatewayError} when the process is not a gateway
139
- * program Encore runs, as under `encore run`; a Middleware is invalid, such
140
- * as a name repeated, or a `match` the gateway refuses, such as an invalid
141
- * regular expression; or the gateway is already served.
126
+ * Starts serving the gateway hosted by this service with the given `middleware`
127
+ * in order, running until Encore shuts the process down. Call this once at the
128
+ * end of the service's entry point.
129
+ *
130
+ * On the first `SIGTERM`, the gateway stops accepting new connections while
131
+ * draining in-flight hooks; a second `SIGTERM` accelerates shutdown. The
132
+ * returned promise resolves after the gateway stops and all queued hooks have
133
+ * finished, at which point Encore exits the process.
134
+ *
135
+ * Rejects with {@link GatewayError} if the process is not running as an Encore
136
+ * gateway, if any middleware definition or matcher is invalid (such as a
137
+ * duplicate name or invalid regex), or if `serve` has already been called.
142
138
  */
143
139
  export async function serve(...middleware) {
144
140
  const checked = check(middleware);
145
141
  const gw = native();
146
142
  if (served)
147
- throw new GatewayError('the gateway is served once per process');
143
+ throw new GatewayError('gateway.serve can only be called once per process');
148
144
  served = true;
149
145
  const mws = new Map();
150
146
  let listen;
@@ -164,7 +160,7 @@ export async function serve(...middleware) {
164
160
  dispatcher.deliver(events);
165
161
  }
166
162
  catch (err) {
167
- log.error(err, "cannot hand on the gateway's middleware events");
163
+ log.error(err, 'failed to dispatch gateway middleware events');
168
164
  }
169
165
  });
170
166
  }
@@ -176,13 +172,13 @@ export async function serve(...middleware) {
176
172
  catch (err) {
177
173
  throw new GatewayError(err instanceof Error ? err.message : String(err));
178
174
  }
179
- log.debug(`serving the gateway on ${listen}`);
175
+ log.debug(`serving gateway on ${listen}`);
180
176
  forceCleanupOnRepeat('SIGTERM');
181
177
  await dispatcher.closed;
182
178
  await dispatcher.drained();
183
179
  const dropped = gw.gatewayDropped();
184
180
  if (dropped > 0) {
185
- log.warn(`dropped ${dropped} body chunks and completions the middleware did not keep up with`);
181
+ log.warn(`dropped ${dropped} body chunks and completion events because middleware could not keep up`);
186
182
  }
187
183
  }
188
184
  //# sourceMappingURL=mod.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.js","sourceRoot":"","sources":["../../gateway/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyGG;AAEH,OAAO,EAAC,EAAE,EAAC,MAAM,yBAAyB,CAAC;AAC3C,OAAO,KAAK,IAAI,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAC,oBAAoB,EAAE,IAAI,EAAC,MAAM,8BAA8B,CAAC;AACxE,OAAO,GAAG,MAAM,QAAQ,CAAC;AACzB,OAAO,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AAEtC,OAAO,EACL,KAAK,EACL,UAAU,EACV,IAAI,GAGL,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAEjC,OAAO,EACL,OAAO,EACP,YAAY,EACZ,SAAS,EACT,UAAU,EACV,MAAM,EACN,OAAO,GAER,MAAM,UAAU,CAAC;AAClB,OAAO,EAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAC;AAIlD,IAAI,MAAM,GAAG,KAAK,CAAC;AAEnB;oBACoB;AACpB,SAAS,MAAM;IACb,MAAM,CAAC,GAAG,IAAyC,CAAC;IACpD,IAAI,OAAO,CAAC,CAAC,YAAY,KAAK,UAAU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