mdkcontroller 1.0.5 → 1.0.6
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/demoApp.js +27 -3
- package/package.json +1 -1
package/demoApp.js
CHANGED
|
@@ -1,8 +1,32 @@
|
|
|
1
1
|
import svInstance from "./main.js";
|
|
2
|
+
import {Router} from "express";
|
|
3
|
+
// import svInstance from "mdkcontroller";
|
|
2
4
|
|
|
3
5
|
const _sv = await svInstance("khanhnbd");
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
+
const app = _sv.server;
|
|
7
|
+
const db = _sv.database;
|
|
8
|
+
const authCrypt = _sv.authen;
|
|
9
|
+
|
|
10
|
+
const tbMovie = db.data.yourTableName ?? [];
|
|
11
|
+
|
|
12
|
+
const newRouterApi = Router();
|
|
13
|
+
newRouterApi.get("/demoFunction/gets", authCrypt.validate, (req, res) => {
|
|
14
|
+
res.json({message: "Get all users"});
|
|
15
|
+
});
|
|
16
|
+
newRouterApi.get('/demoPhase2/CallNonAuth', async (req, res) => {
|
|
17
|
+
const accessToken = req.cookies?.access_token;
|
|
18
|
+
if (accessToken) {
|
|
19
|
+
const indexToken = tbMovie.findIndex(f => true);
|
|
20
|
+
tbMovie.slice(indexToken, 1);
|
|
21
|
+
await db.write();
|
|
22
|
+
}
|
|
23
|
+
res.redirect('/login');
|
|
24
|
+
});
|
|
25
|
+
app.use("/api", newRouterApi);
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
const enc = await authCrypt.encrypt("khanhnbd");
|
|
29
|
+
const dec = await authCrypt.decrypt(enc);
|
|
6
30
|
console.log("khanhnbd => " + enc);
|
|
7
|
-
console.log("
|
|
31
|
+
console.log(enc + " will => " + dec);
|
|
8
32
|
_sv.startListen(8905);
|