@finesoft/front 0.1.46 → 0.1.47

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/README.md +135 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,135 @@
1
+ # @finesoft/front
2
+
3
+ Full-stack TypeScript framework — router, DI, actions, SSR, and server — all in one package.
4
+
5
+ Works with **Vue**, **React**, and **Svelte**. Deploy to Node.js, Vercel, Cloudflare Workers, Netlify, or static hosting.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npx create-finesoft-app my-app
11
+ ```
12
+
13
+ Or add to an existing project:
14
+
15
+ ```bash
16
+ npm install @finesoft/front
17
+ ```
18
+
19
+ Peer dependencies: `hono >= 4.0.0`. Optional: `@hono/node-server`, `vite >= 5.0.0`.
20
+
21
+ ## Setup
22
+
23
+ ```ts
24
+ // vite.config.ts
25
+ import { finesoftFrontViteConfig } from "@finesoft/front";
26
+ import vue from "@vitejs/plugin-vue";
27
+ import { defineConfig } from "vite";
28
+
29
+ export default defineConfig({
30
+ plugins: [
31
+ vue(),
32
+ finesoftFrontViteConfig({
33
+ ssr: { entry: "src/ssr.ts" },
34
+ locales: ["en", "zh"],
35
+ proxies: [{ prefix: "/api", target: "https://api.example.com" }],
36
+ adapter: "auto",
37
+ }),
38
+ ],
39
+ });
40
+ ```
41
+
42
+ ## Routing
43
+
44
+ ```ts
45
+ // src/bootstrap.ts
46
+ import { type Framework, defineRoutes } from "@finesoft/front";
47
+ import { HomeController } from "./lib/controllers/home";
48
+ import { authGuard } from "./lib/guards/auth";
49
+
50
+ export function bootstrap(framework: Framework): void {
51
+ defineRoutes(framework, [
52
+ { path: "/", intentId: "home", controller: new HomeController() },
53
+ {
54
+ path: "/about",
55
+ intentId: "about",
56
+ controller: new AboutController(),
57
+ renderMode: "csr",
58
+ },
59
+ { path: "/admin", intentId: "home", beforeLoad: [authGuard] },
60
+ ]);
61
+ }
62
+ ```
63
+
64
+ ## Controllers
65
+
66
+ ```ts
67
+ import { BaseController, type Container } from "@finesoft/front";
68
+
69
+ class HomeController extends BaseController<Record<string, string>, HomePage> {
70
+ readonly intentId = "home";
71
+
72
+ async execute(_params: Record<string, string>, container: Container) {
73
+ const http = container.resolve<HttpClient>("http");
74
+ return http.get("/api/home");
75
+ }
76
+ }
77
+ ```
78
+
79
+ ## Middleware
80
+
81
+ Two-phase guards shared between SSR and CSR:
82
+
83
+ ```ts
84
+ import { next, redirect, type NavigationContext } from "@finesoft/front";
85
+
86
+ function authGuard(ctx: NavigationContext) {
87
+ return ctx.getCookie("token") ? next() : redirect("/login");
88
+ }
89
+ ```
90
+
91
+ Results: `next()`, `redirect(url, status?)`, `rewrite(url)`, `deny(status?, message?)`.
92
+
93
+ ## SSR
94
+
95
+ ```ts
96
+ // src/ssr.ts
97
+ import { createSSRRender, serializeServerData } from "@finesoft/front";
98
+ import { createSSRApp } from "vue";
99
+ import { renderToString } from "vue/server-renderer";
100
+ import App from "./App.vue";
101
+ import { bootstrap } from "./bootstrap";
102
+
103
+ export const render = createSSRRender({
104
+ bootstrap,
105
+ getErrorPage: () => ({ title: "Error", kind: "error" }),
106
+ async renderApp(page) {
107
+ const html = await renderToString(createSSRApp(App, { page }));
108
+ return { html, head: `<title>${page.title}</title>`, css: "" };
109
+ },
110
+ });
111
+
112
+ export { serializeServerData };
113
+ ```
114
+
115
+ ## Adapters
116
+
117
+ | Adapter | Target |
118
+ | -------------- | -------------------------- |
119
+ | `"node"` | Standalone Node.js server |
120
+ | `"vercel"` | Vercel Build Output API v3 |
121
+ | `"cloudflare"` | Cloudflare Workers |
122
+ | `"netlify"` | Netlify Functions v2 |
123
+ | `"static"` | Pre-rendered static files |
124
+ | `"auto"` | Auto-detect at build time |
125
+
126
+ ## Entry Points
127
+
128
+ | Import | Contents |
129
+ | ------------------------- | ------------------------------------------ |
130
+ | `@finesoft/front` | Everything (core + browser + SSR + server) |
131
+ | `@finesoft/front/browser` | Browser-only (no server code) |
132
+
133
+ ## License
134
+
135
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finesoft/front",
3
- "version": "0.1.46",
3
+ "version": "0.1.47",
4
4
  "description": "Full-stack framework: router, DI, actions, SSR, and server — all in one package",
5
5
  "license": "MIT",
6
6
  "files": [