adminizer 4.2.0-build.66 → 4.2.0-build.68
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/assets/{add-DOaZgoTz.js → add-CYZwY0d_.js} +1 -1
- package/assets/{add-form-BjackXJe.js → add-form-u6CCTy3n.js} +1 -1
- package/assets/app.js +2 -2
- package/assets/{catalog-DVyrGTNR.js → catalog-BpAw4095.js} +1 -1
- package/assets/{field-renderer-BHo944Cn.js → field-renderer-CFBp-IrC.js} +2 -2
- package/assets/{form-BXfnz6h5.js → form-COsFQmSc.js} +1 -1
- package/assets/{form-hP8sjbND.js → form-D7o1HNUE.js} +1 -1
- package/assets/{home-BD4MWmm9.js → home-DFu_vF7z.js} +2 -2
- package/assets/manifest.json +16 -16
- package/assets/{media-manager-CSB_XRcE.js → media-manager-C_Ql2aiI.js} +3 -3
- package/interfaces/adminpanelConfig.d.ts +3 -0
- package/lib/Adminizer.js +10 -6
- package/package.json +1 -1
- package/system/bindInertia.js +4 -0
- package/system/bindMediaManager.js +2 -1
- package/system/defaults.js +3 -0
package/lib/Adminizer.js
CHANGED
|
@@ -70,30 +70,33 @@ export class Adminizer {
|
|
|
70
70
|
}
|
|
71
71
|
getMiddleware() {
|
|
72
72
|
return (req, res, next) => {
|
|
73
|
-
// If a routePrefix is configured, only handle requests that match it.
|
|
74
73
|
try {
|
|
75
74
|
const prefix = (this.config && this.config.routePrefix) ? String(this.config.routePrefix) : '';
|
|
76
75
|
const normalizedPrefix = prefix.replace(/\/+/g, '/').replace(/\/+$/g, '');
|
|
77
76
|
if (normalizedPrefix) {
|
|
78
77
|
const url = req.url || req.originalUrl || '';
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
const conditions = [
|
|
79
|
+
url === normalizedPrefix,
|
|
80
|
+
url.startsWith(normalizedPrefix + '/')
|
|
81
|
+
];
|
|
82
|
+
if (process.env.IS_SAILS === undefined) {
|
|
83
|
+
conditions.push(url.startsWith('/public'));
|
|
84
|
+
}
|
|
85
|
+
if (!conditions.some(condition => condition)) {
|
|
81
86
|
return typeof next === 'function' ? next() : undefined;
|
|
82
87
|
}
|
|
83
88
|
}
|
|
84
89
|
}
|
|
85
90
|
catch (e) {
|
|
86
|
-
//
|
|
91
|
+
// fall back to handling the request
|
|
87
92
|
}
|
|
88
93
|
this.app(req, res, (err) => {
|
|
89
94
|
if (err) {
|
|
90
|
-
// eslint-disable-next-line no-console
|
|
91
95
|
console.error("Error in Adminizer", err);
|
|
92
96
|
res.writeHead(500, { 'Content-Type': 'text/plain' });
|
|
93
97
|
res.end('Internal Server Error');
|
|
94
98
|
}
|
|
95
99
|
else {
|
|
96
|
-
// If Adminizer didn't handle the route, let the rest of the stack try
|
|
97
100
|
if (typeof next === 'function') {
|
|
98
101
|
return next();
|
|
99
102
|
}
|
|
@@ -154,6 +157,7 @@ export class Adminizer {
|
|
|
154
157
|
set: configForms.set ?? defaultForms.set
|
|
155
158
|
}
|
|
156
159
|
};
|
|
160
|
+
console.log(this.config);
|
|
157
161
|
this.modelHandler = new ModelHandler();
|
|
158
162
|
// TODO: 'hot reload' unbind models & unbind forms
|
|
159
163
|
await bindModels(this);
|
package/package.json
CHANGED
package/system/bindInertia.js
CHANGED
|
@@ -17,6 +17,7 @@ export function bindInertia(adminizer) {
|
|
|
17
17
|
<script type="module" src="/@vite/client"></script>
|
|
18
18
|
<script type="module" src="/src/assets/js/app.tsx"></script>
|
|
19
19
|
<script>window.routePrefix = "${adminizer.config.routePrefix}"</script>
|
|
20
|
+
<script>window.isSails = ${process.env.IS_SAILS ? 'true' : 'false'};</script>
|
|
20
21
|
`;
|
|
21
22
|
}
|
|
22
23
|
else {
|
|
@@ -57,11 +58,14 @@ export function bindInertia(adminizer) {
|
|
|
57
58
|
});
|
|
58
59
|
// Route prefix script
|
|
59
60
|
const routePrefixScript = `<script>window.routePrefix = "${adminizer.config.routePrefix}";</script>`;
|
|
61
|
+
// For Sails JS
|
|
62
|
+
const isSails = `<script>window.isSails = ${process.env.IS_SAILS ? 'true' : 'false'};</script>`;
|
|
60
63
|
return `
|
|
61
64
|
${preloadLinks.join('\n')}
|
|
62
65
|
${stylesheets.join('\n')}
|
|
63
66
|
${scripts.join('\n')}
|
|
64
67
|
${routePrefixScript}
|
|
68
|
+
${isSails}
|
|
65
69
|
`;
|
|
66
70
|
}
|
|
67
71
|
};
|
|
@@ -15,7 +15,8 @@ export default function bindMediaManager(adminizer) {
|
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
// Bind media manager public folder
|
|
18
|
-
|
|
18
|
+
if (adminizer.config.bind?.public)
|
|
19
|
+
adminizer.app.use(`/public`, serveStatic(adminizer.config.mediamanager.fileStoragePath));
|
|
19
20
|
// Bind file icons
|
|
20
21
|
adminizer.app.use(`${adminizer.config.routePrefix}/fileicons`, serveStatic(path.join(import.meta.dirname, '../fileicons')));
|
|
21
22
|
}
|