@seip/bluebird-js 0.1.6 → 0.2.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 (152) hide show
  1. package/.vscode/extensions.json +7 -7
  2. package/.vscode/settings.json +10 -10
  3. package/AGENTS.md +266 -116
  4. package/README.md +258 -245
  5. package/app/models/user.js +19 -0
  6. package/app/resources/html/home.html +137 -0
  7. package/app/resources/html/layouts/main.html +54 -0
  8. package/app/resources/html/notFound.html +14 -0
  9. package/app/resources/html/terms.html +46 -0
  10. package/app/resources/index.html +27 -0
  11. package/app/resources/layouts/AppLayout.jsx +89 -0
  12. package/app/resources/main.jsx +18 -0
  13. package/app/resources/pages/Dashboard.jsx +98 -0
  14. package/app/resources/pages/Home.jsx +140 -0
  15. package/app/resources/pages/Login.jsx +35 -0
  16. package/app/resources/pages/NotFound.jsx +16 -0
  17. package/app/resources/pages/Register.jsx +55 -0
  18. package/app/resources/routes.jsx +54 -0
  19. package/app/resources/spa.js +67 -0
  20. package/app/resources/styles.css +9 -0
  21. package/app/routes/api.js +85 -50
  22. package/app/routes/auth.js +209 -0
  23. package/app/routes/web.js +49 -37
  24. package/core/ai.d.ts +151 -151
  25. package/core/ai.js +1071 -1051
  26. package/core/app.d.ts +2 -18
  27. package/core/app.js +978 -792
  28. package/core/auth.d.ts +2 -13
  29. package/core/auth.js +444 -326
  30. package/core/cli/backup.js +167 -167
  31. package/core/cli/build.js +37 -0
  32. package/core/cli/dev.js +155 -0
  33. package/core/cli/doctor.js +37 -2
  34. package/core/cli/export.js +191 -0
  35. package/core/cli/init.js +101 -332
  36. package/core/cli/nginx.js +1 -1
  37. package/core/cli/templates.js +139 -0
  38. package/core/cli/view.js +73 -136
  39. package/core/config.js +44 -2
  40. package/core/csrf.js +156 -24
  41. package/core/database.js +737 -684
  42. package/core/debug.js +1 -1
  43. package/core/html.js +8 -1
  44. package/core/index.d.ts +1286 -1431
  45. package/core/paths.js +55 -0
  46. package/core/ratelimit.js +10 -1
  47. package/core/react/client/api.js +237 -0
  48. package/core/react/client/auth.js +236 -0
  49. package/core/react/client/components.js +1321 -0
  50. package/core/react/client/i18n.js +338 -0
  51. package/core/react/client/index.d.ts +249 -0
  52. package/core/react/client/index.js +49 -0
  53. package/core/react/client/router.js +26 -0
  54. package/core/react/client/theme.css +512 -0
  55. package/core/render-cache.js +250 -212
  56. package/core/render.d.ts +25 -21
  57. package/core/render.js +613 -603
  58. package/core/router.d.ts +2 -3
  59. package/core/router.js +171 -171
  60. package/core/seo.js +10 -0
  61. package/core/spa.js +599 -0
  62. package/core/view-loader.js +81 -455
  63. package/core/vite-plugin.d.ts +18 -0
  64. package/core/vite-plugin.js +162 -0
  65. package/core/vite.js +250 -145
  66. package/index.js +22 -18
  67. package/jsconfig.json +5 -3
  68. package/package.json +114 -92
  69. package/production.md +8 -3
  70. package/public/js/bluebird.js +1160 -0
  71. package/templates/_auth/app/database.js +19 -0
  72. package/templates/_auth/app/models/user.js +22 -0
  73. package/templates/_auth/app/routes/auth-router.js +304 -0
  74. package/templates/_base/app/resources/html/layouts/main.html +55 -0
  75. package/templates/_base/app/resources/html/notFound.html +14 -0
  76. package/templates/_base/app/resources/index.html +27 -0
  77. package/templates/_base/app/resources/styles.css +9 -0
  78. package/templates/api/app/models/note.js +18 -0
  79. package/templates/api/app/routes/api.js +82 -0
  80. package/templates/api/app/routes/auth.js +11 -0
  81. package/templates/api/index.js +19 -0
  82. package/templates/api/template.json +13 -0
  83. package/templates/auth/app/mail.js +11 -0
  84. package/templates/auth/app/models/password_reset.js +18 -0
  85. package/templates/auth/app/resources/html/home.html +21 -0
  86. package/templates/auth/app/resources/html/partials/nav.html +2 -0
  87. package/templates/auth/app/resources/layouts/AppLayout.jsx +60 -0
  88. package/templates/auth/app/resources/main.jsx +18 -0
  89. package/templates/auth/app/resources/pages/Dashboard.jsx +51 -0
  90. package/templates/auth/app/resources/pages/ForgotPassword.jsx +34 -0
  91. package/templates/auth/app/resources/pages/Login.jsx +36 -0
  92. package/templates/auth/app/resources/pages/NotFound.jsx +16 -0
  93. package/templates/auth/app/resources/pages/Profile.jsx +99 -0
  94. package/templates/auth/app/resources/pages/Register.jsx +50 -0
  95. package/templates/auth/app/resources/pages/ResetPassword.jsx +50 -0
  96. package/templates/auth/app/resources/routes.jsx +54 -0
  97. package/templates/auth/app/resources/spa.js +29 -0
  98. package/templates/auth/app/routes/api.js +17 -0
  99. package/templates/auth/app/routes/auth.js +13 -0
  100. package/templates/auth/app/routes/web.js +21 -0
  101. package/templates/auth/index.js +19 -0
  102. package/templates/auth/template.json +15 -0
  103. package/templates/blank/app/models/.gitkeep +0 -0
  104. package/templates/blank/app/resources/html/home.html +27 -0
  105. package/templates/blank/app/resources/html/partials/nav.html +1 -0
  106. package/templates/blank/app/resources/main.jsx +16 -0
  107. package/templates/blank/app/resources/pages/Home.jsx +42 -0
  108. package/templates/blank/app/resources/pages/NotFound.jsx +27 -0
  109. package/templates/blank/app/resources/routes.jsx +15 -0
  110. package/templates/blank/app/resources/spa.js +24 -0
  111. package/templates/blank/app/routes/api.js +11 -0
  112. package/templates/blank/app/routes/web.js +21 -0
  113. package/templates/blank/index.js +13 -0
  114. package/templates/blank/template.json +12 -0
  115. package/templates/blog/app/lib/blog.js +149 -0
  116. package/templates/blog/app/models/post.js +22 -0
  117. package/templates/blog/app/resources/html/home.html +28 -0
  118. package/templates/blog/app/resources/html/not-found.html +5 -0
  119. package/templates/blog/app/resources/html/partials/nav.html +2 -0
  120. package/templates/blog/app/resources/html/partials/post-card.html +9 -0
  121. package/templates/blog/app/resources/html/post.html +8 -0
  122. package/templates/blog/app/resources/layouts/AdminLayout.jsx +54 -0
  123. package/templates/blog/app/resources/main.jsx +18 -0
  124. package/templates/blog/app/resources/pages/Login.jsx +31 -0
  125. package/templates/blog/app/resources/pages/NotFound.jsx +16 -0
  126. package/templates/blog/app/resources/pages/PostEditor.jsx +51 -0
  127. package/templates/blog/app/resources/pages/Posts.jsx +83 -0
  128. package/templates/blog/app/resources/pages/Register.jsx +43 -0
  129. package/templates/blog/app/resources/routes.jsx +51 -0
  130. package/templates/blog/app/resources/spa.js +25 -0
  131. package/templates/blog/app/resources/styles.css +40 -0
  132. package/templates/blog/app/routes/api.js +77 -0
  133. package/templates/blog/app/routes/auth.js +10 -0
  134. package/templates/blog/app/routes/web.js +114 -0
  135. package/templates/blog/index.js +21 -0
  136. package/templates/blog/template.json +14 -0
  137. package/vite.config.js +11 -0
  138. package/app/views/about.jsx +0 -98
  139. package/app/views/components/Header.jsx +0 -42
  140. package/app/views/components/LiveCounter.jsx +0 -66
  141. package/app/views/dashboard.jsx +0 -300
  142. package/app/views/index.jsx +0 -123
  143. package/app/views/layouts/main/view.jsx +0 -201
  144. package/app/views/legal/terms.html +0 -29
  145. package/app/views/login.jsx +0 -141
  146. package/core/actions.d.ts +0 -4
  147. package/core/actions.js +0 -329
  148. package/core/jsx.d.ts +0 -38
  149. package/core/jsx.js +0 -1432
  150. package/core/vite.d.ts +0 -3
  151. package/public/js/bluebird-client.js +0 -3161
  152. package/public/js/tailwind.js +0 -8
