ztechno_core 0.0.59 → 0.0.60
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/lib/express.d.ts +6 -0
- package/lib/express.js +18 -0
- package/package.json +3 -1
package/lib/express.d.ts
ADDED
package/lib/express.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.middleware = void 0;
|
|
4
|
+
function middleware() {
|
|
5
|
+
return async (req, res, next) => {
|
|
6
|
+
if (req.cookies === undefined) {
|
|
7
|
+
throw new Error(`Module 'cookie-parser' isn't initialized. Please use app.use(cookieParser())`);
|
|
8
|
+
}
|
|
9
|
+
if (req.cookies?.session === undefined) {
|
|
10
|
+
return next();
|
|
11
|
+
}
|
|
12
|
+
const auth = await userService.auth({ session: req.cookies?.session });
|
|
13
|
+
req.user = auth.user;
|
|
14
|
+
// TODO: Implement assertAdmin or something like that
|
|
15
|
+
next();
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.middleware = middleware;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ztechno_core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.60",
|
|
4
4
|
"description": "Core files for ztechno framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -38,7 +38,9 @@
|
|
|
38
38
|
"typescript": "^4.9.3"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
+
"@types/express": "^5.0.0",
|
|
41
42
|
"dom-parser": "^0.1.6",
|
|
43
|
+
"express": "^4.21.2",
|
|
42
44
|
"mysql": "^2.18.1",
|
|
43
45
|
"nodemailer": "^6.8.0",
|
|
44
46
|
"translate": "^1.4.1"
|