Skip to content

Middleware next() #717

Closed
Closed

Description

@KATT

Moving this (back) to issues as I agree with @mmkal & @mmkal that this would be useful, especially now that batching is enabled by default for things like time logging.

Discussed in #586

Originally posted by delaneyj June 18, 2021
Unless I'm missing something you can't have a middleware do pre/post style flow ala koa...

.middleware(async ({ ctx, next }) => {
  const auth = checkForAuth(ctx)
  if (!auth) return handleUnauth(ctx)
  await next()
  const update = checkForUpdatedAuth(ctx)
  if (update) {
    ctx.res.headers['x-access-token'] = update.token
  }
})

Activity

  1. KATT commented on Aug 29, 2021

    @KATT
    MemberAuthor

    Part of v9

  2. github-actions commented on Oct 4, 2022

    @github-actions
    Contributor

    This issue has been locked because it had no new activity for 14 days. If you are running into a similar issue, please create a new issue. Thank you.

  3. locked as resolved and limited conversation to collaborators on Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    @trpc/server⏭ major bump needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions