@trenskow/app 0.5.5 → 0.5.9
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/application.js +20 -17
- package/package.json +1 -1
package/lib/application.js
CHANGED
|
@@ -173,10 +173,13 @@ export default class Application extends EventEmitter {
|
|
|
173
173
|
|
|
174
174
|
if (path.substr(-1) === '/') path = path.slice(0, -1);
|
|
175
175
|
|
|
176
|
-
query = Object.fromEntries(query
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
176
|
+
query = Object.fromEntries(query
|
|
177
|
+
.split(/&/)
|
|
178
|
+
.filter((entry) => entry)
|
|
179
|
+
.map((entry) => {
|
|
180
|
+
const [key, value] = entry.split(/=/).map(decodeURIComponent);
|
|
181
|
+
return [caseit(key), value];
|
|
182
|
+
}));
|
|
180
183
|
|
|
181
184
|
let state = 'routing';
|
|
182
185
|
|
|
@@ -243,10 +246,7 @@ export default class Application extends EventEmitter {
|
|
|
243
246
|
|
|
244
247
|
}
|
|
245
248
|
},
|
|
246
|
-
query
|
|
247
|
-
get: (target, property) => target[caseit(property)],
|
|
248
|
-
set: (target, property, value) => target[caseit(property)] = value
|
|
249
|
-
}),
|
|
249
|
+
query,
|
|
250
250
|
render: () => {
|
|
251
251
|
state = 'rendering';
|
|
252
252
|
},
|
|
@@ -256,7 +256,7 @@ export default class Application extends EventEmitter {
|
|
|
256
256
|
({ error, brutally } = error);
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
if (!['completed', 'aborted'].includes(state)) {
|
|
259
|
+
if (!['completed', 'aborted', 'ignored'].includes(state)) {
|
|
260
260
|
state = 'aborted';
|
|
261
261
|
if (error) context.result = error;
|
|
262
262
|
}
|
|
@@ -269,6 +269,11 @@ export default class Application extends EventEmitter {
|
|
|
269
269
|
});
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
+
},
|
|
273
|
+
ignore: () => {
|
|
274
|
+
if (!['completed', 'aborted', 'ignored'].includes(state)) {
|
|
275
|
+
state = 'ignored';
|
|
276
|
+
}
|
|
272
277
|
}
|
|
273
278
|
|
|
274
279
|
};
|
|
@@ -321,17 +326,15 @@ export default class Application extends EventEmitter {
|
|
|
321
326
|
});
|
|
322
327
|
});
|
|
323
328
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
} catch (error) {
|
|
329
|
+
if (state === 'ignored') return;
|
|
327
330
|
|
|
328
|
-
if (
|
|
329
|
-
|
|
330
|
-
context.result = new ApiError.InternalError({ underlying: error });
|
|
331
|
-
} else {
|
|
332
|
-
context.result = error;
|
|
331
|
+
if (context.response.statusCode === 200) {
|
|
332
|
+
context.response.statusCode = typeof context.result !== 'undefined' ? 200 : 204;
|
|
333
333
|
}
|
|
334
334
|
|
|
335
|
+
} catch (error) {
|
|
336
|
+
|
|
337
|
+
context.result = error;
|
|
335
338
|
context.response.statusCode = error.statusCode ?? 500;
|
|
336
339
|
|
|
337
340
|
}
|