Skip to content
Myr

fix(compose): Support a handler that non-async and returning a promise. (#469)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* fix(compose): Support a handler that non-async and returning a promise. * Update deno_dist via `yarn denoify`.

authored by Taku Amano · committed by GitHub · parent e23f7fb · Browse files · 3 files+24 added−24 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+24 added−24 removed

  • tests:+20 added−0 removed
  • other:+4 added−24 removed

3 files+24 added−24 removed

modified:deno_dist/compose.ts+2 added-12 removed
modified:src/compose.test.ts+20 added
57 unmodified lines
58 expect(context.res['zzz']).toBe('yyy')59 })60})6162describe('compose with returning a promise, non-async funciton', () => {63 const handlers: Function[] = [64 (c: C) => {65 return new Promise((resolve) =>66 setTimeout(() => {67 c.res = { message: 'new response' }68 resolve(true)69 }, 1)70 )71 },72 ]7374 it('Response', async () => {75 const c: C = { req: {}, res: {} }76 const composed = compose<C>(handlers)77 const context = await composed(c)78 expect(context.res['message']).toBe('new response')79 })80})8182describe('Handler and middlewares', () => {83 const middleware: Function[] = []8485 const req = new Request('http://localhost/')
612 unmodified lines
modified:src/compose.ts+2 added-12 removed