binhend 2.1.21 → 2.1.23
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/package.json
CHANGED
package/src/api/routes.js
CHANGED
|
@@ -5,6 +5,7 @@ const { server } = require('../server');
|
|
|
5
5
|
const cors = require('../middleware/cors');
|
|
6
6
|
const express = require('express');
|
|
7
7
|
const parseBasicAuthToken = require('../middleware/parseBasicAuthToken');
|
|
8
|
+
const parseCookies = require('../middleware/parseCookies');
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Maps routes recursively from a directory
|
|
@@ -52,6 +53,7 @@ async function buildRoutes(dirPath) {
|
|
|
52
53
|
router.use(express.urlencoded({ extended: false }));
|
|
53
54
|
router.use(express.json());
|
|
54
55
|
router.use(parseBasicAuthToken);
|
|
56
|
+
router.use(parseCookies);
|
|
55
57
|
|
|
56
58
|
try {
|
|
57
59
|
await mapRoutes(router, resolve(dirPath));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports = (request, response, next) => {
|
|
3
|
+
const header = request.headers.cookie;
|
|
4
|
+
const cookies = {};
|
|
5
|
+
|
|
6
|
+
header.split(';').forEach(cookie => {
|
|
7
|
+
const [key, ...val] = cookie.trim().split('=');
|
|
8
|
+
cookies[key] = decodeURIComponent(val.join('='));
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
request.cookies = cookies;
|
|
12
|
+
|
|
13
|
+
next();
|
|
14
|
+
};
|
|
@@ -31,7 +31,7 @@ function generate(sourceRootPath, outputRootPath, callbackDone) {
|
|
|
31
31
|
// not return here, but wait for next "if" statement to be copied to build folder, then return there.
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
if (fileExtension !== '.js') {
|
|
34
|
+
if (fileExtension !== '.js' && fileExtension !== '.mjs') {
|
|
35
35
|
// any files not JS (.css, .jpg, etc.) will be copied to build folder.
|
|
36
36
|
return cloneFileIfNew(fileSourcePath, fileOutputPath);
|
|
37
37
|
}
|
|
@@ -48,7 +48,7 @@ function generate(sourceRootPath, outputRootPath, callbackDone) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
function mapConfigValues(content) {
|
|
51
|
-
var matches = content.matchAll(/{\/\*(
|
|
51
|
+
var matches = content.matchAll(/{\/\*(.*?)\*\/}/g); // match all terms wrapped in format: {/*TERM*/}
|
|
52
52
|
|
|
53
53
|
var map = {};
|
|
54
54
|
|