Skip to content

Commit

Permalink
fix: remove unneeded try/catch
Browse files Browse the repository at this point in the history
  • Loading branch information
ajhenry committed Jun 11, 2024
1 parent f71b70f commit 7165caa
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/utils/trpc-middleware.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
import { TRPCError } from '@trpc/server'
import { checkGitHubAppInstallationAuth, checkGitHubAuth } from './auth'
import { Middleware } from './trpc-server'

export const verifyGitHubAppAuth: Middleware = async (opts) => {
const { ctx, rawInput } = opts

// Check app authentication
try {
await checkGitHubAppInstallationAuth(
(rawInput as Record<string, string>)?.accessToken,
(rawInput as Record<string, string>)?.mirrorOwner,
(rawInput as Record<string, string>)?.mirrorName,
)
await checkGitHubAppInstallationAuth(
(rawInput as Record<string, string>)?.accessToken,
(rawInput as Record<string, string>)?.mirrorOwner,
(rawInput as Record<string, string>)?.mirrorName,
)

return opts.next({
ctx,
})
} catch (error) {
console.error('Error checking github app installation auth', error)
throw new TRPCError({ code: 'UNAUTHORIZED' })
}
return opts.next({
ctx,
})
}

export const verifyAuth: Middleware = async (opts) => {
Expand Down

0 comments on commit 7165caa

Please sign in to comment.