vchikalkin a3f98c1e91 finally: fix calculate error
(caused by empty cookies in bonus validation user request)
2023-03-24 20:21:10 +03:00

17 lines
331 B
TypeScript

import { t } from './server';
import { TRPCError } from '@trpc/server';
export const userMiddleware = t.middleware(({ ctx, next }) => {
if (process.env.NODE_ENV !== 'development' && !ctx.user) {
throw new TRPCError({
code: 'UNAUTHORIZED',
});
}
return next({
ctx: {
isAdmin: false,
},
});
});