adminizer 4.1.0-build.33 → 4.1.0-build.34

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.
@@ -12,6 +12,11 @@ import { ViteDevServer } from 'vite';
12
12
  import { MenuHelper } from "../helpers/menuHelper";
13
13
  import { ControlsHandler } from "./v4/controls/ControlsHandler";
14
14
  export declare class Adminizer {
15
+ /**
16
+ * If you convey this default Middleware, it will add it to the very top of the router,
17
+ * and will contact each request
18
+ */
19
+ defaultMiddleware: MiddlewareType;
15
20
  app: Express;
16
21
  config: AdminpanelConfig;
17
22
  private readonly _emitter;
package/lib/Adminizer.js CHANGED
@@ -31,6 +31,13 @@ import { bindControls } from "../system/bindControls";
31
31
  import { ControlsHandler } from "./v4/controls/ControlsHandler";
32
32
  import { v4 as uuid } from "uuid";
33
33
  export class Adminizer {
34
+ // Preconfigures
35
+ /**
36
+ * If you convey this default Middleware, it will add it to the very top of the router,
37
+ * and will contact each request
38
+ */
39
+ defaultMiddleware;
40
+ // Instances
34
41
  app;
35
42
  config;
36
43
  _emitter;
@@ -43,6 +50,7 @@ export class Adminizer {
43
50
  widgetHandler;
44
51
  vite;
45
52
  controlsHandler;
53
+ // Constants
46
54
  jwtSecret = process.env.JWT_SECRET ?? uuid();
47
55
  static logger = winston.createLogger({
48
56
  level: process.env.LOG_LEVEL ?? "debug",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "adminizer",
3
3
  "type": "module",
4
- "version": "4.1.0-build.33",
4
+ "version": "4.1.0-build.34",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "vitest --reporter verbose",
package/system/Router.js CHANGED
@@ -28,6 +28,11 @@ export default class Router {
28
28
  Adminizer.log.error(`This method allowed for run only one time`);
29
29
  return;
30
30
  }
31
+ if (typeof adminizer.defaultMiddleware === 'function' &&
32
+ adminizer.defaultMiddleware.length >= 3 &&
33
+ adminizer.defaultMiddleware.length <= 4) {
34
+ adminizer.app.use(adminizer.defaultMiddleware);
35
+ }
31
36
  /**
32
37
  * List or one policy that should be bound to actions
33
38
  * @type {MiddlewareType[]}
@@ -146,7 +151,7 @@ export default class Router {
146
151
  /**
147
152
  * Create a default dashboard
148
153
  */
149
- if (Boolean(adminizer.config.dashboard)) {
154
+ if (adminizer.config.dashboard) {
150
155
  adminizer.app.all(adminizer.config.routePrefix, adminizer.policyManager.bindPolicies(policies, _dashboard));
151
156
  }
152
157
  else {