mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-18 07:20:50 +00:00
wip
This commit is contained in:
19
apps/server/src/router/context.ts
Normal file
19
apps/server/src/router/context.ts
Normal 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>;
|
||||
Reference in New Issue
Block a user