@seip/bluebird-js 0.1.1 → 0.1.4
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/.vscode/extensions.json +7 -0
- package/.vscode/settings.json +10 -0
- package/AGENTS.md +124 -64
- package/README.md +236 -103
- package/app/routes/web.js +47 -55
- package/app/views/about.jsx +98 -0
- package/app/views/components/Header.jsx +42 -0
- package/app/views/components/LiveCounter.jsx +67 -0
- package/app/views/dashboard.jsx +300 -0
- package/app/views/index.jsx +123 -0
- package/app/views/layouts/main/view.jsx +201 -0
- package/app/views/legal/terms.html +29 -19
- package/app/views/login.jsx +141 -0
- package/core/actions.d.ts +4 -0
- package/core/actions.js +329 -0
- package/core/app.js +129 -22
- package/core/auth.js +1 -1
- package/core/cli/doctor.js +3 -4
- package/core/cli/init.js +153 -6
- package/core/cli/migrate.js +418 -145
- package/core/cli/view.js +76 -11
- package/core/config.js +35 -5
- package/core/csrf.js +1 -1
- package/core/database.js +52 -17
- package/core/debug.js +1 -1
- package/core/html.d.ts +54 -42
- package/core/html.js +473 -217
- package/core/index.d.ts +187 -85
- package/core/jsx.d.ts +38 -0
- package/core/jsx.js +1180 -0
- package/core/model.js +282 -61
- package/core/queue.js +7 -4
- package/core/render-cache.js +212 -212
- package/core/render.d.ts +20 -2
- package/core/render.js +320 -43
- package/core/upload.js +7 -1
- package/core/validate.js +1 -1
- package/core/view-loader.js +341 -19
- package/core/vite.js +1 -1
- package/package.json +9 -3
- package/public/js/bluebird-client.js +2313 -1049
- package/public/js/tailwind.js +8 -0
- package/app/views/about.js +0 -63
- package/app/views/dashboard.js +0 -147
- package/app/views/index.js +0 -80
- package/app/views/layouts/main/view.js +0 -81
- package/app/views/login.js +0 -80
- package/public/css/bluebird.min.css +0 -2
- package/public/js/bluebird.min.js +0 -1073
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Bluebird.js Framework
|
|
2
2
|
|
|
3
|
-
**Performance-first Node.js API and web framework with native JavaScript ESM, built-in
|
|
3
|
+
**Performance-first Node.js API and web framework with native JavaScript ESM, built-in Tailwind CSS, Inter fonts, declarative UI components, JWT auth, BaseModel, smart migrations, and multi-level caching.**
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@seip/bluebird-js)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -10,17 +10,20 @@
|
|
|
10
10
|
|
|
11
11
|
## Introduction
|
|
12
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,
|
|
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, built-in Tailwind CSS v4 runtime and Google Fonts (`Inter`), zero-build SSR with React/Next.js-style component tags, multi-driver caching (in-memory LRU by default with filesystem and Redis support), AES-256-GCM encrypted JWT authentication, BaseModel schema definitions with smart migrations, CSRF protection, background queues, and PM2 production clustering into a cohesive developer experience.
|
|
14
14
|
|
|
15
15
|
### Key Highlights
|
|
16
16
|
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
19
|
-
- **
|
|
20
|
-
- **
|
|
17
|
+
- **Native Zero-Build React JSX SSR (`app/views/*.jsx`):** Compiles `.jsx` modules in memory via Node 22.18+ `module.registerHooks()` with zero temporary disk files and zero build steps.
|
|
18
|
+
- **Declarative Auto-Routes from Views:** Export `const route`, `const cache`, `const middlewares`, `const layout`, and `const seo` directly from `app/views/*.jsx` to mount cached, protected web routes automatically (`noAutoDiscoverRoutes: true` in `new App()` to disable).
|
|
19
|
+
- **Client Islands with Anti-Accordion Skeletons (`<Client>` / `<Island>`):** SSR by default (0 KB client JS), with `<Client>` boundaries that lock dimensions (`minHeight`, `minWidth`) and render a `skeleton` to prevent layout shift (CLS).
|
|
20
|
+
- **Built-In Tailwind CSS & Inter Font:** Includes the official standalone Tailwind CSS runtime (`/js/tailwind.js`) and Google Fonts `Inter` by default with zero configuration or compilers.
|
|
21
|
+
- **Smart Automatic Migrations:** CLI detects schema changes across `app/models/`, resolves foreign key dependencies topologically, generates consolidated `CREATE TABLE` / `ALTER TABLE ADD COLUMN` SQL files, and executes them with interactive terminal prompts.
|
|
22
|
+
- **Lightweight BaseModel:** Static facade providing readable schemas, CRUD shortcuts, query operators (`IN`, `$gt`, `$like`), `count()`, `exists()`, `firstOrCreate()`, `updateOrCreate()`, smart relations without N+1 queries, soft deletes, and automatic query cache invalidation.
|
|
21
23
|
- **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.
|
|
24
|
+
- **Comprehensive Client UI Kit:** Built-in `bluebird-client.js` with toasts, snackbars, drawers, command palette (`Ctrl+K`), responsive data tables, tabs, carousels, declarative forms (`data-bb-form`), and View Transitions SPA routing.
|
|
22
25
|
- **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
|
|
26
|
+
- **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.
|
|
24
27
|
- **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
28
|
|
|
26
29
|
---
|
|
@@ -67,32 +70,29 @@ project/
|
|
|
67
70
|
│ ├── routes/ # Application routes
|
|
68
71
|
│ │ ├── api.js # REST API routes
|
|
69
72
|
│ │ └── web.js # HTML page routes
|
|
70
|
-
│ ├── views/ #
|
|
71
|
-
│ │ ├──
|
|
72
|
-
│ │ ├──
|
|
73
|
-
│ │ ├──
|
|
74
|
-
│ │ ├──
|
|
75
|
-
│ │
|
|
73
|
+
│ ├── views/ # React JSX (.jsx) & JavaScript (.js) SSR views
|
|
74
|
+
│ │ ├── components/ # Reusable JSX components (e.g. Header.jsx)
|
|
75
|
+
│ │ ├── layouts/ # Shared page layouts (e.g. main/view.jsx)
|
|
76
|
+
│ │ ├── index.jsx # Public home view (Auto-Route: /)
|
|
77
|
+
│ │ ├── about.jsx # About page view (Auto-Route: /about)
|
|
78
|
+
│ │ ├── login.jsx # Sign-in page view (Auto-Route: /login)
|
|
79
|
+
│ │ └── dashboard.jsx # Protected dashboard view (Auto-Route: /dashboard)
|
|
76
80
|
│ └── jobs/ # Background worker job handlers
|
|
77
|
-
├── src/ # Frontend source (React Islands)
|
|
78
|
-
│ └── islands/ # Interactive React island components
|
|
79
81
|
├── public/ # Public static assets (CSS, JS, images, fonts)
|
|
80
|
-
│ ├── css/
|
|
81
82
|
│ ├── js/
|
|
82
|
-
│ │
|
|
83
|
-
│ └──
|
|
83
|
+
│ │ ├── tailwind.js # Built-in Tailwind CSS runtime
|
|
84
|
+
│ │ └── bluebird-client.js # Client UI kit, View Transitions & SPA router
|
|
85
|
+
│ └── images/
|
|
84
86
|
├── core/ # Bluebird.js framework core
|
|
85
87
|
├── database/ # SQLite storage and SQL migrations
|
|
86
|
-
│ └── migrations/
|
|
87
|
-
├── ecosystem.config.cjs # PM2 cluster configuration (production)
|
|
88
|
-
├── production.md # Production deployment guide
|
|
88
|
+
│ └── migrations/ # Version-controlled SQL migrations
|
|
89
89
|
├── .env # Environment variables
|
|
90
90
|
└── package.json
|
|
91
91
|
```
|
|
92
92
|
|
|
93
93
|
---
|
|
94
94
|
|
|
95
|
-
## Usage Examples
|
|
95
|
+
## Core Features & Usage Examples
|
|
96
96
|
|
|
97
97
|
### 1. Application Entrypoint (`index.js`)
|
|
98
98
|
|
|
@@ -119,11 +119,15 @@ const app = new App({
|
|
|
119
119
|
routes: [routerWeb, routerApi],
|
|
120
120
|
});
|
|
121
121
|
|
|
122
|
-
const { url } = await app.runDesktop();
|
|
122
|
+
const { url, lanUrl } = await app.runDesktop({ allowLan: true });
|
|
123
123
|
mainWindow.loadURL(url);
|
|
124
124
|
```
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
### 2. BaseModel & Smart Automatic Migrations (`app/models/`)
|
|
129
|
+
|
|
130
|
+
#### Defining a Model (`app/models/user.js`)
|
|
127
131
|
|
|
128
132
|
```javascript
|
|
129
133
|
import Model from "@seip/bluebird-js/core/model.js";
|
|
@@ -144,128 +148,252 @@ export default class User extends Model {
|
|
|
144
148
|
}
|
|
145
149
|
```
|
|
146
150
|
|
|
147
|
-
|
|
151
|
+
#### Foreign Key References (`app/models/post.js`)
|
|
148
152
|
|
|
149
153
|
```javascript
|
|
150
|
-
import
|
|
151
|
-
import Router from "@seip/bluebird-js/core/router.js";
|
|
152
|
-
import User from "../models/user.js";
|
|
154
|
+
import Model from "@seip/bluebird-js/core/model.js";
|
|
153
155
|
|
|
154
|
-
|
|
156
|
+
export default class Post extends Model {
|
|
157
|
+
static table = "posts";
|
|
158
|
+
static schema = {
|
|
159
|
+
id: { type: "int", primary: true, auto: true },
|
|
160
|
+
title: { type: "string", length: 200, required: true },
|
|
161
|
+
content: { type: "text" },
|
|
162
|
+
author_id: { type: "int", references: "users.id", onDelete: "cascade" },
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
```
|
|
155
166
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
167
|
+
#### Powerful Query Methods
|
|
168
|
+
|
|
169
|
+
```javascript
|
|
170
|
+
const totalUsers = await User.count({ role: "user" });
|
|
171
|
+
const userExists = await User.exists({ email: "alice@example.com" });
|
|
172
|
+
|
|
173
|
+
const activeUsers = await User.all({
|
|
174
|
+
where: {
|
|
175
|
+
id: [1, 2, 3],
|
|
176
|
+
role: { $ne: "banned" },
|
|
177
|
+
views: { $gt: 100 },
|
|
178
|
+
},
|
|
159
179
|
});
|
|
160
180
|
|
|
161
|
-
|
|
162
|
-
"
|
|
163
|
-
|
|
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
|
-
}
|
|
181
|
+
const user = await User.firstOrCreate(
|
|
182
|
+
{ email: "john@example.com" },
|
|
183
|
+
{ name: "John Doe", role: "user" }
|
|
169
184
|
);
|
|
170
185
|
|
|
171
|
-
|
|
186
|
+
const updated = await User.updateOrCreate(
|
|
187
|
+
{ email: "john@example.com" },
|
|
188
|
+
{ name: "Johnathan Doe" }
|
|
189
|
+
);
|
|
172
190
|
```
|
|
173
191
|
|
|
174
|
-
|
|
192
|
+
#### Smart Automatic Migrations CLI
|
|
175
193
|
|
|
176
|
-
When
|
|
194
|
+
When you create or modify models, simply run:
|
|
177
195
|
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
|
|
196
|
+
```bash
|
|
197
|
+
npx bluebird-js make:migration
|
|
198
|
+
```
|
|
181
199
|
|
|
182
|
-
|
|
200
|
+
Bluebird inspects your models in `app/models/`, connects to your database, sorts tables by foreign key dependencies topologically, and detects all missing tables and columns (`CREATE TABLE` and `ALTER TABLE ADD COLUMN`). It generates a consolidated SQL migration file and asks:
|
|
183
201
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
202
|
+
```
|
|
203
|
+
[INFO] Detected database schema changes:
|
|
204
|
+
+ CREATE TABLE: users
|
|
205
|
+
+ CREATE TABLE: posts
|
|
206
|
+
[OK] Migration created: database/migrations/20261022_120000_auto_migration.sql
|
|
207
|
+
? Do you want to execute pending migrations now? (Y/n):
|
|
208
|
+
```
|
|
188
209
|
|
|
189
|
-
|
|
210
|
+
To run migrations directly without prompts (ideal for CI/CD):
|
|
211
|
+
```bash
|
|
212
|
+
npx bluebird-js migrate --yes
|
|
190
213
|
```
|
|
191
214
|
|
|
192
|
-
|
|
215
|
+
---
|
|
193
216
|
|
|
194
|
-
|
|
195
|
-
// app/views/dashboard.js
|
|
196
|
-
import { html } from "@seip/bluebird-js/core/html.js";
|
|
217
|
+
### 3. React JSX SSR, Declarative Auto-Routes & `<Client>` Skeletons
|
|
197
218
|
|
|
198
|
-
|
|
199
|
-
export const head = (data) => ({ title: `Dashboard — ${data.user?.name || "Member"}` });
|
|
219
|
+
#### Default Tailwind CSS & Inter Typography
|
|
200
220
|
|
|
201
|
-
|
|
202
|
-
const initial = metrics?.unread || 0;
|
|
221
|
+
The default layout (`app/views/layouts/main/view.jsx`) comes pre-wired with Google Fonts `Inter` and the standalone Tailwind CSS v4 runtime (`/js/tailwind.js`). You can write pure Tailwind utility classes immediately without running Vite, PostCSS, or Tailwind CLI.
|
|
203
222
|
|
|
204
|
-
|
|
205
|
-
<section class="dashboard-grid">
|
|
206
|
-
<h1>Welcome back, ${user.name}</h1>
|
|
223
|
+
#### Native `.jsx` Views & Declarative Auto-Routes
|
|
207
224
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
225
|
+
Bluebird compiles `.jsx` files in memory using Node's native module hooks (`core/jsx.js`)—no external bundler or disk temp files required. Even better, any view inside `app/views/` (excluding `layouts/`, `components/`, `partials/`, `islands/`, and `/api`) can export its own route configuration (`route`, `cache`, `middlewares`, `layout`, `seo`) and `App` mounts it automatically on startup (pass `noAutoDiscoverRoutes: true` to `new App()` if you prefer manual registration only):
|
|
226
|
+
|
|
227
|
+
```jsx
|
|
228
|
+
// app/views/components/Header.jsx
|
|
229
|
+
export default function Header({ title, user, count = 0 }) {
|
|
230
|
+
return (
|
|
231
|
+
<header className="flex items-center justify-between p-6 border-b border-slate-800">
|
|
232
|
+
<div>
|
|
233
|
+
<h1 className="text-2xl font-bold text-slate-100">{title}</h1>
|
|
234
|
+
<p className="text-sm text-slate-400">Welcome back, {user?.name || "Guest"}</p>
|
|
212
235
|
</div>
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
`;
|
|
236
|
+
<span className="px-3 py-1 rounded-full text-xs font-semibold bg-sky-500/10 text-sky-400 border border-sky-500/20">
|
|
237
|
+
Notifications: {count}
|
|
238
|
+
</span>
|
|
239
|
+
</header>
|
|
240
|
+
);
|
|
231
241
|
}
|
|
232
242
|
```
|
|
233
243
|
|
|
234
|
-
|
|
244
|
+
```jsx
|
|
245
|
+
// app/views/dashboard.jsx
|
|
246
|
+
import Auth from "@seip/bluebird-js/core/auth.js";
|
|
247
|
+
import Actions from "@seip/bluebird-js/core/actions.js";
|
|
248
|
+
import { Client } from "@seip/bluebird-js/core/jsx.js";
|
|
249
|
+
import Header from "./components/Header.jsx";
|
|
250
|
+
import LiveCounter from "./components/LiveCounter.js";
|
|
251
|
+
|
|
252
|
+
export const route = "/dashboard";
|
|
253
|
+
export const layout = "main";
|
|
254
|
+
export const middlewares = [Auth.protect({ redirect: "/login" })];
|
|
255
|
+
export const seo = false;
|
|
256
|
+
export const head = (data) => ({ title: `Dashboard — ${data.user?.name || "Member"}` });
|
|
257
|
+
|
|
258
|
+
// Server Actions: automatic CSRF, 16KB maxBytes guard, prototype pollution filter & Validator schema
|
|
259
|
+
export const actions = {
|
|
260
|
+
syncCount: Actions.define(
|
|
261
|
+
{
|
|
262
|
+
maxBytes: "16kb",
|
|
263
|
+
schema: { count: { required: true, number: true } },
|
|
264
|
+
},
|
|
265
|
+
async ({ body, user }) => {
|
|
266
|
+
return { syncedCount: Number(body.count), updatedBy: user?.email };
|
|
267
|
+
}
|
|
268
|
+
),
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
export default async function DashboardView({ user, syncedCount = 7 }) {
|
|
272
|
+
return (
|
|
273
|
+
<>
|
|
274
|
+
<Header title="Protected Dashboard" user={user} count={syncedCount} />
|
|
275
|
+
|
|
276
|
+
<div className="space-y-6 mt-6">
|
|
277
|
+
{/* Reusable imported Client component with persistent state & anti-CLS skeleton */}
|
|
278
|
+
<Client
|
|
279
|
+
component={LiveCounter}
|
|
280
|
+
props={{ initial: syncedCount }}
|
|
281
|
+
persistent={true}
|
|
282
|
+
minHeight={56}
|
|
283
|
+
skeleton={
|
|
284
|
+
<div className="h-14 rounded-xl bg-slate-900 animate-pulse flex items-center px-4 text-xs text-slate-400">
|
|
285
|
+
Loading interactive widget...
|
|
286
|
+
</div>
|
|
287
|
+
}
|
|
288
|
+
/>
|
|
289
|
+
</div>
|
|
290
|
+
</>
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
```
|
|
235
294
|
|
|
236
|
-
|
|
295
|
+
---
|
|
237
296
|
|
|
238
|
-
###
|
|
297
|
+
### 4. Built-in Client UI Kit (`public/js/bluebird-client.js`)
|
|
298
|
+
|
|
299
|
+
Bluebird includes a lightweight, dependency-free client UI toolkit with Tailwind CSS styles built right into `public/js/bluebird-client.js`:
|
|
300
|
+
|
|
301
|
+
#### Toasts & Snackbars
|
|
239
302
|
|
|
240
303
|
```javascript
|
|
241
|
-
|
|
304
|
+
toast({
|
|
305
|
+
title: "Profile Updated",
|
|
306
|
+
description: "Your settings have been saved successfully.",
|
|
307
|
+
type: "success",
|
|
308
|
+
position: "top-right",
|
|
309
|
+
duration: 4000,
|
|
310
|
+
});
|
|
242
311
|
|
|
243
|
-
|
|
244
|
-
|
|
312
|
+
snackbar({ message: "Network connection restored", type: "info" });
|
|
313
|
+
```
|
|
245
314
|
|
|
246
|
-
|
|
315
|
+
Or trigger them declaratively via HTML attributes:
|
|
316
|
+
```html
|
|
317
|
+
<button data-toast="Settings saved successfully!" data-toast-type="success">Save</button>
|
|
318
|
+
<button data-snackbar="Item deleted" data-snackbar-type="error">Delete</button>
|
|
247
319
|
```
|
|
248
320
|
|
|
249
|
-
|
|
321
|
+
#### Drawers & Mobile Navigation
|
|
250
322
|
|
|
251
|
-
|
|
323
|
+
```html
|
|
324
|
+
<button data-drawer-target="cartDrawer">Open Cart</button>
|
|
325
|
+
|
|
326
|
+
<div id="cartDrawer" class="hidden fixed top-0 right-0 h-full w-80 bg-slate-900 p-6 z-50">
|
|
327
|
+
<button data-drawer-close="cartDrawer" class="text-slate-400">×</button>
|
|
328
|
+
<h3>Shopping Cart</h3>
|
|
329
|
+
</div>
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
#### Responsive Data Table (`ResponsiveDataTable`)
|
|
333
|
+
|
|
334
|
+
Transforms tables dynamically into touch-friendly cards on mobile devices:
|
|
252
335
|
|
|
253
336
|
```javascript
|
|
254
|
-
|
|
337
|
+
new ResponsiveDataTable("usersTableContainer", {
|
|
338
|
+
columns: [
|
|
339
|
+
{ key: "id", label: "ID", sortable: true },
|
|
340
|
+
{ key: "name", label: "Name", sortable: true },
|
|
341
|
+
{ key: "email", label: "Email" },
|
|
342
|
+
{ key: "role", label: "Role" },
|
|
343
|
+
],
|
|
344
|
+
data: usersList,
|
|
345
|
+
searchable: true,
|
|
346
|
+
pagination: true,
|
|
347
|
+
pageSize: 10,
|
|
348
|
+
onEdit: (row) => editUser(row.id),
|
|
349
|
+
onDelete: (row) => deleteUser(row.id),
|
|
350
|
+
});
|
|
255
351
|
```
|
|
256
352
|
|
|
353
|
+
#### Declarative SPA Forms (`data-bb-form`)
|
|
354
|
+
|
|
355
|
+
```html
|
|
356
|
+
<form action="/api/profile" method="POST" data-bb-form="true">
|
|
357
|
+
<input type="text" name="name" required />
|
|
358
|
+
<button type="submit">Update</button>
|
|
359
|
+
</form>
|
|
360
|
+
```
|
|
361
|
+
Submissions are automatically handled via `fetch`, CSRF tokens are injected, and toasts/redirects are handled seamlessly via View Transitions.
|
|
362
|
+
|
|
363
|
+
#### Declarative DOM Helpers
|
|
364
|
+
|
|
365
|
+
- `data-copy="Text to copy"`: Copies text to clipboard on click.
|
|
366
|
+
- `data-confirm="Are you sure?"`: Confirms before link navigation or button click.
|
|
367
|
+
- `data-toggle="theme"`: Switches between dark and light modes and updates the `dark` class on `<html>`.
|
|
368
|
+
- `data-password-toggle="passwordFieldId"`: Toggles password visibility.
|
|
369
|
+
- `data-filter-target="tableId"`: Live filters rows or cards matching input value.
|
|
370
|
+
|
|
257
371
|
---
|
|
258
372
|
|
|
259
|
-
|
|
373
|
+
### 5. Multi-Driver Caching (`core/cache.js`)
|
|
374
|
+
|
|
375
|
+
```javascript
|
|
376
|
+
import Cache from "@seip/bluebird-js/core/cache.js";
|
|
260
377
|
|
|
261
|
-
|
|
378
|
+
await Cache.set("metrics", { activeUsers: 450 }, 60, { driver: "memory" });
|
|
379
|
+
const metrics = await Cache.get("metrics", { driver: "memory" });
|
|
262
380
|
|
|
263
|
-
|
|
264
|
-
npm start # Starts via Node.js
|
|
265
|
-
npx bluebird-js make:ecosystem --start # Generates ecosystem config and launches via PM2
|
|
381
|
+
await Cache.set("report", htmlContent, 300, { driver: "file" });
|
|
266
382
|
```
|
|
267
383
|
|
|
268
|
-
|
|
384
|
+
---
|
|
385
|
+
|
|
386
|
+
### 6. Desktop Applications (Electron & Desktop Mode)
|
|
387
|
+
|
|
388
|
+
Bluebird.js runs natively embedded inside **Electron** applications with ultra-fast boot (<200ms) and minimal RAM consumption (~25–40 MB vs ~300 MB with Nextron):
|
|
389
|
+
|
|
390
|
+
- **Automatic Writable Paths:** Routes SQLite database, `logs/`, `app/cache/`, and file uploads (`Upload.storage()`) to `Config.userDataDir()` (`app.getPath("userData")`) to avoid read-only errors inside `.asar` archives.
|
|
391
|
+
- **Dynamic Port & LAN / QR Access:** Binds to dynamic port `0` and generates LAN URLs (`allowLan: true`) for companion mobile/QR code access.
|
|
392
|
+
- **Clean WAL Shutdown:** `await app.close()` truncates SQLite WAL and frees file locks cleanly on Windows/Mac/Linux.
|
|
393
|
+
|
|
394
|
+
```bash
|
|
395
|
+
npx bluebird-js add electron
|
|
396
|
+
```
|
|
269
397
|
|
|
270
398
|
---
|
|
271
399
|
|
|
@@ -276,11 +404,16 @@ npx bluebird-js doctor # Diagnostic audit and HTT
|
|
|
276
404
|
npx bluebird-js make:model <Name> # Generates BaseModel class
|
|
277
405
|
npx bluebird-js make:route <name> [--auth] # Scaffolds REST route
|
|
278
406
|
npx bluebird-js make:view <name> [--ejs] # Scaffolds HTML/EJS template
|
|
279
|
-
npx bluebird-js make:migration
|
|
280
|
-
npx bluebird-js
|
|
407
|
+
npx bluebird-js make:migration [name] # Smart auto-migration from app/models/
|
|
408
|
+
npx bluebird-js make:migration --model <Model> # Generates migration for specific Model
|
|
409
|
+
npx bluebird-js migrate [--yes] # Executes pending migrations
|
|
410
|
+
npx bluebird-js migrate:status # Displays applied migration batches
|
|
411
|
+
npx bluebird-js migrate:rollback # Reverts latest migration batch
|
|
412
|
+
npx bluebird-js make:seed <name> # Creates database seed file
|
|
281
413
|
npx bluebird-js seed # Executes database seeds
|
|
282
414
|
npx bluebird-js nginx:conf [domain] [port] [root] # Generates Nginx reverse proxy configuration
|
|
283
415
|
npx bluebird-js make:ecosystem [--start] # Generates PM2 clustering config
|
|
416
|
+
npx bluebird-js add electron # Scaffolds Electron desktop app & desktop.js
|
|
284
417
|
npx bluebird-js add react-islands # Scaffolds React Islands, Vite & Client Router
|
|
285
418
|
npx bluebird-js add <module> # Installs optional on-demand package
|
|
286
419
|
```
|
package/app/routes/web.js
CHANGED
|
@@ -1,55 +1,47 @@
|
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
req.headers
|
|
34
|
-
req.headers
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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;
|
|
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
|
+
/**
|
|
6
|
+
* Web Router for custom actions and static HTML files.
|
|
7
|
+
* Page GET routes (`/`, `/about`, `/login`, `/dashboard`) are automatically
|
|
8
|
+
* generated from `app/views/*.jsx` via declarative exports (`route`, `cache`, `middlewares`, `layout`, `seo`).
|
|
9
|
+
*/
|
|
10
|
+
const routerWeb = new Router("/", { seo: true });
|
|
11
|
+
|
|
12
|
+
routerWeb.get("/terms", (req, res) => Render.html(res, "legal/terms.html", { ttl: 86400 }));
|
|
13
|
+
|
|
14
|
+
routerWeb.post("/login", async (req, res) => {
|
|
15
|
+
const email = req.body?.email || "alex@example.com";
|
|
16
|
+
const rawPrefix = email.split("@")[0] || "alex";
|
|
17
|
+
const name = req.body?.name || (rawPrefix.charAt(0).toUpperCase() + rawPrefix.slice(1));
|
|
18
|
+
|
|
19
|
+
const user = {
|
|
20
|
+
id: 1,
|
|
21
|
+
name,
|
|
22
|
+
email,
|
|
23
|
+
role: "admin",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
await Auth.login(res, user);
|
|
27
|
+
return res.redirect("/dashboard");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
routerWeb.get("/logout", async (req, res) => {
|
|
31
|
+
if (
|
|
32
|
+
req.headers["x-bluebird-prefetch"] ||
|
|
33
|
+
req.headers.purpose === "prefetch" ||
|
|
34
|
+
req.headers["sec-purpose"] === "prefetch"
|
|
35
|
+
) {
|
|
36
|
+
return res.status(204).end();
|
|
37
|
+
}
|
|
38
|
+
await Auth.logout(res);
|
|
39
|
+
return res.redirect("/login");
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
routerWeb.post("/logout", async (req, res) => {
|
|
43
|
+
await Auth.logout(res);
|
|
44
|
+
return res.redirect("/login");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export default routerWeb;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export const route = "/about";
|
|
2
|
+
export const cache = 300;
|
|
3
|
+
export const layout = "main";
|
|
4
|
+
export const seo = true;
|
|
5
|
+
|
|
6
|
+
export const head = () => ({
|
|
7
|
+
title: "About Us — Blue Bird Framework",
|
|
8
|
+
description: "Learn about the architecture and design philosophy of Blue Bird.",
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* About page React JSX view module.
|
|
13
|
+
*/
|
|
14
|
+
export default function AboutView() {
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
<section className="py-10 md:py-14 border-b border-slate-800/80">
|
|
18
|
+
<h1 className="mt-3 text-3xl md:text-5xl font-extrabold tracking-tight bg-gradient-to-r from-sky-400 via-blue-500 to-indigo-400 bg-clip-text text-transparent">
|
|
19
|
+
About Blue Bird
|
|
20
|
+
</h1>
|
|
21
|
+
<p className="mt-4 text-base md:text-lg text-slate-300 max-w-2xl leading-relaxed">
|
|
22
|
+
Built for performance, simplicity, and raw speed with native React JSX SSR.
|
|
23
|
+
</p>
|
|
24
|
+
</section>
|
|
25
|
+
|
|
26
|
+
<article className="mt-8 rounded-2xl border border-slate-800 bg-slate-900/60 p-6 md:p-8">
|
|
27
|
+
<header>
|
|
28
|
+
<h2 className="text-xl font-bold text-sky-400 mb-3">Our Philosophy</h2>
|
|
29
|
+
</header>
|
|
30
|
+
<p className="text-slate-300 leading-relaxed">
|
|
31
|
+
Blue Bird was born out of a desire for a clean, performance-first approach to web development. We
|
|
32
|
+
believe in harnessing the raw power of Express.js and modern Node.js ESM, stripping away unnecessary bloat, and
|
|
33
|
+
providing developers with a robust foundation that just works.
|
|
34
|
+
</p>
|
|
35
|
+
<p className="text-slate-300 leading-relaxed mt-4">
|
|
36
|
+
By combining server-rendered React JSX views with selective client hydration, anti-CLS skeletons, and native browser View Transitions,
|
|
37
|
+
Blue Bird eliminates heavy compilation pipelines and excessive memory usage.
|
|
38
|
+
</p>
|
|
39
|
+
</article>
|
|
40
|
+
|
|
41
|
+
<div className="mt-8">
|
|
42
|
+
<h2 className="text-xl font-bold text-slate-100 mb-4">Why Blue Bird?</h2>
|
|
43
|
+
|
|
44
|
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
45
|
+
<div className="space-y-4">
|
|
46
|
+
<details
|
|
47
|
+
className="rounded-xl border border-slate-800 bg-slate-900/50 p-4 open:border-slate-700 transition-colors"
|
|
48
|
+
open
|
|
49
|
+
>
|
|
50
|
+
<summary className="font-semibold text-slate-200 cursor-pointer select-none">
|
|
51
|
+
Production Ready
|
|
52
|
+
</summary>
|
|
53
|
+
<p className="mt-2 text-sm text-slate-400 leading-relaxed">
|
|
54
|
+
Seamless transition from development to production with PM2 clustering, systemd, and high performance multi-level caching.
|
|
55
|
+
</p>
|
|
56
|
+
</details>
|
|
57
|
+
<details
|
|
58
|
+
className="rounded-xl border border-slate-800 bg-slate-900/50 p-4 open:border-slate-700 transition-colors"
|
|
59
|
+
open
|
|
60
|
+
>
|
|
61
|
+
<summary className="font-semibold text-slate-200 cursor-pointer select-none">
|
|
62
|
+
Military Grade Security
|
|
63
|
+
</summary>
|
|
64
|
+
<p className="mt-2 text-sm text-slate-400 leading-relaxed">
|
|
65
|
+
Built-in AES-256-GCM JWT encryption, secure HttpOnly cookie sessions, security headers, and rate limiting.
|
|
66
|
+
</p>
|
|
67
|
+
</details>
|
|
68
|
+
</div>
|
|
69
|
+
<div className="space-y-4">
|
|
70
|
+
<details
|
|
71
|
+
className="rounded-xl border border-slate-800 bg-slate-900/50 p-4 open:border-slate-700 transition-colors"
|
|
72
|
+
open
|
|
73
|
+
>
|
|
74
|
+
<summary className="font-semibold text-slate-200 cursor-pointer select-none">
|
|
75
|
+
Multi-Tier Caching
|
|
76
|
+
</summary>
|
|
77
|
+
<p className="mt-2 text-sm text-slate-400 leading-relaxed">
|
|
78
|
+
In-memory LRU, Redis clustering, and persistent file caching for maximum requests per second with minimum CPU usage.
|
|
79
|
+
</p>
|
|
80
|
+
</details>
|
|
81
|
+
<details
|
|
82
|
+
className="rounded-xl border border-slate-800 bg-slate-900/50 p-4 open:border-slate-700 transition-colors"
|
|
83
|
+
open
|
|
84
|
+
>
|
|
85
|
+
<summary className="font-semibold text-slate-200 cursor-pointer select-none">
|
|
86
|
+
React JSX SSR & Auto-Routes
|
|
87
|
+
</summary>
|
|
88
|
+
<p className="mt-2 text-sm text-slate-400 leading-relaxed">
|
|
89
|
+
Write clean JSX components with declarative route exports (<code>cache</code>, <code>middlewares</code>, <code>layout</code>) and zero build steps.
|
|
90
|
+
</p>
|
|
91
|
+
</details>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
</>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|