refactor(transcode): relocate TranscodeService to core and flatten API package

This commit is contained in:
yiling
2026-06-16 09:47:27 +08:00
parent 7f6e41708a
commit f16a8a7069
51 changed files with 161 additions and 159 deletions
+35
View File
@@ -0,0 +1,35 @@
import type { Prisma } from '@shumai/db'
import { auth } from '@shumai/core/src/auth/auth'
import { prisma } from '@shumai/db'
import { createMiddleware } from 'hono/factory'
type User = Prisma.UserGetPayload<Record<string, never>>
export const authMiddleware = createMiddleware<{
Variables: {
user: User
}
}>(async (c, next) => {
const session = await auth.api.getSession({
headers: c.req.raw.headers,
})
if (!session) {
return c.json({ error: 'Unauthorized' }, 401)
}
try {
const user = await prisma.user.findUnique({
where: { id: session.user.id },
})
if (!user) {
return c.json({ error: 'User not found' }, 401)
}
c.set('user', user)
await next()
} catch {
return c.json({ error: 'Authentication failed' }, 401)
}
})