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