From 042d30ab4d1e3023ff8bc0b59378903652e4aae7 Mon Sep 17 00:00:00 2001 From: Sebastien Ringrose Date: Mon, 26 Dec 2022 21:15:15 +0000 Subject: [PATCH] feat: overwrite response in resursive cascade --- server.ts | 2 +- utils/Cascade.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/server.ts b/server.ts index 0ffb10b3..99650ea1 100644 --- a/server.ts +++ b/server.ts @@ -144,7 +144,7 @@ export class Server { ? onError : (error) => { console.log(error) - return new Response("", { status: 500 }) + return new Response("Something went wrong...", { status: 500 }) }, onListen: onListen ? onListen diff --git a/utils/Cascade.ts b/utils/Cascade.ts index 9c687ad1..8b63e214 100644 --- a/utils/Cascade.ts +++ b/utils/Cascade.ts @@ -12,7 +12,6 @@ export class Cascade { constructor(public ctx: RequestContext, private toCall: Array) {} - async run(fcn: Middleware): Promise { if (!fcn) return @@ -25,7 +24,7 @@ export class Cascade { try { const result = await fcnPromise(this.ctx, async () => await this.run(this.toCall[++this.called])) - if (!this.response && result) { + if (result) { this.response = result } else { await this.run(this.toCall[++this.called])