@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
@@ -0,0 +1,80 @@
1
+ import { html } from "@seip/bluebird-js/core/html.js";
2
+
3
+ export const layout = "main";
4
+
5
+ export const head = () => ({
6
+ title: "Blue Bird Framework — High Performance Web Framework",
7
+ description: "Fast, structured, and opinionated Express.js framework for visual elegance and performance.",
8
+ });
9
+
10
+ /**
11
+ * Home page view module.
12
+ * @returns {import('@seip/bluebird-js/core/html.js').SafeHtml}
13
+ */
14
+ export default function IndexView() {
15
+ return html`
16
+ <section class="hero">
17
+ <h1 class="mt-3 text-gradient font-bold">Hello, Developer!</h1>
18
+ <p class="lead">
19
+ Blue Bird is a fast, structured, and opinionated Express.js framework for developers who want
20
+ visual elegance and performance with raw HTML and modern JavaScript.
21
+ </p>
22
+ <div class="hero-actions">
23
+ <a href="/about" role="button">About Us &rarr;</a>
24
+ <a href="https://github.com/seip25/bluebird-js" target="_blank" role="button" class="outline">GitHub</a>
25
+ </div>
26
+ </section>
27
+
28
+ <div class="mt-8">
29
+ <div class="grid cols-3 gap-4">
30
+ <article class="hover-glow">
31
+ <header>
32
+ <span class="badge badge-primary mb-2">Rendering</span>
33
+ <h3 class="text-gradient-blue">Zero-Build JS Views</h3>
34
+ </header>
35
+ <p>Direct tagged template literal rendering (html\`...\`) with automatic XSS escaping, nested layouts, and multi-tier caching.</p>
36
+ </article>
37
+
38
+ <article class="hover-glow">
39
+ <header>
40
+ <span class="badge badge-primary mb-2">Performance</span>
41
+ <h3 class="text-gradient-blue">Multi-Tier Caching</h3>
42
+ </header>
43
+ <p>Configurable TTL caching. Rendered pages and fragments are stored in L1 RAM LRU, L2 Redis, or L3 persistent file cache.</p>
44
+ </article>
45
+
46
+ <article class="hover-glow">
47
+ <header>
48
+ <span class="badge badge-primary mb-2">Security</span>
49
+ <h3 class="text-gradient-blue">JWT &amp; Route Security</h3>
50
+ </header>
51
+ <p>Secure cookie management, GCM-encrypted JWT tokens, custom security headers, and route rate limiting built-in.</p>
52
+ </article>
53
+
54
+ <article class="hover-glow">
55
+ <header>
56
+ <span class="badge badge-primary mb-2">Database</span>
57
+ <h3 class="text-gradient-blue">Unified DB Layer</h3>
58
+ </header>
59
+ <p>Built-in support for SQLite (native node:sqlite with WAL), MySQL, and PostgreSQL with connection pooling and caching.</p>
60
+ </article>
61
+
62
+ <article class="hover-glow">
63
+ <header>
64
+ <span class="badge badge-primary mb-2">DevOps</span>
65
+ <h3 class="text-gradient-blue">Production Ready</h3>
66
+ </header>
67
+ <p>Production cluster orchestration with PM2, native health checks, and smooth View Transitions SPA navigation.</p>
68
+ </article>
69
+
70
+ <article class="hover-glow">
71
+ <header>
72
+ <span class="badge badge-primary mb-2">Design</span>
73
+ <h3 class="text-gradient-blue">Pure Semantic CSS</h3>
74
+ </header>
75
+ <p>Clean semantic markup styled by <a href="https://seip25.github.io/Blue-bird-css/" target="_blank">Blue Bird CSS</a> with zero node compile steps.</p>
76
+ </article>
77
+ </div>
78
+ </div>
79
+ `;
80
+ }
@@ -0,0 +1,81 @@
1
+ import { html } from "@seip/bluebird-js/core/html.js";
2
+
3
+ /**
4
+ * Shared application layout for Bluebird.js.
5
+ * Provides the global HTML shell, header navigation, aside menu, and footer.
6
+ *
7
+ * @param {Object} context
8
+ * @param {import('@seip/bluebird-js/core/html.js').SafeHtml} context.body - Main content rendered by the view.
9
+ * @param {Object} context.head - Head metadata (title, description, canonical, etc.).
10
+ * @param {Object} context.ctx - Request context ({ req, res, user, locals }).
11
+ * @param {Object} context.data - View data props.
12
+ * @returns {import('@seip/bluebird-js/core/html.js').SafeHtml}
13
+ */
14
+ export default function MainLayout({ body, head = {}, ctx = {} }) {
15
+ const currentPath = ctx.req?.path || "/";
16
+ const user = ctx.user || ctx.req?.user;
17
+
18
+ const isActive = (path) =>
19
+ currentPath === path ? "active badge badge-glow px-3 py-3" : "";
20
+
21
+ return html`<!DOCTYPE html>
22
+ <html lang="en" data-theme="dark">
23
+ <head>
24
+ <meta charset="UTF-8" />
25
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
26
+ <title>${head.title || "Blue Bird Framework"}</title>
27
+ <link rel="canonical" href="${head.canonical || "https://seip25.github.io/Blue-bird/"}" />
28
+ <meta name="description" content="${head.description || "Blue Bird is a fast, structured, and opinionated Express.js framework for developers who want visual elegance and performance with raw HTML and CSS."}" />
29
+ <meta name="keywords" content="${head.keywords || "Blue Bird, Express.js, Node.js, Semantic CSS, Performance, Nginx, Redis"}" />
30
+ <meta name="author" content="Seip25" />
31
+ <link rel="icon" href="/images/favicon.ico" />
32
+ <link rel="stylesheet" href="/css/bluebird.min.css" />
33
+ <script src="/js/bluebird-client.js" defer></script>
34
+ </head>
35
+ <body data-layout="main">
36
+ <header>
37
+ <nav>
38
+ <a href="/" class="flex items-center gap-2">
39
+ <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="text-blue">
40
+ <path d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8" />
41
+ </svg>
42
+ <strong class="text-xl text-gradient">Blue Bird</strong>
43
+ </a>
44
+ </nav>
45
+ </header>
46
+
47
+ <main data-bb-outlet="true">
48
+ <aside>
49
+ <h4>Menu</h4>
50
+ <a href="/" class="${isActive("/")}">Home</a>
51
+ <a href="/about" class="${isActive("/about")}">About</a>
52
+ <a href="/login" class="${isActive("/login")}">Login</a>
53
+ <a href="/dashboard" class="${isActive("/dashboard")}">Dashboard</a>
54
+ <a href="https://seip25.github.io/Blue-bird" target="_blank">Blue bird</a>
55
+ <a href="https://seip25.github.io/Blue-bird-css/" target="_blank">Blue Bird CSS</a>
56
+ ${user
57
+ ? html`<a href="/logout" data-no-prefetch="true" role="button" class="btn-sm destructive mt-4">Sign Out</a>`
58
+ : html`<a href="https://github.com/seip25/bluebird-js" target="_blank" role="button" class="btn-sm outline">GitHub</a>`}
59
+ </aside>
60
+
61
+ <div class="page-content">
62
+ ${body}
63
+ </div>
64
+ </main>
65
+
66
+ <footer>
67
+ <div class="footer-content">
68
+ <p>Powered by <strong class="text-gradient">Blue Bird Framework</strong>
69
+ </p>
70
+ <div class="lang-switcher">
71
+ <a href="/" class="lang-link">Home</a>
72
+ <a href="/about" class="lang-link">About</a>
73
+ <a href="/login" class="lang-link">Login</a>
74
+ <a href="/dashboard" class="lang-link">Dashboard</a>
75
+ <a href="https://github.com/seip25/bluebird-js" target="_blank" class="github-star mt-2">&#9733; GitHub</a>
76
+ </div>
77
+ </div>
78
+ </footer>
79
+ </body>
80
+ </html>`;
81
+ }
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en" data-theme="dark">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Terms of Service — Blue Bird</title>
6
+ <link rel="stylesheet" href="/css/bluebird.min.css">
7
+ </head>
8
+ <body class="p-8">
9
+ <article class="card">
10
+ <header>
11
+ <h1 class="text-gradient">Terms of Service</h1>
12
+ <p class="text-muted">Served directly as raw, unparsed HTML via Render.html().</p>
13
+ </header>
14
+ <div class="mt-4">
15
+ <p>This static document demonstrates zero-overhead static HTML serving without template interpolation or server computation.</p>
16
+ </div>
17
+ </article>
18
+ </body>
19
+ </html>
@@ -0,0 +1,80 @@
1
+ import { html, script } from "@seip/bluebird-js/core/html.js";
2
+
3
+ export const layout = "main";
4
+
5
+ export const head = () => ({
6
+ title: "Sign In — Blue Bird Framework",
7
+ description: "Test native JWT authentication, encrypted cookies, and protected routes.",
8
+ });
9
+
10
+ /**
11
+ * Login page view module.
12
+ * @returns {import('@seip/bluebird-js/core/html.js').SafeHtml}
13
+ */
14
+ export default function LoginView() {
15
+ return html`
16
+ <section class="hero">
17
+ <h1 class="mt-3 text-gradient font-bold">Authentication Demo</h1>
18
+ <p class="lead">Test native AES-256-GCM JWT auth cookies, Auth.protect middleware, and seamless View Transitions.</p>
19
+ </section>
20
+
21
+ <div class="mt-6">
22
+ <div class="alert alert-info mb-6">
23
+ <div>
24
+ <strong class="alert-title">Interactive Auth Testing</strong>
25
+ <p class="alert-description">
26
+ Submit credentials below to generate an encrypted JWT session cookie with <code>Auth.login(res, user)</code>.
27
+ Try visiting <strong>/dashboard</strong> directly before and after logging in to verify the <code>Auth.protect({ redirect: "/login" })</code> middleware!
28
+ </p>
29
+ </div>
30
+ </div>
31
+
32
+ <article class="card">
33
+ <header class="card-header">
34
+ <h3 class="card-title">Sign In</h3>
35
+ <p class="card-description">Enter your test credentials below to start a secure session.</p>
36
+ </header>
37
+
38
+ <form action="/login" method="POST" id="loginForm">
39
+ <label for="email">Email Address</label>
40
+ <input type="email" id="email" name="email" value="alex@example.com" placeholder="alex@example.com" required />
41
+
42
+ <label for="password">Password</label>
43
+ <input type="password" id="password" name="password" value="password123" placeholder="••••••••" required />
44
+
45
+ <div class="flex items-center justify-between gap-4 mt-6">
46
+ <button type="submit" id="submitBtn" class="glow-blue">Sign In &rarr;</button>
47
+ <a href="/dashboard" role="button" class="outline">Try /dashboard (Protected)</a>
48
+ </div>
49
+ </form>
50
+ </article>
51
+
52
+ <article class="mt-6">
53
+ <header>
54
+ <h4 class="font-bold">What is being tested here?</h4>
55
+ </header>
56
+ <div class="grid cols-2 gap-4 mt-4">
57
+ <div class="card">
58
+ <h5 class="font-bold mb-2">1. Auth.protect Middleware</h5>
59
+ <p class="text-sm">When an unauthenticated client requests <code>/dashboard</code>, the server issues a 302 redirect to <code>/login</code>. The client router automatically follows the transition smoothly.</p>
60
+ </div>
61
+ <div class="card">
62
+ <h5 class="font-bold mb-2">2. Encrypted JWT Cookies</h5>
63
+ <p class="text-sm">Session cookies are encrypted with AES-256-GCM and marked HttpOnly and SameSite=Lax to protect against token exfiltration.</p>
64
+ </div>
65
+ </div>
66
+ </article>
67
+ </div>
68
+
69
+ <script>
70
+ const form = document.getElementById("loginForm");
71
+ const btn = document.getElementById("submitBtn");
72
+ form?.addEventListener("submit", () => {
73
+ if (btn) {
74
+ btn.textContent = "Signing In...";
75
+ btn.setAttribute("disabled", "true");
76
+ }
77
+ });
78
+ </script>
79
+ `;
80
+ }
package/core/app.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import App, {
2
+ AppError,
3
+ WebSocketManager,
4
+ AppOptions,
5
+ CorsOptions,
6
+ SecurityHeadersOptions,
7
+ AppStaticOptions,
8
+ } from "./index.js";
9
+ export default App;
10
+ export {
11
+ App,
12
+ AppError,
13
+ WebSocketManager,
14
+ AppOptions,
15
+ CorsOptions,
16
+ SecurityHeadersOptions,
17
+ AppStaticOptions,
18
+ };