@seip/bluebird-js 0.0.0-stage → 0.1.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 (79) hide show
  1. package/.env_example +54 -0
  2. package/AGENTS.md +426 -0
  3. package/LICENSE +21 -0
  4. package/README.md +292 -3
  5. package/app/routes/api.js +50 -0
  6. package/app/routes/web.js +55 -0
  7. package/app/views/about.js +63 -0
  8. package/app/views/dashboard.js +147 -0
  9. package/app/views/index.js +80 -0
  10. package/app/views/layouts/main/view.js +81 -0
  11. package/app/views/legal/terms.html +19 -0
  12. package/app/views/login.js +80 -0
  13. package/core/app.d.ts +18 -0
  14. package/core/app.js +684 -0
  15. package/core/auth.d.ts +13 -0
  16. package/core/auth.js +326 -0
  17. package/core/cache.d.ts +17 -0
  18. package/core/cache.js +475 -0
  19. package/core/cli/doctor.js +287 -0
  20. package/core/cli/ecosystem.js +162 -0
  21. package/core/cli/init.js +779 -0
  22. package/core/cli/migrate.js +541 -0
  23. package/core/cli/model.js +66 -0
  24. package/core/cli/nginx.js +199 -0
  25. package/core/cli/route.js +121 -0
  26. package/core/cli/swagger.js +45 -0
  27. package/core/cli/view.js +96 -0
  28. package/core/config.d.ts +3 -0
  29. package/core/config.js +111 -0
  30. package/core/csrf.d.ts +3 -0
  31. package/core/csrf.js +114 -0
  32. package/core/database.d.ts +15 -0
  33. package/core/database.js +636 -0
  34. package/core/debug.d.ts +3 -0
  35. package/core/debug.js +250 -0
  36. package/core/hash.d.ts +3 -0
  37. package/core/hash.js +194 -0
  38. package/core/html.d.ts +42 -0
  39. package/core/html.js +217 -0
  40. package/core/index.d.ts +1176 -0
  41. package/core/logger.d.ts +3 -0
  42. package/core/logger.js +127 -0
  43. package/core/middleware.d.ts +3 -0
  44. package/core/middleware.js +28 -0
  45. package/core/model.d.ts +19 -0
  46. package/core/model.js +600 -0
  47. package/core/queue.d.ts +13 -0
  48. package/core/queue.js +172 -0
  49. package/core/ratelimit.d.ts +3 -0
  50. package/core/ratelimit.js +145 -0
  51. package/core/redis.d.ts +21 -0
  52. package/core/redis.js +230 -0
  53. package/core/render-cache.js +212 -0
  54. package/core/render.d.ts +3 -0
  55. package/core/render.js +320 -0
  56. package/core/router.d.ts +3 -0
  57. package/core/router.js +171 -0
  58. package/core/seo.d.ts +3 -0
  59. package/core/seo.js +106 -0
  60. package/core/swagger.d.ts +3 -0
  61. package/core/swagger.js +60 -0
  62. package/core/upload.d.ts +13 -0
  63. package/core/upload.js +102 -0
  64. package/core/util/colors.js +82 -0
  65. package/core/validate.d.ts +15 -0
  66. package/core/validate.js +364 -0
  67. package/core/view-loader.js +162 -0
  68. package/core/vite.d.ts +3 -0
  69. package/core/vite.js +145 -0
  70. package/core/ws.d.ts +13 -0
  71. package/core/ws.js +245 -0
  72. package/index.js +18 -0
  73. package/jsconfig.json +15 -0
  74. package/package.json +85 -5
  75. package/production.md +273 -0
  76. package/public/css/bluebird.min.css +2 -0
  77. package/public/images/favicon.ico +0 -0
  78. package/public/js/bluebird-client.js +1781 -0
  79. package/public/js/bluebird.min.js +1073 -0
