diff --git a/src/routes/authRoutes.ts b/src/routes/authRoutes.ts index ff16961..6265592 100644 --- a/src/routes/authRoutes.ts +++ b/src/routes/authRoutes.ts @@ -2,6 +2,7 @@ import { Router } from 'express' import { register, login } from '../controllers/authController.ts' import { validateBody } from '../middleware/validation.ts' import { z } from 'zod' +import { insertUserSchema } from '../db/schema.ts' const router = Router() @@ -23,7 +24,7 @@ const loginSchema = z.object({ }) // Routes -router.post('/register', validateBody(registerSchema), register) +router.post('/register', validateBody(insertUserSchema), register) router.post('/login', validateBody(loginSchema), login) export default router diff --git a/src/utils/jwt.ts b/src/utils/jwt.ts index 92323a1..17bb629 100644 --- a/src/utils/jwt.ts +++ b/src/utils/jwt.ts @@ -1,8 +1,8 @@ -import { SignJWT, jwtVerify, decodeJwt } from 'jose' +import { SignJWT, jwtVerify, decodeJwt, type JWTPayload} from 'jose' import { createSecretKey } from 'crypto' import env from '../../env.ts' -export interface JwtPayload { +export interface JwtPayload extends JWTPayload{ id: string email: string username: string @@ -33,16 +33,3 @@ export const verifyToken = async (token: string): Promise => { username: payload.username as string, } } - -export const decodeToken = (token: string): JwtPayload | null => { - try { - const payload = decodeJwt(token) - return { - id: payload.id as string, - email: payload.email as string, - username: payload.username as string, - } - } catch { - return null - } -}