@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/core/router.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export default
|
|
3
|
-
export { Router, RouterOptions };
|
|
1
|
+
export type { Router, RouterOptions, SpaMetaEntry, SpaOptions } from "./index.d.ts";
|
|
2
|
+
export { Router as default } from "./index.d.ts";
|
package/core/router.js
CHANGED
|
@@ -1,171 +1,171 @@
|
|
|
1
|
-
import express from "express";
|
|
2
|
-
import
|
|
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
|
-
* @param {
|
|
35
|
-
* @param {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
this.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
*
|
|
72
|
-
* }
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
*
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
*
|
|
105
|
-
* @param {
|
|
106
|
-
* @
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
this.router.
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
*
|
|
146
|
-
* @param {string}
|
|
147
|
-
* @param {
|
|
148
|
-
*/
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
*
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
*
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
export { Router };
|
|
171
|
-
export default Router;
|
|
1
|
+
import express from "express";
|
|
2
|
+
import Seo from "./seo.js";
|
|
3
|
+
import { createSpaMiddleware, registerSpaSeoRoutes } from "./spa.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Wraps route handlers to automatically catch async rejections and forward them to `next(err)`.
|
|
7
|
+
* @param {Function} fn - Handler function.
|
|
8
|
+
* @returns {Function} Wrapped handler.
|
|
9
|
+
*/
|
|
10
|
+
function wrapAsync(fn) {
|
|
11
|
+
if (typeof fn !== "function") return fn;
|
|
12
|
+
return (req, res, next) => {
|
|
13
|
+
try {
|
|
14
|
+
const result = fn(req, res, next);
|
|
15
|
+
if (result && typeof result.catch === "function") {
|
|
16
|
+
result.catch(next);
|
|
17
|
+
}
|
|
18
|
+
} catch (err) {
|
|
19
|
+
next(err);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Router wrapper class for handling Express routing, HTML views, and React SPAs.
|
|
26
|
+
* When created with `{ seo: true }`, static GET routes and SPA routes are indexed
|
|
27
|
+
* in `/sitemap.xml` and `/robots.txt`.
|
|
28
|
+
*/
|
|
29
|
+
class Router {
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new Router instance.
|
|
32
|
+
* @param {string} [path="/"] - Base path for this router.
|
|
33
|
+
* @param {Object} [options={}] - Router configuration options.
|
|
34
|
+
* @param {boolean} [options.seo=false] - Register static GET routes for sitemap generation.
|
|
35
|
+
* @param {string[]} [options.languages=[]] - Optional language prefixes for SEO routes.
|
|
36
|
+
*/
|
|
37
|
+
constructor(path = "/", options = {}) {
|
|
38
|
+
this.router = express.Router();
|
|
39
|
+
this.path = path;
|
|
40
|
+
this._seo = options.seo ?? false;
|
|
41
|
+
this._languages = options.languages || [];
|
|
42
|
+
this._hasSpa = false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Registers a middleware on this router.
|
|
47
|
+
* @param {...Function} middleware
|
|
48
|
+
*/
|
|
49
|
+
use(...middleware) {
|
|
50
|
+
const handlers = middleware.map(wrapAsync);
|
|
51
|
+
this.router.use(...handlers);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Registers a GET route handler.
|
|
56
|
+
* @param {string|RegExp} path
|
|
57
|
+
* @param {...Function} callback
|
|
58
|
+
*/
|
|
59
|
+
get(path, ...callback) {
|
|
60
|
+
if (this._seo && typeof path === "string") {
|
|
61
|
+
Seo.registerRoute(this.path, path, this._languages);
|
|
62
|
+
}
|
|
63
|
+
if (path === "/*" || path === "*") {
|
|
64
|
+
path = /.*/;
|
|
65
|
+
}
|
|
66
|
+
const handlers = callback.map(wrapAsync);
|
|
67
|
+
this.router.get(path, ...handlers);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Registers a POST route handler.
|
|
72
|
+
* @param {string|RegExp} path
|
|
73
|
+
* @param {...Function} callback
|
|
74
|
+
*/
|
|
75
|
+
post(path, ...callback) {
|
|
76
|
+
if (path === "/*" || path === "*") {
|
|
77
|
+
path = /.*/;
|
|
78
|
+
}
|
|
79
|
+
const handlers = callback.map(wrapAsync);
|
|
80
|
+
this.router.post(path, ...handlers);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Registers a PUT route handler.
|
|
85
|
+
* @param {string|RegExp} path
|
|
86
|
+
* @param {...Function} callback
|
|
87
|
+
*/
|
|
88
|
+
put(path, ...callback) {
|
|
89
|
+
const handlers = callback.map(wrapAsync);
|
|
90
|
+
this.router.put(path, ...handlers);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Registers a DELETE route handler.
|
|
95
|
+
* @param {string|RegExp} path
|
|
96
|
+
* @param {...Function} callback
|
|
97
|
+
*/
|
|
98
|
+
delete(path, ...callback) {
|
|
99
|
+
const handlers = callback.map(wrapAsync);
|
|
100
|
+
this.router.delete(path, ...handlers);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Registers a PATCH route handler.
|
|
105
|
+
* @param {string|RegExp} path
|
|
106
|
+
* @param {...Function} callback
|
|
107
|
+
*/
|
|
108
|
+
patch(path, ...callback) {
|
|
109
|
+
const handlers = callback.map(wrapAsync);
|
|
110
|
+
this.router.patch(path, ...handlers);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Registers an OPTIONS route handler.
|
|
115
|
+
* @param {string|RegExp} path
|
|
116
|
+
* @param {...Function} callback
|
|
117
|
+
*/
|
|
118
|
+
options(path, ...callback) {
|
|
119
|
+
const handlers = callback.map(wrapAsync);
|
|
120
|
+
this.router.options(path, ...handlers);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Mounts a client-rendered React SPA under `mountPath`, serving the `app/resources/index.html` shell with per-URL SEO metadata,
|
|
125
|
+
* JSON-LD, canonical tags, custom scripts/styles, and a full-width skeleton inside `#root`.
|
|
126
|
+
* @param {string} mountPath - Mount prefix (e.g. `"/app"` or `"/"`).
|
|
127
|
+
* @param {Object} [options={}] - SPA configuration and per-URL `meta` tree.
|
|
128
|
+
*/
|
|
129
|
+
spa(mountPath, options = {}) {
|
|
130
|
+
this._hasSpa = true;
|
|
131
|
+
const cleanMount = String(mountPath || "/").replace(/\/\*+$/, "") || "/";
|
|
132
|
+
const baseClean = this.path === "/" ? "" : this.path.replace(/\/$/, "");
|
|
133
|
+
const subClean = cleanMount === "/" ? "" : `/${cleanMount.replace(/^\/+|\/+$/g, "")}`;
|
|
134
|
+
const fullMount = `${baseClean}${subClean}` || "/";
|
|
135
|
+
|
|
136
|
+
if ((this._seo || options.seo === true) && options.seo !== false) {
|
|
137
|
+
registerSpaSeoRoutes(fullMount, options, this._languages);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const spaMiddleware = wrapAsync(createSpaMiddleware(this.path, cleanMount, options));
|
|
141
|
+
this.router.use(spaMiddleware);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Alias for `router.spa()`.
|
|
146
|
+
* @param {string} mountPath
|
|
147
|
+
* @param {Object} [options={}]
|
|
148
|
+
*/
|
|
149
|
+
SPA(mountPath, options = {}) {
|
|
150
|
+
return this.spa(mountPath, options);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Returns the underlying Express router instance.
|
|
155
|
+
* @returns {import('express').Router}
|
|
156
|
+
*/
|
|
157
|
+
getRouter() {
|
|
158
|
+
return this.router;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Returns the base path associated with this router.
|
|
163
|
+
* @returns {string}
|
|
164
|
+
*/
|
|
165
|
+
getPath() {
|
|
166
|
+
return this.path;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export { Router };
|
|
171
|
+
export default Router;
|
package/core/seo.js
CHANGED
|
@@ -38,6 +38,16 @@ class Seo {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Removes a path from the sitemap (e.g. an unpublished or deleted blog post).
|
|
43
|
+
* @param {string} fullPath - Absolute path such as `/blog/my-post`.
|
|
44
|
+
* @returns {boolean} Whether the path was registered.
|
|
45
|
+
*/
|
|
46
|
+
static unregisterRoute(fullPath) {
|
|
47
|
+
const clean = String(fullPath || "").trim();
|
|
48
|
+
return registeredSeoRoutes.delete(clean.startsWith("/") ? clean : `/${clean}`);
|
|
49
|
+
}
|
|
50
|
+
|
|
41
51
|
/**
|
|
42
52
|
* Returns all registered SEO route paths.
|
|
43
53
|
* @returns {string[]}
|