@bakery-framework/cli 2.3.0 → 2.4.1

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 (2) hide show
  1. package/package.json +3 -3
  2. package/src/worker.ts +13 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakery-framework/cli",
3
- "version": "2.3.0",
3
+ "version": "2.4.1",
4
4
  "description": "Bakery entry point and process supervision: mode dispatch, dev watcher, cluster.",
5
5
  "keywords": [
6
6
  "bakery",
@@ -39,10 +39,10 @@
39
39
  "bun": ">=1.4.0"
40
40
  },
41
41
  "dependencies": {
42
- "@bakery-framework/core": "^2.3.0"
42
+ "@bakery-framework/core": "^2.4.1"
43
43
  },
44
44
  "peerDependencies": {
45
- "@bakery-framework/orm": "^2.3.0"
45
+ "@bakery-framework/orm": "^2.4.1"
46
46
  },
47
47
  "peerDependenciesMeta": {
48
48
  "@bakery-framework/orm": {
package/src/worker.ts CHANGED
@@ -4,6 +4,8 @@ import {
4
4
  hostStore,
5
5
  } from '@bakery-framework/core/core/bakery'
6
6
  import {
7
+ checkHostMounts,
8
+ checkHosts,
7
9
  initConfig,
8
10
  resolveHostConfig,
9
11
  } from '@bakery-framework/core/core/config'
@@ -15,6 +17,7 @@ import {
15
17
  handleRequest,
16
18
  handleRequestError,
17
19
  processResponse,
20
+ routeOf,
18
21
  serveWebSocket,
19
22
  } from '@bakery-framework/core/router'
20
23
  import { Session } from '@bakery-framework/core/session'
@@ -247,8 +250,11 @@ function settleRequest(
247
250
  try {
248
251
  // Before anything binds: a rate limit that cannot mean anything (a refill
249
252
  // of 0, a prefix without its slash) stops the boot here, naming the field,
250
- // in the catch below.
253
+ // in the catch below. So does a host mount (a path without its slash, a
254
+ // pattern with '*' inside a label) and a `domains` entry that is no domain.
251
255
  checkRateLimits(Bakery.config)
256
+ checkHosts(Bakery.config)
257
+ checkHostMounts(Bakery.config)
252
258
 
253
259
  Bakery.server = Bun.serve({
254
260
  port: PORT,
@@ -266,6 +272,9 @@ try {
266
272
  const hostConfig = resolveHostConfig(hostname)
267
273
 
268
274
  return hostStore.run({ config: hostConfig, hostname, req }, async () => {
275
+ // The limiter keys on the path as sent. An error page is looked up
276
+ // from `routeOf(req).path` instead, the path routing resolved, so a
277
+ // page request on a mounted host finds the subtree's error page.
269
278
  const path = url.pathname
270
279
  req.startNs = Bun.nanoseconds()
271
280
  req.__hostname = hostname
@@ -281,7 +290,7 @@ try {
281
290
  Bakery.sharedPool.incrementCounter(COUNTER_SLOTS.TOTAL_ERRORS, 1)
282
291
  serveLog.SESSION_LOAD_ERR({ error: errorMsg(loadError) })
283
292
  return await processResponse(
284
- await handleRequestError(path, req, loadError),
293
+ await handleRequestError(routeOf(req).path, req, loadError),
285
294
  req,
286
295
  )
287
296
  }
@@ -303,7 +312,7 @@ try {
303
312
 
304
313
  if (isErrorResult(res)) {
305
314
  Bakery.sharedPool.incrementCounter(COUNTER_SLOTS.TOTAL_ERRORS, 1)
306
- return await handleRequestError(path, req, res)
315
+ return await handleRequestError(routeOf(req).path, req, res)
307
316
  }
308
317
  // The app's own error page (see `hasOwnDocument`): sent as written,
309
318
  // and still an error answer for the counter.
@@ -316,7 +325,7 @@ try {
316
325
  async function errorHandler(error) {
317
326
  Bakery.sharedPool.incrementCounter(COUNTER_SLOTS.TOTAL_ERRORS, 1)
318
327
  serveLog.UNHANDLED_ERR({ error: errorMsg(error) })
319
- return await handleRequestError(path, req, error)
328
+ return await handleRequestError(routeOf(req).path, req, error)
320
329
  },
321
330
  )
322
331