binhend 2.2.4 → 2.2.6
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/LICENSE +21 -0
- package/index.js +18 -26
- package/jsconfig.json +6 -3
- package/package.json +1 -1
- package/packages/core/src/server.js +12 -2
- package/packages/csd/package.json +1 -0
- package/packages/csd/src/controller.js +4 -4
- package/packages/csd/src/dao.js +25 -11
- package/packages/web/src/component.method.js +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Nguyễn Đức Bình
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/index.js
CHANGED
|
@@ -6,56 +6,48 @@
|
|
|
6
6
|
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const server = require('./packages/core/src/server');
|
|
10
|
+
const Router = require('./packages/core/src/Router');
|
|
11
|
+
const { routes } = require('./packages/core/src/routes');
|
|
10
12
|
|
|
11
|
-
const
|
|
13
|
+
const Bromise = require('./packages/utils/src/Bromise');
|
|
14
|
+
const HttpError = require('./packages/utils/src/HttpError');
|
|
15
|
+
const HttpCodes = require('./packages/utils/src/HttpCodes');
|
|
12
16
|
|
|
13
|
-
const {
|
|
17
|
+
const { HTTPS } = require('./packages/https/src/https');
|
|
14
18
|
|
|
15
|
-
const
|
|
19
|
+
const cors = require('./packages/middlewares/src/cors');
|
|
20
|
+
const trycatch = require('./packages/middlewares/src/trycatch');
|
|
16
21
|
|
|
17
22
|
const { config, ConfigLoader } = require('./packages/config/src/configuration');
|
|
18
23
|
|
|
19
|
-
const { WebBuild, binh } = require('./packages/web');
|
|
20
|
-
|
|
21
|
-
// const { create: CSD, Controller: CinCSD, Service: SinCSD, DAO: DinCSD } = require('./packages/csd/src/');
|
|
22
|
-
|
|
23
24
|
const CSD = require('./packages/csd/src/csd');
|
|
24
25
|
const CinCSD = require('./packages/csd/src/controller');
|
|
25
26
|
const SinCSD = require('./packages/csd/src/service');
|
|
26
27
|
const DinCSD = require('./packages/csd/src/dao');
|
|
27
28
|
|
|
28
|
-
const
|
|
29
|
+
const crypto = require('./packages/crypto/src/crypto');
|
|
30
|
+
const types = require('./packages/types/src/typeCheck');
|
|
31
|
+
const validation = require('./packages/validation/src/typeValidation');
|
|
29
32
|
|
|
30
|
-
const
|
|
33
|
+
const { WebBuild } = require('./packages/web/src/WebBuild');
|
|
34
|
+
const { binh } = require('./packages/web/src/component.method');
|
|
31
35
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// Run scripts
|
|
35
|
-
require('./packages/module-alias'); // for format: require('@/any/path')
|
|
36
|
+
//___ Run scripts ___//
|
|
37
|
+
require('./packages/module-alias'); //--- alias path '@' for requiring modules: require('@/any/path')
|
|
36
38
|
|
|
37
39
|
module.exports = {
|
|
38
40
|
server, routes, Router,
|
|
39
41
|
|
|
40
|
-
Bromise, HttpCodes,
|
|
42
|
+
Bromise, HttpError, HttpCodes, HTTPS,
|
|
41
43
|
|
|
42
44
|
cors, trycatch,
|
|
43
45
|
|
|
44
46
|
config, ConfigLoader,
|
|
45
47
|
|
|
46
|
-
HTTPS,
|
|
47
|
-
|
|
48
48
|
CSD, CinCSD, SinCSD, DinCSD, // only CSD is for usage, others for exposing methods (via IDE auto-suggestion)
|
|
49
49
|
|
|
50
|
-
crypto,
|
|
51
|
-
|
|
52
|
-
types,
|
|
53
|
-
validation,
|
|
50
|
+
crypto, types, validation,
|
|
54
51
|
|
|
55
52
|
WebBuild, binh
|
|
56
53
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// module.exports = {
|
|
60
|
-
// ...require('@binhend/core'),
|
|
61
|
-
// };
|
package/jsconfig.json
CHANGED
|
@@ -7,13 +7,16 @@
|
|
|
7
7
|
"allowJs": true,
|
|
8
8
|
"noEmit": true,
|
|
9
9
|
|
|
10
|
-
"baseUrl": "./
|
|
10
|
+
"baseUrl": "./",
|
|
11
11
|
"paths": {
|
|
12
12
|
"@/*": [
|
|
13
|
-
"
|
|
13
|
+
"./src/*"
|
|
14
|
+
],
|
|
15
|
+
"@binhend/*": [
|
|
16
|
+
"./packages/*"
|
|
14
17
|
],
|
|
15
18
|
"@test/*": [
|
|
16
|
-
"
|
|
19
|
+
"./test/*"
|
|
17
20
|
]
|
|
18
21
|
}
|
|
19
22
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
|
+
|
|
1
2
|
const express = require('express');
|
|
2
3
|
|
|
3
|
-
var server;
|
|
4
|
+
var server = express();
|
|
5
|
+
var calledOnce = false;
|
|
4
6
|
|
|
5
7
|
function getServer() {
|
|
6
|
-
|
|
8
|
+
if (calledOnce) {
|
|
9
|
+
server = server;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
server = express();
|
|
13
|
+
calledOnce = true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return server;
|
|
7
17
|
}
|
|
8
18
|
|
|
9
19
|
module.exports = getServer;
|
|
@@ -28,7 +28,7 @@ function Controller(service) {
|
|
|
28
28
|
response.status(httpCode).json(result);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
//___ CREATE ___//
|
|
32
32
|
|
|
33
33
|
this.create = trycatch(async (request, response) => {
|
|
34
34
|
let data = request.body;
|
|
@@ -40,7 +40,7 @@ function Controller(service) {
|
|
|
40
40
|
await process('upsert', [query, data], OK, response);
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
//___ READ ___//
|
|
44
44
|
|
|
45
45
|
this.getAll = trycatch(async (request, response) => {
|
|
46
46
|
await process('getAll', [], OK, response);
|
|
@@ -56,7 +56,7 @@ function Controller(service) {
|
|
|
56
56
|
await process('getByQuery', [query], OK, response);
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
//___ UPDATE ___//
|
|
60
60
|
|
|
61
61
|
this.updateAll = trycatch(async (request, response) => {
|
|
62
62
|
let data = request.body;
|
|
@@ -74,7 +74,7 @@ function Controller(service) {
|
|
|
74
74
|
await process('updateByQuery', [query, data], OK, response);
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
//___ DELETE ___//
|
|
78
78
|
|
|
79
79
|
this.deleteAll = trycatch(async (request, response) => {
|
|
80
80
|
await process('deleteAll', [], OK, response);
|
package/packages/csd/src/dao.js
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
|
|
2
|
-
const
|
|
2
|
+
const must = require('@binhend/validation');
|
|
3
3
|
|
|
4
|
-
function DAO(
|
|
5
|
-
var service = initService({});
|
|
4
|
+
function DAO(implementedInstance = {}) {
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
const instance = implementedInstance,
|
|
7
|
+
required = { required: true };
|
|
8
|
+
|
|
9
|
+
//___ CREATE ___//
|
|
10
|
+
this.create = must.Function(instance.create, required);
|
|
11
|
+
this.upsert = must.Function(instance.upsert, required);
|
|
12
|
+
|
|
13
|
+
//___ READ ___//
|
|
14
|
+
this.getAll = must.Function(instance.getAll, required);
|
|
15
|
+
this.getByID = must.Function(instance.getByID, required);
|
|
16
|
+
this.getByQuery = must.Function(instance.getByQuery, required);
|
|
17
|
+
|
|
18
|
+
//___ UPDATE ___//
|
|
19
|
+
this.updateAll = must.Function(instance.updateAll, required);
|
|
20
|
+
this.updateByID = must.Function(instance.updateByID, required);
|
|
21
|
+
this.updateByQuery = must.Function(instance.updateByQuery, required);
|
|
22
|
+
|
|
23
|
+
//___ DELETE ___//
|
|
24
|
+
this.deleteAll = must.Function(instance.deleteAll, required);
|
|
25
|
+
this.deleteByID = must.Function(instance.deleteByID, required);
|
|
26
|
+
this.deleteByQuery = must.Function(instance.deleteByQuery, required);
|
|
13
27
|
}
|
|
14
28
|
|
|
15
|
-
module.exports = (
|
|
16
|
-
return new DAO(
|
|
29
|
+
module.exports = (implementedInstance) => {
|
|
30
|
+
return new DAO(implementedInstance);
|
|
17
31
|
};
|