@bee.js/node 0.0.52 → 0.0.54
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/ORM/beeORM.js +1 -1
- package/lib/beeHive/create.js +56 -37
- package/package.json +1 -1
package/lib/ORM/beeORM.js
CHANGED
|
@@ -98,10 +98,10 @@ const modelSqlWhere = function (
|
|
|
98
98
|
callsWhere = []
|
|
99
99
|
) {
|
|
100
100
|
const q = quote;
|
|
101
|
+
const keys = parseArray(model.indexes?.keys || "");
|
|
101
102
|
|
|
102
103
|
let SQL = "";
|
|
103
104
|
let gWhere = model.globalWhere ? q(model.globalWhere, "()") : "";
|
|
104
|
-
let keys = parseArray(model.indexes.keys);
|
|
105
105
|
|
|
106
106
|
gWhere =
|
|
107
107
|
gWhere && middlewareParams ? stringBind(gWhere, middlewareParams) : "";
|
package/lib/beeHive/create.js
CHANGED
|
@@ -1,52 +1,71 @@
|
|
|
1
|
-
const express
|
|
2
|
-
const bodyParser = require(
|
|
3
|
-
const log
|
|
4
|
-
const headers
|
|
1
|
+
const express = require("express");
|
|
2
|
+
const bodyParser = require("body-parser");
|
|
3
|
+
const log = require("./log");
|
|
4
|
+
const headers = require("./headers");
|
|
5
5
|
|
|
6
|
+
module.exports = function (configs) {
|
|
7
|
+
const app = express();
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
app.use(
|
|
10
|
+
bodyParser.urlencoded({
|
|
11
|
+
limit: "10mb",
|
|
12
|
+
extended: true,
|
|
13
|
+
parameterLimit: 50000,
|
|
14
|
+
})
|
|
15
|
+
);
|
|
16
|
+
app.use(bodyParser.json({ extended: true, limit: "10mb" }));
|
|
17
|
+
app.use(bodyParser.raw());
|
|
18
|
+
app.use((req, res, next) => headers(req, res, next));
|
|
9
19
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
app.use(bodyParser.raw())
|
|
13
|
-
app.use((req, res, next) => headers(req, res, next))
|
|
20
|
+
log(`Creating ${configs.name || "Bee.js"}...`);
|
|
21
|
+
log("Optimizing model(s)...");
|
|
14
22
|
|
|
15
|
-
|
|
16
|
-
log('Optimizing model(s)...')
|
|
23
|
+
const models = configs.models;
|
|
17
24
|
|
|
18
|
-
|
|
25
|
+
Object.entries(models).forEach(([modelName, model]) => {
|
|
26
|
+
model.table = model.table || modelName;
|
|
19
27
|
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
Object.entries(model.schema).forEach(([fieldName, field]) => {
|
|
29
|
+
field.type = field.type.split(" ")[0];
|
|
30
|
+
});
|
|
31
|
+
});
|
|
22
32
|
|
|
23
|
-
|
|
33
|
+
log("Configuring database(s)...");
|
|
24
34
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
35
|
+
// TODO talvez usar {... {obj}, {otherObject} }
|
|
36
|
+
// TODO fazer loop em todos os dbs.
|
|
37
|
+
let defaultConfigs = {
|
|
38
|
+
default: {
|
|
39
|
+
connectionLimit: 100,
|
|
40
|
+
multipleStatements: true,
|
|
41
|
+
charset: "utf8",
|
|
42
|
+
engine: "InnoDB",
|
|
43
|
+
drive: "mysql",
|
|
44
|
+
port: 3306,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
30
47
|
|
|
31
|
-
|
|
48
|
+
configs.databases.default = Object.assign(
|
|
49
|
+
{},
|
|
50
|
+
defaultConfigs.default,
|
|
51
|
+
configs.databases.default
|
|
52
|
+
);
|
|
32
53
|
|
|
33
|
-
|
|
34
|
-
? true
|
|
35
|
-
: configs.debug
|
|
54
|
+
configs.dev = process.argv.includes("--dev") ? true : configs.debug;
|
|
36
55
|
|
|
37
|
-
|
|
56
|
+
configs.debug = configs.dev || configs.debug;
|
|
38
57
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
58
|
+
global.configs = configs;
|
|
59
|
+
global.models = models;
|
|
60
|
+
global.middlewares = configs.middlewares;
|
|
61
|
+
global.controllers = configs.controllers;
|
|
62
|
+
global.routes = configs.routes;
|
|
44
63
|
|
|
45
|
-
|
|
64
|
+
delete global.beeDBPool;
|
|
46
65
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
66
|
+
log(`${Object.keys(global.models).length} model(s)`);
|
|
67
|
+
log(`${Object.keys(global.controllers).length} controller(s)`);
|
|
68
|
+
log(`${Object.keys(global.middlewares).length - 1} middleware(s)`);
|
|
50
69
|
|
|
51
|
-
|
|
52
|
-
}
|
|
70
|
+
return app;
|
|
71
|
+
};
|