@bakery-framework/plugin-vue 2.0.0-rc.3 → 2.0.0-rc.5

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 +2 -2
  2. package/src/utils.ts +27 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakery-framework/plugin-vue",
3
- "version": "2.0.0-rc.3",
3
+ "version": "2.0.0-rc.5",
4
4
  "description": "Bakery vue plugin.",
5
5
  "keywords": [
6
6
  "bakery",
@@ -43,7 +43,7 @@
43
43
  "vue": "^3.5.38"
44
44
  },
45
45
  "dependencies": {
46
- "@bakery-framework/core": "^2.0.0-rc.3"
46
+ "@bakery-framework/core": "^2.0.0-rc.5"
47
47
  },
48
48
  "engines": {
49
49
  "bun": ">=1.4.0"
package/src/utils.ts CHANGED
@@ -593,6 +593,33 @@ export async function getServerResponse(options: ServerResponseOptions) {
593
593
  `Server script error in ${id}: ${err?.message || err} at ${req.url}`,
594
594
  'error',
595
595
  )
596
+
597
+ // **A block that declares a guard fails closed.**
598
+ //
599
+ // The generated wrapper runs the block's top-level statements and *then*
600
+ // calls `middleware`, so a throw anywhere above skips the guard
601
+ // completely. Returning `{}` here then served the route: a `/admin/*`
602
+ // page answering 200 to an anonymous caller because a query threw. Not
603
+ // hypothetical, and not only the obvious causes: the block only has to
604
+ // throw, so a database being down, a null deref or a typo all reach it.
605
+ //
606
+ // Convention 2 names this shape exactly: a guard "returns the rejection,
607
+ // not `null`, on any indeterminate state". A guard that ceased to exist
608
+ // is the most indeterminate state there is.
609
+ //
610
+ // Only when a guard is declared. A data-only block that throws still
611
+ // renders the page with no data, which is the documented behavior and is
612
+ // a visible failure rather than a silent one: the page is obviously
613
+ // broken, and nothing was protecting it.
614
+ //
615
+ // The declaration is read from the source, not from the result, because
616
+ // there is no result: the module threw before its exports existed. That
617
+ // is the same static list `compileServerBlock` already builds to decide
618
+ // which exports are callable as actions.
619
+ if (collectExportedFunctionNames(script).includes('middleware')) {
620
+ return new Response('Internal Server Error', { status: 500 })
621
+ }
622
+
596
623
  return {}
597
624
  } finally {
598
625
  clearTimeout(timer)