@seip/bluebird-js 0.2.0 → 0.2.2
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 +5 -1
- package/README.md +64 -0
- package/app/resources/html/layouts/main.html +2 -1
- package/app/resources/html/table.html +15 -0
- package/app/resources/layouts/AppLayout.jsx +4 -1
- package/app/resources/pages/Dashboard.jsx +27 -32
- package/app/resources/pages/TableDemo.jsx +85 -0
- package/app/resources/routes.jsx +5 -0
- package/app/resources/spa.js +6 -0
- package/app/routes/api.js +44 -0
- package/app/routes/web.js +31 -1
- package/core/cache.js +17 -0
- package/core/cli/migrate.js +57 -31
- package/core/cli/route.js +8 -7
- package/core/index.d.ts +1288 -1286
- package/core/react/client/api.js +2 -0
- package/core/react/client/components.js +4 -1
- package/core/react/client/datatable.js +595 -0
- package/core/react/client/i18n.js +102 -0
- package/core/react/client/index.d.ts +66 -0
- package/core/react/client/index.js +1 -0
- package/package.json +1 -1
- package/public/js/bluebird.js +732 -6
- package/templates/_base/app/resources/html/layouts/main.html +1 -1
package/core/cli/route.js
CHANGED
|
@@ -36,7 +36,7 @@ class RouteCLI {
|
|
|
36
36
|
const singularName = routeName.endsWith("s") ? routeName.slice(0, -1) : routeName;
|
|
37
37
|
const pascalName = routeName.charAt(0).toUpperCase() + routeName.slice(1);
|
|
38
38
|
const routerVarName = `router${pascalName}`;
|
|
39
|
-
const basePath =
|
|
39
|
+
const basePath = `/api/${routeName}`;
|
|
40
40
|
|
|
41
41
|
const routesFolder = path.resolve(process.cwd(), "app/routes");
|
|
42
42
|
if (!fs.existsSync(routesFolder)) {
|
|
@@ -59,7 +59,10 @@ class RouteCLI {
|
|
|
59
59
|
const content = `import Router from "@seip/bluebird-js/core/router.js";
|
|
60
60
|
import Validator from "@seip/bluebird-js/core/validate.js";
|
|
61
61
|
import Cache from "@seip/bluebird-js/core/cache.js";
|
|
62
|
-
|
|
62
|
+
import Csrf from "@seip/bluebird-js/core/csrf.js";
|
|
63
|
+
${authImport}
|
|
64
|
+
const ${routerVarName} = new Router("${basePath}");
|
|
65
|
+
${routerVarName}.use(Csrf.middleware());
|
|
63
66
|
|
|
64
67
|
const ${singularName}Schema = {
|
|
65
68
|
name: { required: true, min: 2, max: 255 },
|
|
@@ -81,7 +84,7 @@ ${routerVarName}.get("/:id", Cache.middleware(60), (req, res) => {
|
|
|
81
84
|
${routerVarName}.post("/", ${authProtect}validate${pascalName}.middleware(), async (req, res) => {
|
|
82
85
|
const data = req.body;
|
|
83
86
|
|
|
84
|
-
await Cache.
|
|
87
|
+
await Cache.invalidateRoute("${basePath}");
|
|
85
88
|
|
|
86
89
|
res.created({ ${singularName}: data }, "${pascalName} created successfully");
|
|
87
90
|
});
|
|
@@ -90,8 +93,7 @@ ${routerVarName}.put("/:id", ${authProtect}validate${pascalName}.middleware(), a
|
|
|
90
93
|
const { id } = req.params;
|
|
91
94
|
const data = req.body;
|
|
92
95
|
|
|
93
|
-
await Cache.
|
|
94
|
-
await Cache.delete(\`${basePath}/\${id}\`);
|
|
96
|
+
await Cache.invalidateRoute("${basePath}");
|
|
95
97
|
|
|
96
98
|
res.ok({ ${singularName}: { id, ...data } }, "${pascalName} updated successfully");
|
|
97
99
|
});
|
|
@@ -99,8 +101,7 @@ ${routerVarName}.put("/:id", ${authProtect}validate${pascalName}.middleware(), a
|
|
|
99
101
|
${routerVarName}.delete("/:id", ${authProtect}async (req, res) => {
|
|
100
102
|
const { id } = req.params;
|
|
101
103
|
|
|
102
|
-
await Cache.
|
|
103
|
-
await Cache.delete(\`${basePath}/\${id}\`);
|
|
104
|
+
await Cache.invalidateRoute("${basePath}");
|
|
104
105
|
|
|
105
106
|
res.ok({ id }, "${pascalName} deleted successfully");
|
|
106
107
|
});
|