@webjsdev/cli 0.10.34 → 0.10.35

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webjsdev/cli",
3
- "version": "0.10.34",
3
+ "version": "0.10.35",
4
4
  "type": "module",
5
5
  "description": "webjs CLI - dev, start, create, db",
6
6
  "bin": {
@@ -351,7 +351,11 @@ app/ ROUTING ONLY: thin route adapters (import from modules/
351
351
  layout.ts root layout, wraps every page
352
352
  error.ts error boundary (render failures → user-friendly)
353
353
  loading.ts Suspense fallback for sibling page
354
- not-found.ts custom 404 page
354
+ not-found.ts custom 404 page (nearest wins on notFound())
355
+ forbidden.ts 403 page (nearest wins on forbidden())
356
+ unauthorized.ts 401 page (nearest wins on unauthorized())
357
+ global-error.ts root-only app-wide error boundary (owns its <html>)
358
+ global-not-found.ts root-only 404 for an unmatched-anywhere URL
355
359
  middleware.ts global request middleware
356
360
  [slug]/page.ts dynamic route segment
357
361
  [...rest]/page.ts catch-all
@@ -392,6 +396,8 @@ test/<feature>/ feature-scoped tests, one folder per concern
392
396
  e2e/<name>.test.ts end-to-end test (full app boot, opt in via WEBJS_E2E=1)
393
397
  smoke/<name>.test.ts fast post-deploy sanity check
394
398
  middleware.ts root middleware (optional, outermost)
399
+ instrumentation.ts optional boot hook: register() runs once; wire APM via setOnError
400
+ instrumentation-client.ts optional client boot hook, runs first before app modules
395
401
  ```
396
402
 
397
403
  ### The gallery (reference content, prune it)
@@ -495,11 +495,17 @@ Routes live under `app/` and follow NextJs App Router conventions:
495
495
  - `app/**/layout.ts`: Layout wrapper
496
496
  - `app/**/error.ts`: Error boundary
497
497
  - `app/**/middleware.ts`: Per-segment middleware
498
+ - `instrumentation.ts` (app root): optional boot hook. `register()` runs once at startup; call `setOnError()` (from `@webjsdev/server`) inside it to wire an APM error sink (composes with `createRequestHandler({ onError })`).
499
+ - `instrumentation-client.ts` (app root): optional client boot hook, imported first in the browser boot so it runs before app modules.
498
500
 
499
501
  **Special route files:**
500
502
  - `app/**/error.ts`: Error boundary. Default export receives `{ error }`, returns `TemplateResult`. Nearest boundary catches errors from pages below it.
501
503
  - `app/**/loading.ts`: Loading state. Auto-wraps the sibling page in a `Suspense` boundary. Shown while async page functions resolve.
502
504
  - `app/**/not-found.ts`: 404 page. Nearest wins when `notFound()` is thrown.
505
+ - `app/**/forbidden.ts`: 403 page. Nearest wins when `forbidden()` is thrown (an authenticated user who lacks permission).
506
+ - `app/**/unauthorized.ts`: 401 page. Nearest wins when `unauthorized()` is thrown (a request that is not authenticated).
507
+ - `app/global-error.ts` (root only): app-wide error boundary, tried after nested `error.ts` boundaries. Renders its OWN `<!doctype><html><body>` document.
508
+ - `app/global-not-found.ts` (root only): 404 for a URL that matches nothing anywhere.
503
509
  - `app/sitemap.ts`: Dynamic sitemap at `/sitemap.xml`. Export a function returning an array of `{ url, lastModified }`.
504
510
  - `app/robots.ts`: Dynamic robots.txt at `/robots.txt`.
505
511
  - `app/manifest.ts`: Web app manifest at `/manifest.json`.
@@ -2,6 +2,10 @@
2
2
  // (possibly async) function receiving { params, searchParams, url }; it runs
3
3
  // ONLY on the server. Throw notFound() / redirect() to short-circuit.
4
4
  //
5
+ // params / searchParams are BOTH synchronously readable AND awaitable: read
6
+ // `params.id` directly, or `const { id } = await params` (the Next 15/16
7
+ // pattern, supported so that muscle memory transfers). Either form is correct.
8
+ //
5
9
  // Type-safe routes: instead of hand-typing `{ params: { id: string } }`, type
6
10
  // the props with PageProps<'<route>'>. `webjs types` (run automatically by
7
11
  // `webjs dev`) generates .webjs/routes.d.ts with a Route union and per-route
@@ -11,14 +15,18 @@
11
15
  import { html } from '@webjsdev/core';
12
16
  import type { PageProps } from '@webjsdev/core';
13
17
 
14
- export default function RoutingParam({ params }: PageProps<'/features/routing/[id]'>) {
18
+ export default async function RoutingParam({ params }: PageProps<'/features/routing/[id]'>) {
19
+ // The Next-style await also works; `params.id` sync would be identical.
20
+ const { id } = await params;
15
21
  return html`
16
22
  <h1 class="text-h2 font-bold mb-4">Route param</h1>
17
- <p>The <code>[id]</code> segment is: <strong>${params.id}</strong></p>
23
+ <p>The <code>[id]</code> segment is: <strong>${id}</strong></p>
18
24
  <p class="text-muted-foreground text-sm mt-3">
19
25
  Typed with <code class="font-mono">PageProps&lt;'/features/routing/[id]'&gt;</code>,
20
26
  so <code class="font-mono">params.id</code> is a checked
21
27
  <code class="font-mono">string</code> from the generated route union.
28
+ <code class="font-mono">params</code> is awaitable too:
29
+ <code class="font-mono">const { id } = await params</code> works, same value.
22
30
  </p>
23
31
  <p class="mt-3"><a class="text-primary" href="/features/routing">Back</a></p>
24
32
  `;