axe-api 0.17.4 → 0.17.5
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 +6 -0
- package/package.json +1 -1
- package/src/resolvers/setExpressRoutes.js +9 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Release Notes
|
|
2
2
|
|
|
3
|
+
## [0.17.5 (2021-11-27)](https://github.com/axe-api/axe-api/compare/0.17.5...0.17.4)
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- [#111](https://github.com/axe-api/axe-api/issues/111)
|
|
8
|
+
|
|
3
9
|
## [0.17.4 (2021-10-28)](https://github.com/axe-api/axe-api/compare/0.17.4...0.17.3)
|
|
4
10
|
|
|
5
11
|
### Fixed
|
package/package.json
CHANGED
|
@@ -6,25 +6,6 @@ import Handlers from "./../handlers/index.js";
|
|
|
6
6
|
|
|
7
7
|
let Config = null;
|
|
8
8
|
|
|
9
|
-
const handleErrors = (req, res, error) => {
|
|
10
|
-
const status = error.type === "HttpResponse" ? error.status : 400;
|
|
11
|
-
let errors = error.content ? error.content : error.message;
|
|
12
|
-
|
|
13
|
-
if (Config.Application.env === "production") {
|
|
14
|
-
errors = "An error occurred!";
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const result = {
|
|
18
|
-
errors,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
if (Config.Application.env === "development") {
|
|
22
|
-
result.stack = error.stack;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
res.status(status).json(result);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
9
|
const setTransactionOption = (option, handler, defaultValue) => {
|
|
29
10
|
if (Array.isArray(option)) {
|
|
30
11
|
if (option.some((i) => i.handler === handler)) {
|
|
@@ -53,7 +34,7 @@ const hasTransaction = (config, model, handler) => {
|
|
|
53
34
|
return privilegedOption;
|
|
54
35
|
};
|
|
55
36
|
|
|
56
|
-
const requestHandler = async (handler, req, res, context) => {
|
|
37
|
+
const requestHandler = async (handler, req, res, next, context) => {
|
|
57
38
|
try {
|
|
58
39
|
context.trx = context.database;
|
|
59
40
|
if (hasTransaction(Config, context.model, handler)) {
|
|
@@ -73,7 +54,7 @@ const requestHandler = async (handler, req, res, context) => {
|
|
|
73
54
|
await context.trx.rollback();
|
|
74
55
|
}
|
|
75
56
|
|
|
76
|
-
|
|
57
|
+
next(error);
|
|
77
58
|
}
|
|
78
59
|
};
|
|
79
60
|
|
|
@@ -229,9 +210,13 @@ const createRouteByModel = async (
|
|
|
229
210
|
docs.push(routeTemplate.method, url, model);
|
|
230
211
|
|
|
231
212
|
// Adding the route to the express
|
|
232
|
-
app[routeTemplate.method.toLowerCase()](
|
|
233
|
-
|
|
234
|
-
|
|
213
|
+
app[routeTemplate.method.toLowerCase()](
|
|
214
|
+
url,
|
|
215
|
+
middlewares,
|
|
216
|
+
(req, res, next) => {
|
|
217
|
+
requestHandler(handler, req, res, next, context);
|
|
218
|
+
}
|
|
219
|
+
);
|
|
235
220
|
}
|
|
236
221
|
|
|
237
222
|
await createChildRoutes(model, models, resource, urlPrefix);
|