@bee.js/node 0.0.100 → 0.0.103
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/WEB/route.js +1 -2
- package/lib/beeHive/routes.js +5 -12
- package/lib/beeHive/start.js +6 -1
- package/lib/beeHive/utils/bodyParsers.js +20 -0
- package/package.json +1 -1
package/lib/WEB/route.js
CHANGED
|
@@ -5,9 +5,8 @@ module.exports = async function(req, res, next, ignoreMiddlewares = false) {
|
|
|
5
5
|
log(`Route: ${req.method} ${req.originalUrl}`)
|
|
6
6
|
|
|
7
7
|
req.ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress
|
|
8
|
-
const isApiServiceRoute = req.routeConfig?.apiService === true;
|
|
9
8
|
|
|
10
|
-
if(!ignoreMiddlewares
|
|
9
|
+
if(!ignoreMiddlewares) {
|
|
11
10
|
|
|
12
11
|
let token = (req.headers.authorization || '').split(' ').slice(-1)[0]
|
|
13
12
|
let validSession = global.configs.middlewares.session //TODO
|
package/lib/beeHive/routes.js
CHANGED
|
@@ -4,12 +4,17 @@ const freeRoute = require("../WEB/freeRoute");
|
|
|
4
4
|
const log = require("./log");
|
|
5
5
|
const headers = require("./headers");
|
|
6
6
|
const bodyParser = require("body-parser");
|
|
7
|
+
const createBodyParsers = require("./utils/bodyParsers");
|
|
7
8
|
|
|
8
9
|
module.exports = function () {
|
|
9
10
|
if (!global.routes) return;
|
|
10
11
|
|
|
11
12
|
const router = express.Router();
|
|
12
13
|
const controllers = global.controllers;
|
|
14
|
+
const bodyParsers = createBodyParsers(bodyParser);
|
|
15
|
+
|
|
16
|
+
router.use(...bodyParsers);
|
|
17
|
+
router.use((req, res, next) => headers({ req, res, next, router, configs }));
|
|
13
18
|
|
|
14
19
|
global.routes?.forEach((r) => {
|
|
15
20
|
let controller =
|
|
@@ -35,18 +40,6 @@ module.exports = function () {
|
|
|
35
40
|
},
|
|
36
41
|
controller
|
|
37
42
|
);
|
|
38
|
-
|
|
39
|
-
router.use(
|
|
40
|
-
bodyParser.urlencoded({
|
|
41
|
-
limit: "20mb",
|
|
42
|
-
extended: true,
|
|
43
|
-
parameterLimit: 50000,
|
|
44
|
-
})
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
router.use(bodyParser.json({ extended: true, limit: "20mb" }));
|
|
48
|
-
router.use(bodyParser.raw());
|
|
49
|
-
router.use((req, res, next) => headers({ req, res, next, router, configs }));
|
|
50
43
|
});
|
|
51
44
|
|
|
52
45
|
log(`${Object.keys(global.routes).length} route(s) 222222
|
package/lib/beeHive/start.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const log = require("./log");
|
|
2
2
|
const beeDEV = require("../DEV/beeDEV");
|
|
3
3
|
const bodyParser = require('body-parser');
|
|
4
|
+
const createBodyParsers = require("./utils/bodyParsers");
|
|
4
5
|
const http = require("http");
|
|
5
6
|
const https = require("https");
|
|
6
7
|
const fs = require("fs");
|
|
@@ -10,7 +11,11 @@ const servers = { http: null, https: null };
|
|
|
10
11
|
|
|
11
12
|
module.exports = function (app, options = {}) {
|
|
12
13
|
if (process.argv.includes("--dev"))
|
|
13
|
-
app.post(
|
|
14
|
+
app.post(
|
|
15
|
+
"/beedev/:action",
|
|
16
|
+
...createBodyParsers(bodyParser),
|
|
17
|
+
beeDEV
|
|
18
|
+
);
|
|
14
19
|
|
|
15
20
|
const ports = (global.configs.port || global.configs.ports || 1987.443)
|
|
16
21
|
.toString()
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const BODY_LIMIT = "100mb";
|
|
2
|
+
const URLENCODED_PARSER_OPTIONS = {
|
|
3
|
+
limit: BODY_LIMIT,
|
|
4
|
+
extended: true,
|
|
5
|
+
parameterLimit: 50000,
|
|
6
|
+
};
|
|
7
|
+
const JSON_PARSER_OPTIONS = {
|
|
8
|
+
limit: BODY_LIMIT,
|
|
9
|
+
};
|
|
10
|
+
const RAW_PARSER_OPTIONS = {
|
|
11
|
+
limit: BODY_LIMIT,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
module.exports = function createBodyParsers(bodyParser) {
|
|
15
|
+
return [
|
|
16
|
+
bodyParser.urlencoded(URLENCODED_PARSER_OPTIONS),
|
|
17
|
+
bodyParser.json(JSON_PARSER_OPTIONS),
|
|
18
|
+
bodyParser.raw(RAW_PARSER_OPTIONS),
|
|
19
|
+
];
|
|
20
|
+
};
|