@nmvuong92/fluxe 0.9.1 → 0.9.3
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/README.md +9 -8
- package/lib/core/cli.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Khung fullstack tối giản — **một runtime TypeScript** (chạy trên `nod
|
|
|
8
8
|
trên triết lý **RCA — Resolved Cell Architecture**: *logic chỉ phụ thuộc HỢP ĐỒNG; mọi quyết định
|
|
9
9
|
vận hành (render, backend data) là **kết quả được GIẢI** bởi engine, không viết tay.*
|
|
10
10
|
|
|
11
|
-
> Đổi backend data `memory ↔ sqlite ↔ postgres` chỉ một dòng trong `app/backend.ts`, đổi render
|
|
11
|
+
> Đổi backend data `memory ↔ sqlite ↔ postgres` chỉ một dòng trong `app/backend/data.ts`, đổi render
|
|
12
12
|
> `static ↔ island` qua profile — **cell & frontend không đổi một dòng**.
|
|
13
13
|
|
|
14
14
|
## Cài & dùng (npm)
|
|
@@ -25,7 +25,7 @@ import { rpc } from "@nmvuong92/fluxe/client";
|
|
|
25
25
|
|
|
26
26
|
| Import | Nội dung |
|
|
27
27
|
|--------|----------|
|
|
28
|
-
| `@nmvuong92/fluxe` | engine: defineCell, makeServer, resolver, auth, validate, seo, broker, ratelimit, codegen… (KHÔNG có driver data — backend là của bạn ở `app/backend.ts`) |
|
|
28
|
+
| `@nmvuong92/fluxe` | engine: defineCell, makeServer, resolver, auth, validate, seo, broker, ratelimit, codegen… (KHÔNG có driver data — backend là của bạn ở `app/backend/data.ts`) |
|
|
29
29
|
| `@nmvuong92/fluxe/react` | useQuery, useMutation, Link, Nav, ThemeToggle, useTheme, DebugBar |
|
|
30
30
|
| `@nmvuong92/fluxe/client` | rpc, RpcError, mutate, revalidate, subscribe |
|
|
31
31
|
| `@nmvuong92/fluxe/jobs` | queue/dead-letter (cần `--experimental-sqlite`) |
|
|
@@ -47,8 +47,9 @@ npm run test:all # typecheck + 144 unit + integration (selftest2) —
|
|
|
47
47
|
app/ ← DEV sở hữu (sửa thoải mái) — Contract Plane
|
|
48
48
|
cells/ trang/feature (route + loader + view + action/head/layout/guard)
|
|
49
49
|
layouts/ layout dùng chung (nested)
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
backend/ BACKEND của bạn (Express/Hono/Nest + fluxe)
|
|
51
|
+
server.ts entry: mount fluxe (catch-all) + route riêng của bạn
|
|
52
|
+
data.ts TẦNG DATA: interface domain + chọn driver (memory/sqlite/postgres); export backend
|
|
52
53
|
profiles.ts profile resolve render mode (static/island) per môi trường
|
|
53
54
|
contract.ts schema → codegen types TS
|
|
54
55
|
env.ts env có kiểu, validate fail-fast lúc boot
|
|
@@ -60,7 +61,7 @@ src/ ← ENGINE (không đụng) — Resolution Plane
|
|
|
60
61
|
server_factory.ts runtime ráp cell + giải manifest
|
|
61
62
|
```
|
|
62
63
|
|
|
63
|
-
**Quy tắc:** backend là **tầng data của bạn** ở `app/backend.ts` (interface domain + chọn driver),
|
|
64
|
+
**Quy tắc:** backend là **tầng data của bạn** ở `app/backend/data.ts` (interface domain + chọn driver),
|
|
64
65
|
inject qua `makeServer(…, { backend })`. Engine không bao giờ import ngược vào `app/`.
|
|
65
66
|
|
|
66
67
|
## Tính năng (tất cả TDD + chạy thật)
|
|
@@ -69,7 +70,7 @@ inject qua `makeServer(…, { backend })`. Engine không bao giờ import ngư
|
|
|
69
70
|
- **Render** — static (0 JS) · island hydrate · SPA nav (Inertia) · static-prerender · API mode `?json=1`
|
|
70
71
|
- **Routing** — động `[param]` → `ctx.input` · **nested layouts** · SEO (head/canonical/OG/JSON-LD per cell, `/sitemap.xml`, `/robots.txt`)
|
|
71
72
|
- **Bảo mật (đầy đủ)** — input validation (Zod) · auth password **scrypt** · **RBAC** · **CSRF** double-submit · **rate-limit** token-bucket · error handling không-leak + structured
|
|
72
|
-
- **Data** — backend **user-owned** ở `app/backend.ts` (bạn tự định nghĩa interface + implement bằng `node:sqlite`/`pg`/ORM trực tiếp), inject qua `makeServer(…, { backend })` · engine 0 driver · **codegen contract** 1 schema → types TS
|
|
73
|
+
- **Data** — backend **user-owned** ở `app/backend/data.ts` (bạn tự định nghĩa interface + implement bằng `node:sqlite`/`pg`/ORM trực tiếp), inject qua `makeServer(…, { backend })` · engine 0 driver · **codegen contract** 1 schema → types TS
|
|
73
74
|
- **Mutations DX** — `RpcError` có cấu trúc · `mutate()` optimistic + rollback · lỗi validation field-level
|
|
74
75
|
- **Realtime (Trục 4g)** — **SSE channel** + pub/sub broker · live-update on action · **presence** (multi-tab)
|
|
75
76
|
- **Async** — **job queue bền** (SQLite, retry → dead-letter)
|
|
@@ -79,7 +80,7 @@ inject qua `makeServer(…, { backend })`. Engine không bao giờ import ngư
|
|
|
79
80
|
|
|
80
81
|
## Backend data (user-owned, TS in-process)
|
|
81
82
|
|
|
82
|
-
Backend là **tầng data của bạn** — định nghĩa interface domain ở `app/backend.ts` + chọn driver
|
|
83
|
+
Backend là **tầng data của bạn** — định nghĩa interface domain ở `app/backend/data.ts` + chọn driver
|
|
83
84
|
**TS in-process** dưới đây, inject qua `makeServer(…, { backend })`. Cell chỉ thấy interface:
|
|
84
85
|
|
|
85
86
|
| Driver | Bạn tự implement bằng |
|
|
@@ -89,7 +90,7 @@ Backend là **tầng data của bạn** — định nghĩa interface domain ở
|
|
|
89
90
|
| `postgres` | `npm i pg`, dùng `Pool`/`Client` trực tiếp (`DATABASE_URL`) |
|
|
90
91
|
|
|
91
92
|
```ts
|
|
92
|
-
// app/backend.ts — engine không biết gì
|
|
93
|
+
// app/backend/data.ts — engine không biết gì
|
|
93
94
|
import { DatabaseSync } from "node:sqlite";
|
|
94
95
|
|
|
95
96
|
export interface Todo { id: string; title: string; done: boolean }
|
package/lib/core/cli.js
CHANGED
|
@@ -47,7 +47,7 @@ export const COMMANDS = {
|
|
|
47
47
|
},
|
|
48
48
|
dev: {
|
|
49
49
|
desc: "Sync + resolve + build client + chạy server",
|
|
50
|
-
shell: (a) => `${SYNC} && tsx scripts/resolve.ts ${p(a)} && ${ESBUILD} && tsx app/server.ts`,
|
|
50
|
+
shell: (a) => `${SYNC} && tsx scripts/resolve.ts ${p(a)} && ${ESBUILD} && tsx app/backend/server.ts`,
|
|
51
51
|
},
|
|
52
52
|
test: {
|
|
53
53
|
desc: "Sync + typecheck + unit + integration",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nmvuong92/fluxe",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"description": "fluxe — khung fullstack tối giản, một runtime TS (RCA: Resolved Cell Architecture).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "nmvuong92",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"typecheck": "tsc --noEmit",
|
|
57
57
|
"sync": "tsx scripts/sync.ts",
|
|
58
58
|
"build:client": "npm run sync && esbuild src/client.tsx --bundle --format=esm --outfile=dist/client.js --jsx=automatic --loader:.tsx=tsx",
|
|
59
|
-
"dev": "npm run build:client && tsx app/server.ts",
|
|
59
|
+
"dev": "npm run build:client && tsx app/backend/server.ts",
|
|
60
60
|
"dev:node": "npm run build:client && tsx src/server.tsx",
|
|
61
61
|
"test": "tsx src/selftest2.ts",
|
|
62
62
|
"test:unit": "node --experimental-sqlite --import tsx --test '{src,app}/**/*.test.ts'",
|