Skip to content

Commit

Permalink
feat: overwrite response in resursive cascade
Browse files Browse the repository at this point in the history
  • Loading branch information
sejori committed Dec 26, 2022
1 parent e8d6877 commit 042d30a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions utils/Cascade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export class Cascade {

constructor(public ctx: RequestContext, private toCall: Array<Middleware | Handler>) {}


async run(fcn: Middleware): Promise<Result> {
if (!fcn) return

Expand All @@ -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])
Expand Down

0 comments on commit 042d30a

Please sign in to comment.