package/README.md CHANGED
@@ -1,3 +1,292 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # Bluebird.js Framework
2
+
3
+ **Performance-first Node.js API and web framework with native JavaScript ESM, built-in JWT auth, HTML rendering, BaseModel, schema validation, and multi-level caching.**
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@seip/bluebird-js.svg)](https://www.npmjs.com/package/@seip/bluebird-js)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7
+ [![Node.js Version](https://img.shields.io/badge/node-%3E%3D22.18.0-brightgreen.svg)](https://nodejs.org)
8
+
9
+ ---
10
+
11
+ ## Introduction
12
+
13
+ Bluebird.js (`@seip/bluebird-js`) is a high-performance web and API framework built on Express (Node.js 22.18+). It provides native modern JavaScript ESM execution, HTML template rendering, multi-driver caching (in-memory by default with filesystem and Redis support), AES-256-GCM encrypted JWT authentication, BaseModel schema definitions, CSRF protection, background queues, and PM2 production clustering into a cohesive developer experience.
14
+
15
+ ### Key Highlights
16
+
17
+ - **Pure Modern JavaScript (ESM):** Zero build steps, zero transpilation, pure Node.js 22.18+ ESM.
18
+ - **Root Entrypoint (`index.js`):** Clean and intuitive architecture with the entry file directly at the root.
19
+ - **Pure JavaScript Views & View Transitions:** Modern zero-build SSR with tagged template literals (html\`...\`), automatic XSS escaping, shared layouts, simple inline vanilla scripts, View Transitions SPA navigation, and uninterrupted audio/video streaming (data-persist="true").
20
+ - **Lightweight BaseModel:** Static facade providing readable schemas, CRUD shortcuts, smart relations, soft deletes, automatic query cache invalidation, and validation bridges.
21
+ - **Native SQLite & Desktop Mode (Electron/Tauri):** Uses Node's built-in `node:sqlite` driver with zero compilation overhead, plus first-class `desktop: true` mode (`app.runDesktop()`) for read-only `.asar` bundles.
22
+ - **Decoupled Caching:** High-speed in-memory LRU cache by default, persistent filesystem fallback, and modular Redis support via `core/redis.js`.
23
+ - **CSRF, Rate Limiting & Security:** Native HMAC-SHA256 signed CSRF protection, built-in Rate Limiter (`rateLimit` in `App` or `App.rateLimit()`), automatic `/sitemap.xml` & `/robots.txt` generation, and secure HTTP headers without external bloat.
24
+ - **Production Ready:** Built-in PM2 clustering CLI (`npx bluebird-js make:ecosystem`), optimized Nginx generator (`npx bluebird-js nginx:conf`), and native runner (`npm start`).
25
+
26
+ ---
27
+
28
+ ## Quick Start
29
+
30
+ ### 1. Requirements
31
+
32
+ - Node.js 22.18.0 or higher
33
+ - npm 10+
34
+
35
+ ### 2. Installation and Initialization
36
+
37
+ ```bash
38
+ npm install @seip/bluebird-js
39
+ npx bluebird-js
40
+ ```
41
+
42
+ The interactive CLI configures:
43
+ - Project title and port settings
44
+ - Database engine: `sqlite` (default, native zero-configuration), `mysql`, `postgres`, or `none`
45
+ - Connection credentials and database paths
46
+ - Automatic generation of `index.js`, `.env`, `jsconfig.json`, `app/`, and `public/`
47
+
48
+ ### 3. Development Server
49
+
50
+ ```bash
51
+ npm run dev
52
+ ```
53
+
54
+ The server starts with Node's native file watcher (`--watch`) and loads `.env` automatically via `--env-file=.env`.
55
+
56
+ ---
57
+
58
+ ## Project Structure
59
+
60
+ ```
61
+ project/
62
+ ├── index.js # Main application entrypoint
63
+ ├── app/
64
+ │ ├── models/ # BaseModel definitions
65
+ │ │ ├── user.js # User model schema & methods
66
+ │ │ └── post.js # Post model schema & relations
67
+ │ ├── routes/ # Application routes
68
+ │ │ ├── api.js # REST API routes
69
+ │ │ └── web.js # HTML page routes
70
+ │ ├── views/ # Pure JavaScript ESM views
71
+ │ │ ├── layouts/ # Shared page layouts (e.g. main/view.js)
72
+ │ │ ├── index.js # Public home view
73
+ │ │ ├── about.js # About page view
74
+ │ │ ├── login.js # Sign-in page view
75
+ │ │ └── dashboard.js # Protected dashboard view
76
+ │ └── jobs/ # Background worker job handlers
77
+ ├── src/ # Frontend source (React Islands)
78
+ │ └── islands/ # Interactive React island components
79
+ ├── public/ # Public static assets (CSS, JS, images, fonts)
80
+ │ ├── css/
81
+ │ ├── js/
82
+ │ │ └── bluebird-client.js # View Transitions, partial swaps & islands runtime
83
+ │ └── dist/ # Production Vite hashed bundles
84
+ ├── core/ # Bluebird.js framework core
85
+ ├── database/ # SQLite storage and SQL migrations
86
+ │ └── migrations/
87
+ ├── ecosystem.config.cjs # PM2 cluster configuration (production)
88
+ ├── production.md # Production deployment guide
89
+ ├── .env # Environment variables
90
+ └── package.json
91
+ ```
92
+
93
+ ---
94
+
95
+ ## Usage Examples
96
+
97
+ ### 1. Application Entrypoint (`index.js`)
98
+
99
+ ```javascript
100
+ import App from "@seip/bluebird-js/core/app.js";
101
+ import routerApi from "./app/routes/api.js";
102
+ import routerWeb from "./app/routes/web.js";
103
+
104
+ const app = new App({
105
+ routes: [routerWeb, routerApi],
106
+ port: process.env.PORT || 3000,
107
+ rateLimit: { max: 120, windowMs: 60000 },
108
+ });
109
+
110
+ app.run();
111
+ ```
112
+
113
+ For **Electron / Desktop** applications:
114
+
115
+ ```javascript
116
+ const app = new App({
117
+ desktop: true,
118
+ userDataPath: electronApp.getPath("userData"),
119
+ routes: [routerWeb, routerApi],
120
+ });
121
+
122
+ const { url } = await app.runDesktop();
123
+ mainWindow.loadURL(url);
124
+ ```
125
+
126
+ ### 2. Defining a Model (`app/models/user.js`)
127
+
128
+ ```javascript
129
+ import Model from "@seip/bluebird-js/core/model.js";
130
+
131
+ export default class User extends Model {
132
+ static table = "users";
133
+ static primaryKey = "id";
134
+ static timestamps = true;
135
+ static softDelete = true;
136
+
137
+ static schema = {
138
+ id: { type: "int", primary: true, auto: true },
139
+ name: { type: "string", length: 150, required: true },
140
+ email: { type: "string", length: 150, unique: true, required: true, email: true },
141
+ password: { type: "string", length: 255, required: true, min: 8, hidden: true, hash: true },
142
+ role: { type: "string", length: 20, default: "user", in: ["user", "admin"] },
143
+ };
144
+ }
145
+ ```
146
+
147
+ ### 3. REST API Routes (`app/routes/api.js`)
148
+
149
+ ```javascript
150
+ import App from "@seip/bluebird-js/core/app.js";
151
+ import Router from "@seip/bluebird-js/core/router.js";
152
+ import User from "../models/user.js";
153
+
154
+ const routerApi = new Router("/api");
155
+
156
+ routerApi.get("/users", async (req, res) => {
157
+ const users = await User.all({ limit: 50, order: "id DESC" });
158
+ res.ok({ users });
159
+ });
160
+
161
+ routerApi.post(
162
+ "/users",
163
+ App.rateLimit({ max: 10, windowMs: 60000 }),
164
+ User.validator("create").middleware(),
165
+ async (req, res) => {
166
+ const userId = await User.create(req.body);
167
+ res.created({ id: userId }, "User created successfully");
168
+ }
169
+ );
170
+
171
+ export default routerApi;
172
+ ```
173
+
174
+ ### 4. HTML Views, Layouts & Server Partials (`app/routes/web.js`)
175
+
176
+ When `{ seo: true }` is enabled on a router, Bluebird automatically generates `/sitemap.xml` and `/robots.txt`:
177
+
178
+ ```javascript
179
+ import Router from "@seip/bluebird-js/core/router.js";
180
+ import Render from "@seip/bluebird-js/core/render.js";
181
+
182
+ const routerWeb = new Router("/", { seo: true });
183
+
184
+ routerWeb.get("/", Render.view("index", { title: "Bluebird Application" }));
185
+ routerWeb.get("/stats-card", (req, res) => {
186
+ return Render.partial(res, "stat_card", { label: "Revenue", val: "$12,400", active: true });
187
+ });
188
+
189
+ export default routerWeb;
190
+ ```
191
+
192
+ Inside your views (`app/views/dashboard.js`), use pure JavaScript functions with `html` tagged templates and plain vanilla `<script>` tags:
193
+
194
+ ```javascript
195
+ // app/views/dashboard.js
196
+ import { html } from "@seip/bluebird-js/core/html.js";
197
+
198
+ export const layout = "main";
199
+ export const head = (data) => ({ title: `Dashboard — ${data.user?.name || "Member"}` });
200
+
201
+ export default function DashboardView({ user, metrics }) {
202
+ const initial = metrics?.unread || 0;
203
+
204
+ return html`
205
+ <section class="dashboard-grid">
206
+ <h1>Welcome back, ${user.name}</h1>
207
+
208
+ <div class="card">
209
+ <button id="btnDec" class="btn-sm">-</button>
210
+ <span id="counter" class="font-bold">${initial}</span>
211
+ <button id="btnInc" class="btn-sm">+</button>
212
+ </div>
213
+ </section>
214
+
215
+ <!-- Native inline script: clean, readable, zero build steps -->
216
+ <script>
217
+ (() => {
218
+ let count = ${initial};
219
+ const el = document.getElementById("counter");
220
+ document.getElementById("btnInc")?.addEventListener("click", () => {
221
+ count++;
222
+ if (el) el.textContent = count;
223
+ });
224
+ document.getElementById("btnDec")?.addEventListener("click", () => {
225
+ if (count > 0) count--;
226
+ if (el) el.textContent = count;
227
+ });
228
+ })();
229
+ </script>
230
+ `;
231
+ }
232
+ ```
233
+
234
+ > **Live Reload:** When running development (`npm run dev` with `node --watch`), Bluebird automatically reloads the browser tab via native Server-Sent Events whenever changes trigger a server restart. No plugins or browser extensions needed.
235
+
236
+ > **Architecture Tip:** Keep business operations, third-party APIs, and database transactions in `app/services/` or `app/models/`. Views should remain declarative, lightweight, and focused on presentation.
237
+
238
+ ### 5. Multi-Driver Caching (`core/cache.js`)
239
+
240
+ ```javascript
241
+ import Cache from "@seip/bluebird-js/core/cache.js";
242
+
243
+ await Cache.set("metrics", { activeUsers: 450 }, 60, { driver: "memory" });
244
+ const metrics = await Cache.get("metrics", { driver: "memory" });
245
+
246
+ await Cache.set("report", htmlContent, 300, { driver: "file" });
247
+ ```
248
+
249
+ ### 6. Raw Static HTML Delivery (`Render.html`)
250
+
251
+ For static legal documents, terms of service, or offline pages without server-side templating overhead:
252
+
253
+ ```javascript
254
+ routerWeb.get("/terms", (req, res) => Render.html(res, "legal/terms.html", { ttl: 86400 }));
255
+ ```
256
+
257
+ ---
258
+
259
+ ## Production Deployment
260
+
261
+ Bluebird.js supports direct Node.js execution and PM2 process clustering out of the box:
262
+
263
+ ```bash
264
+ npm start # Starts via Node.js
265
+ npx bluebird-js make:ecosystem --start # Generates ecosystem config and launches via PM2
266
+ ```
267
+
268
+ For complete instructions covering PM2, systemd services, Nginx reverse proxy setup, and optional standalone Docker configurations, read the [Production Guide](production.md).
269
+
270
+ ---
271
+
272
+ ## Developer Tooling CLI
273
+
274
+ ```bash
275
+ npx bluebird-js doctor # Diagnostic audit and HTTP smoke tests
276
+ npx bluebird-js make:model <Name> # Generates BaseModel class
277
+ npx bluebird-js make:route <name> [--auth] # Scaffolds REST route
278
+ npx bluebird-js make:view <name> [--ejs] # Scaffolds HTML/EJS template
279
+ npx bluebird-js make:migration <name> [--model <M>] # Generates database migration
280
+ npx bluebird-js migrate # Executes pending migrations
281
+ npx bluebird-js seed # Executes database seeds
282
+ npx bluebird-js nginx:conf [domain] [port] [root] # Generates Nginx reverse proxy configuration
283
+ npx bluebird-js make:ecosystem [--start] # Generates PM2 clustering config
284
+ npx bluebird-js add react-islands # Scaffolds React Islands, Vite & Client Router
285
+ npx bluebird-js add <module> # Installs optional on-demand package
286
+ ```
287
+
288
+ ---
289
+
290
+ ## License
291
+
292
+ MIT License. Copyright (c) 2026 Seip25.
@@ -0,0 +1,50 @@
1
+ import Router from "@seip/bluebird-js/core/router.js";
2
+ import Validator from "@seip/bluebird-js/core/validate.js";
3
+ import Cache from "@seip/bluebird-js/core/cache.js";
4
+ import Auth from "@seip/bluebird-js/core/auth.js";
5
+
6
+ const routerApi = new Router("/api");
7
+
8
+ routerApi.get("/", (req, res) => {
9
+ res.json({ api: true, message: "Blue Bird API", time: Date.now() });
10
+ });
11
+
12
+ routerApi.get("/users", (req, res) => {
13
+ const users = [
14
+ { name: "John Doe", email: "john.doe@example.com" },
15
+ { name: "Jane Doe", email: "jane.doe@example.com" },
16
+ ];
17
+ res.json(users);
18
+ });
19
+
20
+ const loginSchema = {
21
+ email: { required: true, email: true },
22
+ password: { required: true, min: 6 },
23
+ };
24
+
25
+ const loginValidator = new Validator(loginSchema, "en");
26
+
27
+ routerApi.post("/login", loginValidator.middleware(), (req, res) => {
28
+ res.json({ message: "Login successful", body: req.body });
29
+ });
30
+
31
+ routerApi.get("/cache", Cache.middleware(60), async (req, res) => {
32
+ await new Promise((resolve) => setTimeout(resolve, 2000));
33
+ res.json({ message: "Cache successful" });
34
+ });
35
+
36
+ routerApi.get("/auth_generate", async (req, res) => {
37
+ const token = await Auth.login(res, { id: 1, name: "John Doe" }, "auth");
38
+ res.json({ message: "Auth successful", token });
39
+ });
40
+
41
+ routerApi.get("/auth_logout", async (req, res) => {
42
+ await Auth.logout(res, "auth", {}, req);
43
+ res.json({ message: "Logged out" });
44
+ });
45
+
46
+ routerApi.get("/auth_verify", Auth.protect(), (req, res) => {
47
+ res.json({ message: "Auth successful", user: req.user });
48
+ });
49
+
50
+ export default routerApi;
@@ -0,0 +1,55 @@
1
+ import Router from "@seip/bluebird-js/core/router.js";
2
+ import Render from "@seip/bluebird-js/core/render.js";
3
+ import Auth from "@seip/bluebird-js/core/auth.js";
4
+
5
+ const routerWeb = new Router("/", { seo: true });
6
+
7
+ routerWeb.get("/", Render.cache(300), Render.view("index"));
8
+
9
+ routerWeb.get("/about", Render.cache(300), Render.view("about"));
10
+
11
+ routerWeb.get("/terms", (req, res) => Render.html(res, "legal/terms.html", { ttl: 86400 }));
12
+
13
+ routerWeb.get("/login", Render.view("login"));
14
+
15
+ routerWeb.post("/login", async (req, res) => {
16
+ const email = req.body?.email || "alex@example.com";
17
+ const rawPrefix = email.split("@")[0] || "alex";
18
+ const name = req.body?.name || (rawPrefix.charAt(0).toUpperCase() + rawPrefix.slice(1));
19
+
20
+ const user = {
21
+ id: 1,
22
+ name,
23
+ email,
24
+ role: "admin",
25
+ };
26
+
27
+ await Auth.login(res, user);
28
+ return res.redirect("/dashboard");
29
+ });
30
+
31
+ routerWeb.get("/logout", async (req, res) => {
32
+ if (
33
+ req.headers["x-bluebird-prefetch"] ||
34
+ req.headers.purpose === "prefetch" ||
35
+ req.headers["sec-purpose"] === "prefetch"
36
+ ) {
37
+ return res.status(204).end();
38
+ }
39
+ await Auth.logout(res);
40
+ return res.redirect("/login");
41
+ });
42
+
43
+ routerWeb.post("/logout", async (req, res) => {
44
+ await Auth.logout(res);
45
+ return res.redirect("/login");
46
+ });
47
+
48
+ routerWeb.get("/dashboard", Auth.protect({ redirect: "/login" }), async (req, res) => {
49
+ await Render.send(res, "dashboard", {
50
+ title: "Dashboard — Blue Bird",
51
+ user: req.user,
52
+ });
53
+ });
54
+
55
+ export default routerWeb;
@@ -0,0 +1,63 @@
1
+ import { html } from "@seip/bluebird-js/core/html.js";
2
+
3
+ export const layout = "main";
4
+
5
+ export const head = () => ({
6
+ title: "About Us — Blue Bird Framework",
7
+ description: "Learn about the architecture and design philosophy of Blue Bird.",
8
+ });
9
+
10
+ /**
11
+ * About page view module.
12
+ * @returns {import('@seip/bluebird-js/core/html.js').SafeHtml}
13
+ */
14
+ export default function AboutView() {
15
+ return html`
16
+ <section class="hero">
17
+ <h1 class="mt-3 text-gradient font-bold">About Blue Bird</h1>
18
+ <p class="lead">Built for performance, simplicity, and raw speed.</p>
19
+ </section>
20
+
21
+ <article class="mt-6">
22
+ <header>
23
+ <h2 class="text-gradient-blue font-semibold">Our Philosophy</h2>
24
+ </header>
25
+ <p>
26
+ Blue Bird was born out of a desire for a clean, performance-first approach to web development. We
27
+ believe in harnessing the raw power of Express.js and modern Node.js ESM, stripping away unnecessary bloat, and
28
+ providing developers with a robust foundation that just works.
29
+ </p>
30
+ <p>
31
+ By combining server-rendered pure JavaScript HTML modules with vanilla client scripts and native browser View Transitions,
32
+ Blue Bird eliminates heavy compilation pipelines and excessive memory usage.
33
+ </p>
34
+ </article>
35
+
36
+ <div class="px-4 py-4 mb-4">
37
+ <h2 class="text-gradient-blue font-semibold">Why Blue Bird?</h2>
38
+
39
+ <div class="grid cols-2 gap-4">
40
+ <div>
41
+ <details open>
42
+ <summary>Production Ready</summary>
43
+ <p>Seamless transition from development to production with PM2 clustering, systemd, and high performance multi-level caching.</p>
44
+ </details>
45
+ <details open>
46
+ <summary>Military Grade Security</summary>
47
+ <p>Built-in AES-256-GCM JWT encryption, secure HttpOnly cookie sessions, security headers, and rate limiting.</p>
48
+ </details>
49
+ </div>
50
+ <div>
51
+ <details open>
52
+ <summary>Multi-Tier Caching</summary>
53
+ <p>In-memory LRU, Redis clustering, and persistent file caching for maximum requests per second with minimum CPU usage.</p>
54
+ </details>
55
+ <details open>
56
+ <summary>Pure Modern JavaScript</summary>
57
+ <p>No heavy build steps or complex toolchains. Modern ESM templates and inline vanilla scripts executed cleanly in the browser.</p>
58
+ </details>
59
+ </div>
60
+ </div>
61
+ </div>
62
+ `;
63
+ }
@@ -0,0 +1,147 @@
1
+ import { html, script } from "@seip/bluebird-js/core/html.js";
2
+
3
+ export const layout = "main";
4
+
5
+ export const head = (data) => ({
6
+ title: `Dashboard — ${data.user?.name || "Member"}`,
7
+ description: "Protected member dashboard for Blue Bird framework.",
8
+ });
9
+
10
+ /**
11
+ * Dashboard page view module.
12
+ * @param {Object} props
13
+ * @param {Object} props.user
14
+ * @returns {import('@seip/bluebird-js/core/html.js').SafeHtml}
15
+ */
16
+ export default function DashboardView({ user = {} }) {
17
+ const initialCount = 7;
18
+
19
+ return html`
20
+ <section class="hero">
21
+ <h1 class="mt-3 text-gradient font-bold">Protected Dashboard</h1>
22
+ <p class="lead">You are securely authenticated via <strong>Auth.protect()</strong> middleware.</p>
23
+ </section>
24
+
25
+ <div class="mt-6">
26
+ <div class="alert alert-success mb-6">
27
+ <div>
28
+ <strong class="alert-title">Active Protected Session</strong>
29
+ <p class="alert-description">
30
+ This route was rendered on-demand with fresh session data via <code>Render.send(res, "dashboard", ...)</code>, bypassing view caching completely.
31
+ </p>
32
+ </div>
33
+ </div>
34
+
35
+ <article class="card">
36
+ <header class="card-header">
37
+ <div class="flex items-center justify-between">
38
+ <div>
39
+ <h3 class="card-title">User Profile</h3>
40
+ <p class="card-description">Decoded JWT payload stored in <code>req.user</code>.</p>
41
+ </div>
42
+ <span class="badge badge-success badge-glow">Active Session</span>
43
+ </div>
44
+ </header>
45
+
46
+ <div class="grid cols-2 gap-4 mt-4">
47
+ <div class="card bg-secondary">
48
+ <small class="text-muted uppercase font-bold tracking-wider">User Name</small>
49
+ <h4 class="font-bold text-lg mt-1">${user.name || "Anonymous"}</h4>
50
+ </div>
51
+ <div class="card bg-secondary">
52
+ <small class="text-muted uppercase font-bold tracking-wider">Email Address</small>
53
+ <h4 class="font-bold text-lg mt-1">${user.email || "user@example.com"}</h4>
54
+ </div>
55
+ <div class="card bg-secondary">
56
+ <small class="text-muted uppercase font-bold tracking-wider">Account Role</small>
57
+ <p class="mt-1"><span class="badge badge-primary">${user.role || "user"}</span></p>
58
+ </div>
59
+ <div class="card bg-secondary">
60
+ <small class="text-muted uppercase font-bold tracking-wider">Session Identifier</small>
61
+ <p class="mt-1 font-mono text-xs"><code>${user._sessionId || "sess_active"}</code></p>
62
+ </div>
63
+ </div>
64
+
65
+ <footer class="card-footer mt-6">
66
+ <a href="/logout" data-no-prefetch="true" role="button" class="destructive">Sign Out &rarr;</a>
67
+ <div class="flex items-center gap-2">
68
+ <a href="/about" role="button" class="outline">Test Transition to /about</a>
69
+ <a href="/" role="button" class="outline">Test Transition to /</a>
70
+ </div>
71
+ </footer>
72
+ </article>
73
+
74
+ <article class="card mt-6">
75
+ <header class="card-header">
76
+ <div class="flex items-center justify-between">
77
+ <div>
78
+ <h3 class="card-title">Vanilla Interactive Controls</h3>
79
+ <p class="card-description">Simple native inline script with zero framework overhead.</p>
80
+ </div>
81
+ <span class="badge badge-primary pulse-badge">Live Interactive</span>
82
+ </div>
83
+ </header>
84
+
85
+ <div class="mt-4">
86
+ <p class="text-sm">Click the buttons below to interact without page reloads:</p>
87
+
88
+ <div class="flex items-center gap-4 mt-3">
89
+ <button id="btnDec" type="button" class="btn-sm outline">&minus; Decrement</button>
90
+ <span id="counterVal" class="font-mono text-2xl font-bold px-3 py-1 bg-secondary rounded">${initialCount}</span>
91
+ <button id="btnInc" type="button" class="btn-sm outline">&plus; Increment</button>
92
+ <button id="btnReset" type="button" class="btn-sm destructive">Reset</button>
93
+ </div>
94
+
95
+ <div class="mt-6">
96
+ <label for="filterQuery" class="text-sm font-semibold">Live Input Demo:</label>
97
+ <input type="text" id="filterQuery" placeholder="Type here to test live vanilla event handling..." class="mt-2" />
98
+ <p id="summaryText" class="text-sm text-muted mt-2">Type in the field above to test live event listening.</p>
99
+ </div>
100
+ </div>
101
+ </article>
102
+
103
+ <script>
104
+ let count = ${initialCount};
105
+ const valEl = document.getElementById("counterVal");
106
+ const incBtn = document.getElementById("btnInc");
107
+ const decBtn = document.getElementById("btnDec");
108
+ const resetBtn = document.getElementById("btnReset");
109
+ const queryInput = document.getElementById("filterQuery");
110
+ const summaryEl = document.getElementById("summaryText");
111
+
112
+ const update = () => { if (valEl) valEl.textContent = String(count); };
113
+ incBtn?.addEventListener("click", () => { count++; update(); });
114
+ decBtn?.addEventListener("click", () => { if (count > 0) count--; update(); });
115
+ resetBtn?.addEventListener("click", () => { count = 0; update(); });
116
+
117
+ queryInput?.addEventListener("input", (e) => {
118
+ if (summaryEl) {
119
+ summaryEl.textContent = e.target.value
120
+ ? "Active input: " + e.target.value
121
+ : "Type in the field above to test live event listening.";
122
+ }
123
+ });
124
+ </script>
125
+
126
+ <article class="mt-6">
127
+ <header>
128
+ <h4 class="font-bold">Transition &amp; Middleware Diagnostics</h4>
129
+ </header>
130
+ <div class="grid cols-3 gap-4 mt-4">
131
+ <div class="card">
132
+ <h5 class="font-bold mb-1">Stateful Navigation</h5>
133
+ <p class="text-sm">Click links between Home, About, and Dashboard. Notice how the View Transitions API animates without page refreshes while preserving session cookies.</p>
134
+ </div>
135
+ <div class="card">
136
+ <h5 class="font-bold mb-1">Zero Cache On Dashboard</h5>
137
+ <p class="text-sm">Response header <code>X-Bluebird-Cache: MISS</code> is returned, verifying that user-sensitive data is never statically cached.</p>
138
+ </div>
139
+ <div class="card">
140
+ <h5 class="font-bold mb-1">Automatic Revocation</h5>
141
+ <p class="text-sm">Clicking "Sign Out" revokes the session in memory/Redis and clears the HttpOnly cookie, blocking subsequent dashboard visits.</p>
142
+ </div>
143
+ </div>
144
+ </article>
145
+ </div>
146
+ `;
147
+ }