@@ -0,0 +1,43 @@
1
+ import { Card, Form, Input, Link, SubmitButton, useAuth } from "@seip/bluebird-js/react";
2
+
3
+ /**
4
+ * One-time admin registration. The server closes registration once the first account exists.
5
+ */
6
+ export default function Register() {
7
+ const { register, registerEnabled } = useAuth();
8
+
9
+ if (!registerEnabled) {
10
+ return (
11
+ <div className="mx-auto max-w-md py-6">
12
+ <Card title="Registration closed" description="The admin account already exists.">
13
+ <Link to="/login" className="text-sm font-semibold text-foreground underline-offset-4 hover:underline">
14
+ Back to sign in
15
+ </Link>
16
+ </Card>
17
+ </div>
18
+ );
19
+ }
20
+
21
+ return (
22
+ <div className="mx-auto max-w-md py-6">
23
+ <Card variant="glass" title="Create the admin account" description="This account will own and manage the blog.">
24
+ <Form onSubmitRequest={(values) => register(values)} successMessage="Admin account created" className="space-y-4">
25
+ <Input name="name" label="Name" autoComplete="name" required />
26
+ <Input name="email" type="email" label="Email" autoComplete="email" required />
27
+ <Input
28
+ name="password"
29
+ type="password"
30
+ label="Password"
31
+ hint="At least 8 characters"
32
+ autoComplete="new-password"
33
+ minLength={8}
34
+ required
35
+ />
36
+ <SubmitButton className="w-full" loadingText="Creating...">
37
+ Create account
38
+ </SubmitButton>
39
+ </Form>
40
+ </Card>
41
+ </div>
42
+ );
43
+ }
@@ -0,0 +1,51 @@
1
+ import { Suspense, lazy } from "react";
2
+ import { Navigate } from "react-router";
3
+ import { GuestOnly, PageSkeleton, RequireAuth, createRouter } from "@seip/bluebird-js/react";
4
+ import AdminLayout from "./layouts/AdminLayout.jsx";
5
+
6
+ const Login = lazy(() => import("./pages/Login.jsx"));
7
+ const Register = lazy(() => import("./pages/Register.jsx"));
8
+ const Posts = lazy(() => import("./pages/Posts.jsx"));
9
+ const PostEditor = lazy(() => import("./pages/PostEditor.jsx"));
10
+ const NotFound = lazy(() => import("./pages/NotFound.jsx"));
11
+
12
+ /**
13
+ * Wraps lazy route components in a full-width Suspense fallback.
14
+ * @param {import('react').ReactNode} element
15
+ * @returns {import('react').ReactNode}
16
+ */
17
+ function withSuspense(element) {
18
+ return <Suspense fallback={<PageSkeleton />}>{element}</Suspense>;
19
+ }
20
+
21
+ /**
22
+ * Blog admin routes under `/app`: sign in, then manage posts (admin role only).
23
+ */
24
+ export const router = createRouter(
25
+ [
26
+ {
27
+ path: "/",
28
+ element: <AdminLayout />,
29
+ children: [
30
+ { index: true, element: <Navigate to="/posts" replace /> },
31
+ {
32
+ element: <GuestOnly redirectTo="/posts" />,
33
+ children: [
34
+ { path: "login", element: withSuspense(<Login />) },
35
+ { path: "register", element: withSuspense(<Register />) },
36
+ ],
37
+ },
38
+ {
39
+ element: <RequireAuth redirectTo="/login" roles={["admin"]} />,
40
+ children: [
41
+ { path: "posts", element: withSuspense(<Posts />) },
42
+ { path: "posts/new", element: withSuspense(<PostEditor />) },
43
+ { path: "posts/:id", element: withSuspense(<PostEditor />) },
44
+ ],
45
+ },
46
+ { path: "*", element: withSuspense(<NotFound />) },
47
+ ],
48
+ },
49
+ ],
50
+ { basename: "/app" }
51
+ );
@@ -0,0 +1,25 @@
1
+ /**
2
+ * React admin configuration shared by `routerWeb.spa(spa.mount, spa)` and `npx bluebird-js export`.
3
+ * The admin is private, so every route is `noindex`.
4
+ * @type {import('@seip/bluebird-js/core/index.js').SpaOptions & { mount: string }}
5
+ */
6
+ const spa = {
7
+ mount: "/app",
8
+ lang: "en",
9
+ titleTemplate: "%s — %%APP_TITLE%% Admin",
10
+ title: "Admin",
11
+ head: [{ tag: "link", rel: "icon", href: "/images/favicon.ico" }],
12
+ htmlAttrs: { class: "dark", "data-theme": "dark" },
13
+ bodyAttrs: {
14
+ class: "min-h-screen bg-app text-foreground antialiased",
15
+ },
16
+ skeleton: "app",
17
+ meta: {
18
+ "*": { title: "Admin", robots: "noindex, nofollow", skeleton: "app" },
19
+ login: { title: "Sign In", robots: "noindex, nofollow", skeleton: "auth" },
20
+ register: { title: "Create Admin Account", robots: "noindex, nofollow", skeleton: "auth" },
21
+ posts: { title: "Posts" },
22
+ },
23
+ };
24
+
25
+ export default spa;
@@ -0,0 +1,40 @@
1
+ @import "tailwindcss";
2
+ @source "./";
3
+ @source "../../public/js";
4
+
5
+ @custom-variant dark (&:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *));
6
+
7
+ @theme {
8
+ --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
9
+ }
10
+
11
+ @layer components {
12
+ .post-body {
13
+ @apply space-y-5 text-base leading-relaxed text-foreground/90;
14
+ }
15
+ .post-body h2 {
16
+ @apply pt-4 text-2xl font-semibold tracking-tight text-foreground;
17
+ }
18
+ .post-body h3,
19
+ .post-body h4 {
20
+ @apply pt-2 text-xl font-semibold tracking-tight text-foreground;
21
+ }
22
+ .post-body a {
23
+ @apply font-medium text-foreground underline decoration-muted-foreground/40 underline-offset-4 hover:decoration-foreground;
24
+ }
25
+ .post-body ul {
26
+ @apply list-disc space-y-1 pl-6;
27
+ }
28
+ .post-body blockquote {
29
+ @apply border-l-2 border-border pl-4 italic text-muted-foreground;
30
+ }
31
+ .post-body code {
32
+ @apply rounded-md bg-muted px-1.5 py-0.5 text-sm;
33
+ }
34
+ .post-body pre {
35
+ @apply overflow-x-auto rounded-2xl border border-border bg-muted p-4 text-sm;
36
+ }
37
+ .post-body pre code {
38
+ @apply bg-transparent p-0;
39
+ }
40
+ }
@@ -0,0 +1,77 @@
1
+ import Router from "@seip/bluebird-js/core/router.js";
2
+ import Auth from "@seip/bluebird-js/core/auth.js";
3
+ import Csrf from "@seip/bluebird-js/core/csrf.js";
4
+ import Validator from "@seip/bluebird-js/core/validate.js";
5
+ import Post from "../models/post.js";
6
+ import { postChanged, uniqueSlug } from "../lib/blog.js";
7
+
8
+ const routerApi = new Router("/api");
9
+ routerApi.use(Csrf.middleware());
10
+
11
+ const adminOnly = Auth.protect({ roles: "admin" });
12
+
13
+ const postValidator = new Validator(
14
+ {
15
+ title: { required: true, min: 3, max: 200 },
16
+ slug: { required: false, max: 200 },
17
+ excerpt: { required: false, max: 300 },
18
+ body: { required: true, min: 1 },
19
+ status: { required: true, in: ["draft", "published"] },
20
+ },
21
+ "en"
22
+ );
23
+
24
+ /**
25
+ * Picks the editable fields of a post from the request body.
26
+ * @param {Object} body
27
+ * @param {Object|null} existing - Current post when updating.
28
+ * @returns {Promise<Object>}
29
+ */
30
+ async function postFields(body, existing = null) {
31
+ const status = body.status === "published" ? "published" : "draft";
32
+ return {
33
+ title: String(body.title).trim(),
34
+ slug: await uniqueSlug(body.slug || body.title, existing?.id ?? null),
35
+ excerpt: String(body.excerpt || "").trim().slice(0, 300),
36
+ body: String(body.body),
37
+ status,
38
+ published_at: status === "published" ? existing?.published_at || new Date().toISOString() : existing?.published_at || null,
39
+ };
40
+ }
41
+
42
+ routerApi.get("/posts", adminOnly, async (req, res) => {
43
+ const result = await Post.paginate({ order: "updated_at DESC", page: req.query.page, limit: 20 });
44
+ res.paginate(result.data, { page: result.page, limit: result.limit, total: result.total, totalPages: result.totalPages });
45
+ });
46
+
47
+ routerApi.get("/posts/:id", adminOnly, async (req, res) => {
48
+ const post = await Post.find(req.params.id);
49
+ return post ? res.ok(post) : res.notFound("Post not found");
50
+ });
51
+
52
+ routerApi.post("/posts", adminOnly, postValidator.middleware(), async (req, res) => {
53
+ const fields = await postFields(req.body);
54
+ const id = await Post.create({ ...fields, user_id: req.user.id });
55
+ const post = await Post.find(id);
56
+ await postChanged(post);
57
+ res.created(post, "Post created");
58
+ });
59
+
60
+ routerApi.put("/posts/:id", adminOnly, postValidator.middleware(), async (req, res) => {
61
+ const existing = await Post.find(req.params.id);
62
+ if (!existing) return res.notFound("Post not found");
63
+ await Post.update(existing.id, await postFields(req.body, existing));
64
+ const post = await Post.find(existing.id);
65
+ await postChanged(post, existing.slug);
66
+ return res.ok(post, "Post saved");
67
+ });
68
+
69
+ routerApi.delete("/posts/:id", adminOnly, async (req, res) => {
70
+ const existing = await Post.find(req.params.id);
71
+ if (!existing) return res.notFound("Post not found");
72
+ await Post.delete(existing.id);
73
+ await postChanged(null, existing.slug);
74
+ return res.ok({ id: existing.id }, "Post deleted");
75
+ });
76
+
77
+ export default routerApi;
@@ -0,0 +1,10 @@
1
+ import { createAuthRouter } from "./auth-router.js";
2
+
3
+ /**
4
+ * `/api/auth/*` for the blog admin. Only the first account can register (it becomes the `admin`),
5
+ * after that registration closes automatically.
6
+ */
7
+ export default createAuthRouter({
8
+ register: "first-user",
9
+ firstUserAdmin: true,
10
+ });
@@ -0,0 +1,114 @@
1
+ import Router from "@seip/bluebird-js/core/router.js";
2
+ import Render from "@seip/bluebird-js/core/render.js";
3
+ import { escapeHtml } from "@seip/bluebird-js/core/html.js";
4
+ import Post from "../models/post.js";
5
+ import { formatDate, renderMarkdown } from "../lib/blog.js";
6
+ import spa from "../resources/spa.js";
7
+
8
+ const routerWeb = new Router("/", { seo: true });
9
+ const BLOG_TITLE = "%%APP_TITLE%%";
10
+ const BLOG_DESCRIPTION = "Articles and updates from %%APP_TITLE%%.";
11
+
12
+ /**
13
+ * Public origin used for canonical URLs, RSS, and JSON-LD.
14
+ * @param {import('express').Request} req
15
+ * @returns {string}
16
+ */
17
+ function origin(req) {
18
+ return (process.env.APP_URL || `${req.protocol}://${req.get("host")}`).replace(/\/$/, "");
19
+ }
20
+
21
+ /**
22
+ * Serializes JSON-LD safely for an inline `<script>` tag.
23
+ * @param {Object} data
24
+ * @returns {string}
25
+ */
26
+ function jsonLd(data) {
27
+ return `<script type="application/ld+json">${JSON.stringify(data).replace(/</g, "\\u003c")}</script>`;
28
+ }
29
+
30
+ routerWeb.get("/", async (req, res) => {
31
+ const page = Math.max(1, parseInt(req.query.page, 10) || 1);
32
+ const result = await Post.paginate({
33
+ where: { status: "published" },
34
+ order: "published_at DESC",
35
+ page,
36
+ limit: 10,
37
+ });
38
+
39
+ return Render.html(
40
+ res,
41
+ "home",
42
+ {
43
+ title: page > 1 ? `${BLOG_TITLE} — Page ${page}` : BLOG_TITLE,
44
+ description: BLOG_DESCRIPTION,
45
+ canonical: `${origin(req)}/${page > 1 ? `?page=${page}` : ""}`,
46
+ headHtml: `<link rel="alternate" type="application/rss+xml" title="${escapeHtml(BLOG_TITLE)}" href="/feed.xml">`,
47
+ posts: result.data.map((post) => ({ ...post, date: formatDate(post.published_at) })),
48
+ prevPage: page > 1 ? page - 1 : null,
49
+ nextPage: page < result.totalPages ? page + 1 : null,
50
+ },
51
+ { layout: "main", cache: 120, cacheQuery: ["page"] }
52
+ );
53
+ });
54
+
55
+ routerWeb.get("/blog/:slug", async (req, res) => {
56
+ const post = await Post.find({ slug: String(req.params.slug), status: "published" });
57
+ if (!post) {
58
+ res.status(404);
59
+ return Render.html(res, "not-found", { title: "Post not found" }, { layout: "main" });
60
+ }
61
+
62
+ const url = `${origin(req)}/blog/${post.slug}`;
63
+ return Render.html(
64
+ res,
65
+ "post",
66
+ {
67
+ title: `${post.title} — ${BLOG_TITLE}`,
68
+ description: post.excerpt || BLOG_DESCRIPTION,
69
+ canonical: url,
70
+ headHtml: jsonLd({
71
+ "@context": "https://schema.org",
72
+ "@type": "BlogPosting",
73
+ headline: post.title,
74
+ description: post.excerpt || undefined,
75
+ datePublished: post.published_at,
76
+ dateModified: post.updated_at || post.published_at,
77
+ mainEntityOfPage: url,
78
+ }),
79
+ post: { ...post, date: formatDate(post.published_at) },
80
+ bodyHtml: renderMarkdown(post.body),
81
+ },
82
+ { layout: "main", cache: 300 }
83
+ );
84
+ });
85
+
86
+ routerWeb.get("/feed.xml", async (req, res) => {
87
+ const base = origin(req);
88
+ const posts = await Post.all({ where: { status: "published" }, order: "published_at DESC", limit: 20 });
89
+ const items = posts
90
+ .map(
91
+ (post) => ` <item>
92
+ <title>${escapeHtml(post.title)}</title>
93
+ <link>${base}/blog/${post.slug}</link>
94
+ <guid>${base}/blog/${post.slug}</guid>
95
+ <pubDate>${new Date(post.published_at || post.created_at).toUTCString()}</pubDate>
96
+ <description>${escapeHtml(post.excerpt || "")}</description>
97
+ </item>`
98
+ )
99
+ .join("\n");
100
+
101
+ res.type("application/rss+xml").send(`<?xml version="1.0" encoding="UTF-8"?>
102
+ <rss version="2.0">
103
+ <channel>
104
+ <title>${escapeHtml(BLOG_TITLE)}</title>
105
+ <link>${base}/</link>
106
+ <description>${escapeHtml(BLOG_DESCRIPTION)}</description>
107
+ ${items}
108
+ </channel>
109
+ </rss>`);
110
+ });
111
+
112
+ routerWeb.spa(spa.mount, spa);
113
+
114
+ export default routerWeb;
@@ -0,0 +1,21 @@
1
+ import App from "@seip/bluebird-js/core/app.js";
2
+ import { ensureSchema } from "./app/database.js";
3
+ import { syncSitemap } from "./app/lib/blog.js";
4
+ import User from "./app/models/user.js";
5
+ import Post from "./app/models/post.js";
6
+ import routerApi from "./app/routes/api.js";
7
+ import routerAuth from "./app/routes/auth.js";
8
+ import routerWeb from "./app/routes/web.js";
9
+
10
+ await ensureSchema([User, Post]);
11
+ await syncSitemap();
12
+
13
+ /**
14
+ * Application entrypoint: public blog rendered with HTML {{ }} templates, React admin on `/app`.
15
+ */
16
+ const app = new App({
17
+ routes: [routerWeb, routerAuth, routerApi],
18
+ port: Number(process.env.PORT || 3000),
19
+ });
20
+
21
+ app.run();
@@ -0,0 +1,14 @@
1
+ {
2
+ "description": "SEO blog rendered with HTML {{ }} (list, post pages, RSS, sitemap) and a React admin on /app to write posts",
3
+ "layers": [
4
+ "_base",
5
+ "_auth"
6
+ ],
7
+ "client": true,
8
+ "database": "required",
9
+ "routes": [
10
+ "/, /blog/:slug HTML {{ }} blog (cached, JSON-LD, sitemap)",
11
+ "/feed.xml RSS feed",
12
+ "/app/* React admin (the first account becomes the admin)"
13
+ ]
14
+ }
package/vite.config.js ADDED
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from "vite";
2
+ import react from "@vitejs/plugin-react";
3
+ import tailwindcss from "@tailwindcss/vite";
4
+ import bluebird from "@seip/bluebird-js/vite";
5
+
6
+ /**
7
+ * Vite configuration (optional: Bluebird uses these same plugins when this file does not exist).
8
+ */
9
+ export default defineConfig({
10
+ plugins: [bluebird(), react(), tailwindcss()],
11
+ });
@@ -1,98 +0,0 @@
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 &amp; 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
-
@@ -1,42 +0,0 @@
1
- /**
2
- * Reusable Header component for dashboard and application views in React JSX.
3
- *
4
- * @param {Object} [props={}]
5
- * @param {string} [props.title]
6
- * @param {string} [props.subtitle]
7
- * @param {number} [props.count]
8
- * @param {Object} [props.user]
9
- * @param {Object} [props.props]
10
- */
11
- export default function Header(props = {}) {
12
- const actualProps = props.props || props;
13
- const title = actualProps.title || "Dashboard Overview";
14
- const subtitle =
15
- actualProps.subtitle || "Welcome to your high-performance Bluebird.js control center.";
16
- const count = actualProps.count !== undefined ? actualProps.count : 0;
17
- const userName = actualProps.user?.name || "Member";
18
-
19
- return (
20
- <header className="flex flex-col md:flex-row md:items-center justify-between gap-4 pb-6 mb-8 border-b border-slate-800">
21
- <div>
22
- <div className="flex items-center gap-3">
23
- <h1 className="text-2xl md:text-3xl font-bold tracking-tight text-slate-100">{title}</h1>
24
- <span className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-sky-500/10 text-sky-400 border border-sky-500/20">
25
- Active: <span id="header-counter-badge" className="ml-1 font-semibold">{count}</span>
26
- </span>
27
- </div>
28
- <p className="text-sm text-slate-400 mt-1">{subtitle}</p>
29
- </div>
30
- <div className="flex items-center gap-3">
31
- <div className="text-right hidden sm:block">
32
- <div className="text-xs text-slate-400">Logged in as</div>
33
- <div className="text-sm font-semibold text-slate-200">{userName}</div>
34
- </div>
35
- <div className="w-10 h-10 rounded-full bg-gradient-to-br from-sky-400 to-indigo-600 flex items-center justify-center text-slate-950 font-bold text-sm shadow-md">
36
- {userName.slice(0, 1).toUpperCase()}
37
- </div>
38
- </div>
39
- </header>
40
- );
41
- }
42
-
@@ -1,66 +0,0 @@
1
- import { useState, useEffect, useAction } from "@seip/bluebird-js/core/jsx.js";
2
- import { html } from "@seip/bluebird-js/core/html.js";
3
-
4
- /**
5
- * Reusable reactive Client Counter component for `<Client component={LiveCounter} ... />`.
6
- * Powered by Bluebird's zero-build client runtime with hooks (useState, useEffect, useAction, html).
7
- *
8
- * @param {Object} props
9
- * @param {number} [props.initial=7]
10
- * @param {string} [props.label="Client Component Counter"]
11
- * @returns {any}
12
- */
13
- export default function LiveCounter({ initial = 7, label = "Client Component Counter" }) {
14
- const [count, setCount] = useState(Number(initial) || 0);
15
- const [sync, isPending] = useAction("syncCount", {
16
- onSuccess(res) {
17
- if (res?.data?.message && typeof window.toast === "function") {
18
- window.toast({
19
- title: "Server Action Executed",
20
- description: res.data.message,
21
- type: "success",
22
- });
23
- }
24
- },
25
- });
26
-
27
- useEffect(() => {
28
- const badge = document.getElementById("header-counter-badge");
29
- if (badge) badge.textContent = String(count);
30
- }, [count]);
31
-
32
- return html`
33
- <div class="h-14 rounded-xl border border-slate-800 bg-slate-950/90 px-4 flex items-center justify-between">
34
- <div class="flex items-center gap-2.5">
35
- <span class="w-2 h-2 rounded-full ${isPending ? "bg-amber-400" : "bg-emerald-400"} animate-pulse"></span>
36
- <span class="text-xs font-medium text-slate-300">${label}:</span>
37
- <strong data-counter-val class="font-mono text-base text-sky-400">${count}</strong>
38
- </div>
39
- <div class="flex items-center gap-2">
40
- <button
41
- type="button"
42
- onClick=${() => setCount(Math.max(0, count - 1))}
43
- class="px-2.5 py-1 rounded-lg border border-slate-700 bg-slate-800 hover:bg-slate-700 text-xs font-semibold text-slate-200 transition-colors"
44
- >
45
- &minus;
46
- </button>
47
- <button
48
- type="button"
49
- onClick=${() => setCount(count + 1)}
50
- class="px-2.5 py-1 rounded-lg bg-sky-500 hover:bg-sky-400 text-xs font-bold text-slate-950 transition-colors"
51
- >
52
- &plus;
53
- </button>
54
- <button
55
- type="button"
56
- onClick=${() => sync({ count })}
57
- disabled=${isPending}
58
- class="px-2.5 py-1 rounded-lg border border-emerald-500/30 bg-emerald-500/15 hover:bg-emerald-500/25 text-xs font-semibold text-emerald-300 transition-colors disabled:opacity-50"
59
- >
60
- ${isPending ? "Syncing..." : "Sync Action"}
61
- </button>
62
- </div>
63
- </div>
64
- `;
65
- }
66
-