Files
litreddit/backend/src/middlewares/isAuth.ts
T
2026-06-24 14:20:05 +02:00

11 lines
314 B
TypeScript

import { MiddlewareFn } from 'type-graphql'
import { Context } from '@/src/types'
// https://typegraphql.com/docs/middlewares.html
export const isAuth: MiddlewareFn<Context> = async ({ context: { req }}, next) => {
if (!req.session?.userID) {
throw new Error('Unauthenticated!')
}
return await next()
}