11 lines
314 B
TypeScript
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()
|
|
}
|