This commit is contained in:
Andras Bacsai
2022-12-12 08:44:23 +01:00
parent f55b861849
commit c445fc0f8a
44 changed files with 3130 additions and 53 deletions

View File

@@ -0,0 +1,19 @@
import { inferAsyncReturnType } from '@trpc/server';
import { CreateFastifyContextOptions } from '@trpc/server/adapters/fastify';
import jwt from 'jsonwebtoken';
import { env } from '../env';
export interface User {
name: string | string[];
}
export function createContext({ req, res }: CreateFastifyContextOptions) {
const token = req.headers.authorization;
if (token) {
const user = jwt.verify(token, env.COOLIFY_SECRET_KEY);
console.log(user);
}
return { req, res };
}
export type Context = inferAsyncReturnType<typeof createContext>;