How to use the hyper-ts.execMiddleware function in hyper-ts

To help you get started, we’ve selected a few hyper-ts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DenisFrezzato / hyper-ts-fastify / src / index.ts View on Github external
const exec = (
  middleware: H.Middleware,
  req: fastify.FastifyRequest,
  res: fastify.FastifyReply,
): Promise =>
  H.execMiddleware(middleware, new FastifyConnection<i>(req, res))().then(e =&gt;
    pipe(
      e,
      fold(constVoid, c =&gt; {
        const { actions: list, reply } = c as FastifyConnection
        const len = list.length
        const actions = LL.toReversedArray(list)
        for (let i = 0; i &lt; len; i++) {
          run(reply, actions[i])
        }
      }),
    ),
  )
</i>