@seip/bluebird-js 0.1.7 → 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.
- package/AGENTS.md +726 -620
- package/README.md +615 -607
- package/app/models/user.js +19 -0
- package/app/resources/html/home.html +137 -0
- package/app/resources/html/layouts/main.html +54 -0
- package/app/resources/html/notFound.html +14 -0
- package/app/resources/html/terms.html +46 -0
- package/app/resources/index.html +27 -0
- package/app/resources/layouts/AppLayout.jsx +89 -0
- package/app/resources/main.jsx +18 -0
- package/app/resources/pages/Dashboard.jsx +98 -0
- package/app/resources/pages/Home.jsx +140 -0
- package/app/resources/pages/Login.jsx +35 -0
- package/app/resources/pages/NotFound.jsx +16 -0
- package/app/resources/pages/Register.jsx +55 -0
- package/app/resources/routes.jsx +54 -0
- package/app/resources/spa.js +67 -0
- package/app/resources/styles.css +9 -0
- package/app/routes/api.js +85 -50
- package/app/routes/auth.js +209 -0
- package/app/routes/web.js +59 -47
- package/core/ai.js +30 -10
- package/core/app.d.ts +2 -18
- package/core/app.js +987 -801
- package/core/auth.d.ts +2 -13
- package/core/auth.js +444 -326
- package/core/cli/build.js +37 -0
- package/core/cli/dev.js +155 -0
- package/core/cli/doctor.js +37 -2
- package/core/cli/export.js +191 -0
- package/core/cli/init.js +91 -322
- package/core/cli/nginx.js +1 -1
- package/core/cli/templates.js +139 -0
- package/core/cli/view.js +98 -161
- package/core/config.js +44 -2
- package/core/csrf.js +156 -24
- package/core/database.js +1184 -1131
- package/core/debug.js +1 -1
- package/core/html.js +8 -1
- package/core/index.d.ts +126 -310
- package/core/paths.js +55 -0
- package/core/ratelimit.js +10 -1
- package/core/react/client/api.js +237 -0
- package/core/react/client/auth.js +236 -0
- package/core/react/client/components.js +1321 -0
- package/core/react/client/i18n.js +338 -0
- package/core/react/client/index.d.ts +249 -0
- package/core/react/client/index.js +49 -0
- package/core/react/client/router.js +26 -0
- package/core/react/client/theme.css +512 -0
- package/core/render-cache.js +250 -212
- package/core/render.d.ts +25 -21
- package/core/render.js +738 -736
- package/core/router.d.ts +2 -3
- package/core/router.js +171 -171
- package/core/seo.js +10 -0
- package/core/spa.js +599 -0
- package/core/view-loader.js +155 -613
- package/core/vite-plugin.d.ts +18 -0
- package/core/vite-plugin.js +162 -0
- package/core/vite.js +250 -145
- package/index.js +22 -18
- package/jsconfig.json +5 -3
- package/package.json +114 -92
- package/production.md +8 -3
- package/public/js/bluebird.js +1160 -0
- package/templates/_auth/app/database.js +19 -0
- package/templates/_auth/app/models/user.js +22 -0
- package/templates/_auth/app/routes/auth-router.js +304 -0
- package/templates/_base/app/resources/html/layouts/main.html +55 -0
- package/templates/_base/app/resources/html/notFound.html +14 -0
- package/templates/_base/app/resources/index.html +27 -0
- package/templates/_base/app/resources/styles.css +9 -0
- package/templates/api/app/models/note.js +18 -0
- package/templates/api/app/routes/api.js +82 -0
- package/templates/api/app/routes/auth.js +11 -0
- package/templates/api/index.js +19 -0
- package/templates/api/template.json +13 -0
- package/templates/auth/app/mail.js +11 -0
- package/templates/auth/app/models/password_reset.js +18 -0
- package/templates/auth/app/resources/html/home.html +21 -0
- package/templates/auth/app/resources/html/partials/nav.html +2 -0
- package/templates/auth/app/resources/layouts/AppLayout.jsx +60 -0
- package/templates/auth/app/resources/main.jsx +18 -0
- package/templates/auth/app/resources/pages/Dashboard.jsx +51 -0
- package/templates/auth/app/resources/pages/ForgotPassword.jsx +34 -0
- package/templates/auth/app/resources/pages/Login.jsx +36 -0
- package/templates/auth/app/resources/pages/NotFound.jsx +16 -0
- package/templates/auth/app/resources/pages/Profile.jsx +99 -0
- package/templates/auth/app/resources/pages/Register.jsx +50 -0
- package/templates/auth/app/resources/pages/ResetPassword.jsx +50 -0
- package/templates/auth/app/resources/routes.jsx +54 -0
- package/templates/auth/app/resources/spa.js +29 -0
- package/templates/auth/app/routes/api.js +17 -0
- package/templates/auth/app/routes/auth.js +13 -0
- package/templates/auth/app/routes/web.js +21 -0
- package/templates/auth/index.js +19 -0
- package/templates/auth/template.json +15 -0
- package/templates/blank/app/models/.gitkeep +0 -0
- package/templates/blank/app/resources/html/home.html +27 -0
- package/templates/blank/app/resources/html/partials/nav.html +1 -0
- package/templates/blank/app/resources/main.jsx +16 -0
- package/templates/blank/app/resources/pages/Home.jsx +42 -0
- package/templates/blank/app/resources/pages/NotFound.jsx +27 -0
- package/templates/blank/app/resources/routes.jsx +15 -0
- package/templates/blank/app/resources/spa.js +24 -0
- package/templates/blank/app/routes/api.js +11 -0
- package/templates/blank/app/routes/web.js +21 -0
- package/templates/blank/index.js +13 -0
- package/templates/blank/template.json +12 -0
- package/templates/blog/app/lib/blog.js +149 -0
- package/templates/blog/app/models/post.js +22 -0
- package/templates/blog/app/resources/html/home.html +28 -0
- package/templates/blog/app/resources/html/not-found.html +5 -0
- package/templates/blog/app/resources/html/partials/nav.html +2 -0
- package/templates/blog/app/resources/html/partials/post-card.html +9 -0
- package/templates/blog/app/resources/html/post.html +8 -0
- package/templates/blog/app/resources/layouts/AdminLayout.jsx +54 -0
- package/templates/blog/app/resources/main.jsx +18 -0
- package/templates/blog/app/resources/pages/Login.jsx +31 -0
- package/templates/blog/app/resources/pages/NotFound.jsx +16 -0
- package/templates/blog/app/resources/pages/PostEditor.jsx +51 -0
- package/templates/blog/app/resources/pages/Posts.jsx +83 -0
- package/templates/blog/app/resources/pages/Register.jsx +43 -0
- package/templates/blog/app/resources/routes.jsx +51 -0
- package/templates/blog/app/resources/spa.js +25 -0
- package/templates/blog/app/resources/styles.css +40 -0
- package/templates/blog/app/routes/api.js +77 -0
- package/templates/blog/app/routes/auth.js +10 -0
- package/templates/blog/app/routes/web.js +114 -0
- package/templates/blog/index.js +21 -0
- package/templates/blog/template.json +14 -0
- package/vite.config.js +11 -0
- package/app/views/components/Header.jsx +0 -42
- package/app/views/components/LiveCounter.jsx +0 -67
- package/app/views/layouts/main/view.jsx +0 -201
- package/app/views/legal/terms.html +0 -29
- package/app/views/pages/about.jsx +0 -98
- package/app/views/pages/dashboard.jsx +0 -278
- package/app/views/pages/index.jsx +0 -123
- package/app/views/pages/login.jsx +0 -141
- package/core/actions.d.ts +0 -4
- package/core/actions.js +0 -355
- package/core/jsx.d.ts +0 -38
- package/core/jsx.js +0 -1597
- package/core/vite.d.ts +0 -3
- package/public/js/bluebird-client.js +0 -3265
- package/public/js/tailwind.js +0 -8
package/app/routes/web.js
CHANGED
|
@@ -1,47 +1,59 @@
|
|
|
1
|
-
import Router from "@seip/bluebird-js/core/router.js";
|
|
2
|
-
import Render from "@seip/bluebird-js/core/render.js";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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 spa from "../resources/spa.js";
|
|
5
|
+
|
|
6
|
+
const routerWeb = new Router("/", { seo: true });
|
|
7
|
+
|
|
8
|
+
routerWeb.get("/", (req, res) => {
|
|
9
|
+
const slides = [
|
|
10
|
+
{
|
|
11
|
+
badge: "HTML SSR",
|
|
12
|
+
title: "Fast HTML {{ }} Templates",
|
|
13
|
+
description: "Serve SEO-ready landings and storefronts directly from app/resources/html/ with layouts, partials, and {{if}} / {{each}}.",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
badge: "React SPA",
|
|
17
|
+
title: "React Router + Vite on /app",
|
|
18
|
+
description: "Client-side React workspace with zero SSR friction, per-URL SEO metadata, and a full-width skeleton in #root.",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
badge: "Auth & UI",
|
|
22
|
+
title: "Tailwind v4 Dark & Light Ready",
|
|
23
|
+
description: "Built-in AuthProvider with optional roles, vanilla data-* helpers, and reusable React UI components.",
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const features = [
|
|
28
|
+
{ name: "HTML SSR Engine", detail: "{{var}}, {{{raw}}}, {{if}}/{{else}}, {{each}}, {{> partial}}" },
|
|
29
|
+
{ name: "Router.spa()", detail: "Per-URL title, meta, keywords, JSON-LD, canonical, and skeleton" },
|
|
30
|
+
{ name: "Auth + Roles", detail: "AuthProvider synced with /api/auth/me and Auth.protect({ roles })" },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
const badges = ["Express 5", "HTML {{ }}", "Vite 7", "React 19", "React Router", "Tailwind v4"];
|
|
34
|
+
const highlightsHtml = badges
|
|
35
|
+
.map(
|
|
36
|
+
(label) =>
|
|
37
|
+
`<span class="badge bg-card/80 text-foreground backdrop-blur-sm">${escapeHtml(label)}</span>`
|
|
38
|
+
)
|
|
39
|
+
.join("");
|
|
40
|
+
|
|
41
|
+
return Render.html(
|
|
42
|
+
res,
|
|
43
|
+
"home",
|
|
44
|
+
{
|
|
45
|
+
title: "Bluebird.js — HTML SSR + React SPA",
|
|
46
|
+
description: "Express + HTML {{ }} SSR templates + React Router SPA with Vite and Tailwind CSS v4.",
|
|
47
|
+
slides,
|
|
48
|
+
features,
|
|
49
|
+
highlightsHtml,
|
|
50
|
+
},
|
|
51
|
+
{ layout: "main", cache: 300 }
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
routerWeb.get("/terms", Render.view("terms", { title: "Terms of Service" }, { cache: 86400, ttl: 86400 }));
|
|
56
|
+
|
|
57
|
+
routerWeb.spa(spa.mount, spa);
|
|
58
|
+
|
|
59
|
+
export default routerWeb;
|
package/core/ai.js
CHANGED
|
@@ -23,8 +23,29 @@ setInterval(() => {
|
|
|
23
23
|
}, 60000).unref();
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
26
|
+
* Checks whether an address belongs to a local or private network (where a reverse proxy would live).
|
|
27
|
+
* @param {string} address
|
|
28
|
+
* @returns {boolean}
|
|
29
|
+
*/
|
|
30
|
+
function isPrivateAddress(address) {
|
|
31
|
+
const ip = String(address || "").replace(/^::ffff:/, "");
|
|
32
|
+
return (
|
|
33
|
+
ip === "::1" ||
|
|
34
|
+
/^127./.test(ip) ||
|
|
35
|
+
/^10./.test(ip) ||
|
|
36
|
+
/^192.168./.test(ip) ||
|
|
37
|
+
/^172.(1[6-9]|2d|3[01])./.test(ip) ||
|
|
38
|
+
/^169.254./.test(ip) ||
|
|
39
|
+
/^f[cd][0-9a-f]{2}:/i.test(ip) ||
|
|
40
|
+
/^fe80:/i.test(ip)
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Extracts the client's real IP address across reverse proxies and CDNs, and cleans IPv6 mappings.
|
|
46
|
+
* Proxy headers (Cloudflare `cf-connecting-ip`, `true-client-ip`, Nginx `x-real-ip`, `x-forwarded-for`) are only
|
|
47
|
+
* trusted when the request arrives from a local/private reverse proxy; a client connecting directly cannot spoof
|
|
48
|
+
* them to dodge rate limits. On Express requests the address honors the app's `trust proxy` setting (`req.ip`).
|
|
28
49
|
* @param {import('express').Request|Object} req
|
|
29
50
|
* @returns {string}
|
|
30
51
|
*/
|
|
@@ -32,17 +53,16 @@ export function getClientIp(req) {
|
|
|
32
53
|
if (!req) return "127.0.0.1";
|
|
33
54
|
|
|
34
55
|
const headers = req.headers || {};
|
|
56
|
+
const peer = req.socket?.remoteAddress || req.connection?.remoteAddress || "";
|
|
57
|
+
const viaProxy = !peer || isPrivateAddress(peer);
|
|
58
|
+
const expressIp = req.app && typeof req.ip === "string" ? req.ip : "";
|
|
35
59
|
|
|
36
60
|
let ip =
|
|
37
|
-
headers["cf-connecting-ip"] ||
|
|
38
|
-
|
|
39
|
-
headers["x-
|
|
40
|
-
headers["x-forwarded-for"] ||
|
|
41
|
-
headers["x-client-ip"] ||
|
|
42
|
-
headers["x-cluster-client-ip"] ||
|
|
61
|
+
(viaProxy && (headers["cf-connecting-ip"] || headers["true-client-ip"] || headers["x-real-ip"])) ||
|
|
62
|
+
expressIp ||
|
|
63
|
+
(viaProxy && (headers["x-forwarded-for"] || headers["x-client-ip"] || headers["x-cluster-client-ip"])) ||
|
|
43
64
|
req.ip ||
|
|
44
|
-
|
|
45
|
-
req.connection?.remoteAddress ||
|
|
65
|
+
peer ||
|
|
46
66
|
"127.0.0.1";
|
|
47
67
|
|
|
48
68
|
if (typeof ip === "string") {
|
package/core/app.d.ts
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
};
|
|
1
|
+
export type { App, AppError, AppOptions, CorsOptions, SecurityHeadersOptions, ViteOptions } from "./index.d.ts";
|
|
2
|
+
export { App as default } from "./index.d.ts";
|