adminizer 4.1.0-build.32 → 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.
|
@@ -10,10 +10,10 @@ export class AccessRightsHelper {
|
|
|
10
10
|
if (!accessRightsToken.id || !accessRightsToken.name || !accessRightsToken.description || !accessRightsToken.department) {
|
|
11
11
|
throw new Error("Adminpanel > Can not register token: Missed one or more required parameters");
|
|
12
12
|
}
|
|
13
|
-
for (let
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
for (let i = 0; i < this._tokens.length; i++) {
|
|
14
|
+
if (this._tokens[i].id === accessRightsToken.id) {
|
|
15
|
+
this._tokens.splice(i, 1);
|
|
16
|
+
break;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
this._tokens.push(accessRightsToken);
|
package/lib/Adminizer.d.ts
CHANGED
|
@@ -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",
|
|
@@ -3,9 +3,6 @@ export class ModelHandler {
|
|
|
3
3
|
models = new Map();
|
|
4
4
|
add(modelName, modelInstance) {
|
|
5
5
|
const modelname = modelName.toLowerCase();
|
|
6
|
-
if (this.models.has(modelname)) {
|
|
7
|
-
throw new Error(`Model "${modelname}" is already registered.`);
|
|
8
|
-
}
|
|
9
6
|
this.models.set(modelname, modelInstance);
|
|
10
7
|
Adminizer.log.debug(`Model with name [${modelname}] was registered`);
|
|
11
8
|
}
|
package/package.json
CHANGED
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 (
|
|
154
|
+
if (adminizer.config.dashboard) {
|
|
150
155
|
adminizer.app.all(adminizer.config.routePrefix, adminizer.policyManager.bindPolicies(policies, _dashboard));
|
|
151
156
|
}
|
|
152
157
|
else {
|