allserver 1.0.0 → 1.0.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/README.md +2 -2
- package/package.json +1 -1
- package/src/server/Allserver.js +6 -4
package/README.md
CHANGED
|
@@ -277,7 +277,7 @@ Allserver({
|
|
|
277
277
|
You'd need to deal with node.js `res` yourself.
|
|
278
278
|
|
|
279
279
|
```js
|
|
280
|
-
const
|
|
280
|
+
const procedures = {
|
|
281
281
|
processEntity({ someEntity }, ctx) {
|
|
282
282
|
const res = ctx.http.res;
|
|
283
283
|
res.statusCode = 422;
|
|
@@ -293,7 +293,7 @@ const procedires = {
|
|
|
293
293
|
Occasionally, your HTTP method would need to access raw body of a request. This is how you do it:
|
|
294
294
|
|
|
295
295
|
```js
|
|
296
|
-
const
|
|
296
|
+
const procedures = {
|
|
297
297
|
async processEntity(_, ctx) {
|
|
298
298
|
const micro = ctx.allserver.transport.micro; // same as require("micro")
|
|
299
299
|
const req = ctx.http.req; // node.js Request
|
package/package.json
CHANGED
package/src/server/Allserver.js
CHANGED
|
@@ -65,11 +65,12 @@ module.exports = require("stampit")({
|
|
|
65
65
|
try {
|
|
66
66
|
result = await ctx.procedure(ctx.arg, ctx);
|
|
67
67
|
} catch (err) {
|
|
68
|
-
|
|
68
|
+
const code = err.code || "ALLSERVER_PROCEDURE_ERROR"
|
|
69
|
+
this.logger.error(code, err);
|
|
69
70
|
ctx.error = err;
|
|
70
71
|
ctx.result = {
|
|
71
72
|
success: false,
|
|
72
|
-
code
|
|
73
|
+
code,
|
|
73
74
|
message: `'${err.message}' error in '${ctx.procedureName}' procedure`,
|
|
74
75
|
};
|
|
75
76
|
await this.transport.prepareProcedureErrorReply(ctx);
|
|
@@ -102,11 +103,12 @@ module.exports = require("stampit")({
|
|
|
102
103
|
break;
|
|
103
104
|
}
|
|
104
105
|
} catch (err) {
|
|
105
|
-
|
|
106
|
+
const code = err.code || "ALLSERVER_MIDDLEWARE_ERROR";
|
|
107
|
+
this.logger.error(code, err);
|
|
106
108
|
ctx.error = err;
|
|
107
109
|
ctx.result = {
|
|
108
110
|
success: false,
|
|
109
|
-
code
|
|
111
|
+
code,
|
|
110
112
|
message: `'${err.message}' error in '${middlewareType}' middleware`,
|
|
111
113
|
};
|
|
112
114
|
return;
|