@bee.js/node 0.0.81 → 0.0.82
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/beeHive/create.js +22 -1
- package/package.json +2 -1
package/lib/beeHive/create.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const express = require("express");
|
|
2
|
+
const cors = require("cors");
|
|
2
3
|
const bodyParser = require("body-parser");
|
|
3
4
|
const log = require("./log");
|
|
4
5
|
const headers = require("./headers");
|
|
@@ -15,7 +16,27 @@ module.exports = function (configs) {
|
|
|
15
16
|
);
|
|
16
17
|
app.use(bodyParser.json({ extended: true, limit: "10mb" }));
|
|
17
18
|
app.use(bodyParser.raw());
|
|
18
|
-
|
|
19
|
+
|
|
20
|
+
if (configs.cors) app.use(cors(configs.cors));
|
|
21
|
+
|
|
22
|
+
log(`Creating cors...`);
|
|
23
|
+
|
|
24
|
+
app.options("*", (req, res) => {
|
|
25
|
+
res.header("Access-Control-Allow-Origin", req.headers.origin || "*");
|
|
26
|
+
|
|
27
|
+
for (const key in configs.headers) res.header(key, configs.headers[key]);
|
|
28
|
+
|
|
29
|
+
return res.sendStatus(200);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (configs.headers)
|
|
33
|
+
app.use((req, res, next) => {
|
|
34
|
+
for (const key in configs.headers) {
|
|
35
|
+
res.header(key, configs.headers[key]);
|
|
36
|
+
}
|
|
37
|
+
next();
|
|
38
|
+
});
|
|
39
|
+
else app.use((req, res, next) => headers(req, res, next));
|
|
19
40
|
|
|
20
41
|
log(`Creating ${configs.name || "Bee.js"}...`);
|
|
21
42
|
log("Optimizing model(s)...");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bee.js/node",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.82",
|
|
4
4
|
"description": "A JavaScript framework for making Node.js API´s",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"body-parser": "^1.19.0",
|
|
29
|
+
"cors": "^2.8.5",
|
|
29
30
|
"crypto-js": "^4.1.1",
|
|
30
31
|
"debug": "^4.1.1",
|
|
31
32
|
"express": "^4.17.1",
|