mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-17 23:20:43 +00:00
20 lines
550 B
TypeScript
20 lines
550 B
TypeScript
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>;
|