jgloo 1.8.0 → 1.8.1
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/CHANGELOG.md +15 -5
- package/jgloo.js +1 -1
- package/mock/api/test-1.js +8 -0
- package/mock/api/test-2.js +7 -0
- package/package.json +1 -1
- package/rest.js +7 -7
- package/server.js +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
<a name="1.8.1"></a>
|
|
2
|
+
|
|
3
|
+
## [1.8.1](https://github.com/zosma180/jgloo/compare/1.8.0...1.8.1) (2022-08-03)
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- Fixed the "delay" option that was applied incorrectly
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
1
11
|
<a name="1.8.0"></a>
|
|
2
12
|
|
|
3
13
|
## [1.8.0](https://github.com/zosma180/jgloo/compare/1.7.0...1.8.0) (2022-07-29)
|
|
@@ -22,7 +32,7 @@
|
|
|
22
32
|
|
|
23
33
|
## [1.6.1](https://github.com/zosma180/jgloo/compare/1.6.0...1.6.1) (2022-07-22)
|
|
24
34
|
|
|
25
|
-
###
|
|
35
|
+
### Fixes
|
|
26
36
|
|
|
27
37
|
- Updated the package-lock to fix the security issues
|
|
28
38
|
|
|
@@ -42,7 +52,7 @@
|
|
|
42
52
|
|
|
43
53
|
## [1.5.2](https://github.com/zosma180/jgloo/compare/1.5.1...1.5.2) (2021-02-21)
|
|
44
54
|
|
|
45
|
-
###
|
|
55
|
+
### Fixes
|
|
46
56
|
|
|
47
57
|
- Fixed the folder path with space characters
|
|
48
58
|
|
|
@@ -52,7 +62,7 @@
|
|
|
52
62
|
|
|
53
63
|
## [1.5.1](https://github.com/zosma180/jgloo/compare/1.5.0...1.5.1) (2021-02-17)
|
|
54
64
|
|
|
55
|
-
###
|
|
65
|
+
### Fixes
|
|
56
66
|
|
|
57
67
|
- Fixed the folder path for Windows environment
|
|
58
68
|
|
|
@@ -152,7 +162,7 @@
|
|
|
152
162
|
|
|
153
163
|
## [1.0.3](https://github.com/zosma180/jgloo/compare/1.0.2...1.0.3) (2019-12-18)
|
|
154
164
|
|
|
155
|
-
###
|
|
165
|
+
### Fixes
|
|
156
166
|
|
|
157
167
|
- Fixed child process remaining alive
|
|
158
168
|
|
|
@@ -172,7 +182,7 @@
|
|
|
172
182
|
|
|
173
183
|
## [1.0.1](https://github.com/zosma180/jgloo/compare/1.0.0...1.0.1) (2019-12-16)
|
|
174
184
|
|
|
175
|
-
###
|
|
185
|
+
### Fixes
|
|
176
186
|
|
|
177
187
|
- Fixed nodemon path
|
|
178
188
|
|
package/jgloo.js
CHANGED
package/package.json
CHANGED
package/rest.js
CHANGED
|
@@ -2,14 +2,14 @@ const path = require('path');
|
|
|
2
2
|
const { getResource, setResource } = require(path.join(__dirname, 'jgloo'));
|
|
3
3
|
|
|
4
4
|
module.exports = {
|
|
5
|
-
configureResource: (app, config) => {
|
|
5
|
+
configureResource: (app, config, middleware) => {
|
|
6
6
|
const fallback = config.path.split('/').filter(Boolean).join('-');
|
|
7
7
|
const resourceName = config.name || fallback;
|
|
8
8
|
const skips = config.not || [];
|
|
9
9
|
|
|
10
10
|
// List
|
|
11
11
|
if (skips.includes('LIST') === false) {
|
|
12
|
-
app.get(config.path, (req, res) => {
|
|
12
|
+
app.get(config.path, middleware, (req, res) => {
|
|
13
13
|
const resource = getResource(resourceName) || [];
|
|
14
14
|
res.json(resource);
|
|
15
15
|
});
|
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
|
17
17
|
|
|
18
18
|
// Read
|
|
19
19
|
if (skips.includes('READ') === false) {
|
|
20
|
-
app.get(`${config.path}/:id`, (req, res) => {
|
|
20
|
+
app.get(`${config.path}/:id`, middleware, (req, res) => {
|
|
21
21
|
const id = Number(req.params.id);
|
|
22
22
|
|
|
23
23
|
const resource = getResource(resourceName) || [];
|
|
@@ -30,7 +30,7 @@ module.exports = {
|
|
|
30
30
|
|
|
31
31
|
// Create
|
|
32
32
|
if (skips.includes('CREATE') === false) {
|
|
33
|
-
app.post(config.path, (req, res) => {
|
|
33
|
+
app.post(config.path, middleware, (req, res) => {
|
|
34
34
|
const resource = getResource(resourceName) || [];
|
|
35
35
|
const model = req.body;
|
|
36
36
|
|
|
@@ -44,7 +44,7 @@ module.exports = {
|
|
|
44
44
|
|
|
45
45
|
// Update
|
|
46
46
|
if (skips.includes('UPDATE') === false) {
|
|
47
|
-
app.put(`${config.path}/:id`, (req, res) => {
|
|
47
|
+
app.put(`${config.path}/:id`, middleware, (req, res) => {
|
|
48
48
|
const id = Number(req.params.id);
|
|
49
49
|
|
|
50
50
|
const resource = getResource(resourceName) || [];
|
|
@@ -61,7 +61,7 @@ module.exports = {
|
|
|
61
61
|
|
|
62
62
|
// Patch
|
|
63
63
|
if (skips.includes('PATCH') === false) {
|
|
64
|
-
app.patch(`${config.path}/:id`, (req, res) => {
|
|
64
|
+
app.patch(`${config.path}/:id`, middleware, (req, res) => {
|
|
65
65
|
const id = Number(req.params.id);
|
|
66
66
|
|
|
67
67
|
const resource = getResource(resourceName) || [];
|
|
@@ -78,7 +78,7 @@ module.exports = {
|
|
|
78
78
|
|
|
79
79
|
// Delete
|
|
80
80
|
if (skips.includes('DELETE') === false) {
|
|
81
|
-
app.delete(`${config.path}/:id`, (req, res) => {
|
|
81
|
+
app.delete(`${config.path}/:id`, middleware, (req, res) => {
|
|
82
82
|
const id = Number(req.params.id);
|
|
83
83
|
|
|
84
84
|
let resource = getResource(resourceName) || [];
|
package/server.js
CHANGED
|
@@ -76,16 +76,16 @@ if (!api.length) {
|
|
|
76
76
|
|
|
77
77
|
api.forEach(config => {
|
|
78
78
|
// Add the API delay, if it is provided
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
const middleware = config.delay
|
|
80
|
+
? getDelayMiddleware(config.delay)
|
|
81
|
+
: (_, __, next) => next();
|
|
82
82
|
|
|
83
83
|
if (config.method === 'resource') {
|
|
84
84
|
// ReST resource
|
|
85
85
|
configureResource(app, config);
|
|
86
86
|
} else {
|
|
87
87
|
// Custom endpoint
|
|
88
|
-
app[config.method](config.path, config.callback);
|
|
88
|
+
app[config.method](config.path, middleware, config.callback);
|
|
89
89
|
}
|
|
90
90
|
});
|
|
91
91
|
|