mdkcontroller 1.0.9 → 1.0.11

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.
Files changed (3) hide show
  1. package/demoApp.js +6 -2
  2. package/main.js +9 -3
  3. package/package.json +3 -2
package/demoApp.js CHANGED
@@ -2,8 +2,12 @@
2
2
  import {Router} from "express";
3
3
  // import svInstance from "mdkcontroller";
4
4
 
5
-
6
- const _sv = await svInstance("khanhnbd");
5
+ const cfg = {
6
+ redirectHome: function (req, res) {
7
+ res.redirect("/pages/home");
8
+ }
9
+ }
10
+ const _sv = await svInstance("khanhnbd", cfg);
7
11
  const app = _sv.server;
8
12
  const db = _sv.database;
9
13
  const authCrypt = _sv.authen;
package/main.js CHANGED
@@ -13,7 +13,7 @@ import {fileURLToPath} from "url";
13
13
  import path from 'path';
14
14
  // import {privateKey, encodeMini} from "./dk_modules/dkvar.js";
15
15
 
16
- export default async function (appname) {
16
+ export default async function (appname, cfgHandler = {}) {
17
17
 
18
18
  const __filename = fileURLToPath(import.meta.url);
19
19
  const __rootDirPath = path.dirname(__filename).toLowerCase();
@@ -30,7 +30,13 @@ export default async function (appname) {
30
30
 
31
31
  app.use((req, res, next) => {
32
32
  res.setHeader('Cache-Control', 'no-store');
33
- if (req.url === "/") res.redirect("/pages");
33
+ if (req.url === "/") {
34
+ if (cfgHandler.redirectHome) {
35
+ cfgHandler.redirectHome(req, res);
36
+ } else {
37
+ res.redirect("/pages");
38
+ }
39
+ }
34
40
  next();
35
41
  });
36
42
 
@@ -39,7 +45,7 @@ export default async function (appname) {
39
45
  switch (resultValidate) {
40
46
  case 1:
41
47
  if (req.path.toLowerCase().indexOf("/cores/login/") >= 0) {
42
- res.redirect("/pages");
48
+ res.redirect("/");
43
49
  return;
44
50
  }
45
51
  break;
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "socket.io": "^4.7.2"
11
11
  },
12
12
  "name": "mdkcontroller",
13
- "version": "1.0.9",
13
+ "version": "1.0.11",
14
14
  "keywords": [],
15
15
  "author": "KHANHNBD <khanh272421@gmail.com>",
16
16
  "license": "ISC",
@@ -24,6 +24,7 @@
24
24
  "demoApp.js",
25
25
  "main.js",
26
26
  "Cores/",
27
- "dk_modules/"
27
+ "dk_modules/",
28
+ "Pagesa/"
28
29
  ]
29
30
  }