@trenskow/app 0.6.3 → 0.6.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/lib/application.js +16 -8
- package/package.json +1 -1
package/lib/application.js
CHANGED
|
@@ -213,6 +213,19 @@ export default class Application extends EventEmitter {
|
|
|
213
213
|
}
|
|
214
214
|
};
|
|
215
215
|
|
|
216
|
+
const render = async () => {
|
|
217
|
+
|
|
218
|
+
state = 'rendering';
|
|
219
|
+
|
|
220
|
+
try {
|
|
221
|
+
await this.#_renderer(context);
|
|
222
|
+
} catch (error) {
|
|
223
|
+
console.error(`Error in render method "${error.message}"`);
|
|
224
|
+
request.socket.destroy();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
};
|
|
228
|
+
|
|
216
229
|
let context = {
|
|
217
230
|
application: this,
|
|
218
231
|
request,
|
|
@@ -271,6 +284,8 @@ export default class Application extends EventEmitter {
|
|
|
271
284
|
});
|
|
272
285
|
}
|
|
273
286
|
|
|
287
|
+
await render();
|
|
288
|
+
|
|
274
289
|
},
|
|
275
290
|
ignore: () => {
|
|
276
291
|
if (!['completed', 'aborted', 'ignored'].includes(state)) {
|
|
@@ -343,14 +358,7 @@ export default class Application extends EventEmitter {
|
|
|
343
358
|
|
|
344
359
|
if (!['routing', 'rendering'].includes(state)) return response.end();
|
|
345
360
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
try {
|
|
349
|
-
await this.#_renderer(context);
|
|
350
|
-
} catch (error) {
|
|
351
|
-
console.error(`Error in render method "${error.message}"`);
|
|
352
|
-
request.socket.destroy();
|
|
353
|
-
}
|
|
361
|
+
await render();
|
|
354
362
|
|
|
355
363
|
state = 'completed';
|
|
356
364
|
|