export const jwt = bearerAuth({ verifyToken: async (accessToken: string, c: AppContext): Promise<boolean> => { try { const jwtPayload: JWTPayload = await verifyAccessToken(accessToken); c.set('user', jwtPayload.user as AuthUser); return true; } catch (err) { throw new Error(err instanceof JwtTokenExpired ? 'Expired JWT Token' : 'Authentication failed'); } },});export const auth: MiddlewareHandler = async (c: AppContext, next: Next): Promise<any> => { try { await jwt(c, next); } catch (e: any) { return c.json({error: e.message && e.message.length > 0 ? e.message : 'Authentication failed'}, 401); }};
request: { query: z.object({ limit: z.string().optional(), order: z.string().optional(), after: z.string().optional(), before: z.string().optional(), }) as RouteParameter, },