import { createMiddleware } from "hono/factory";
import { getCookie } from "hono/cookie";
import { verify } from "hono/jwt";
export const authMiddleware = createMiddleware(async (c, next) => {
const token = getCookie(c, "dekada_access");
if (!token) {
return c.json({ success: false, message: "Unauthorized" }, 401);
}
const payload = await verify(token, Bun.env.ACCESS_TOKEN_SECRET!);
if (!payload) {
return c.json({ success: false, message: "Unauthorized" }, 401);
}
await next();
});
import { createMiddleware } from "hono/factory";
import { getCookie } from "hono/cookie";
import { verify } from "hono/jwt";
export const authMiddleware = createMiddleware(async (c, next) => {
const token = getCookie(c, "dekada_access");
if (!token) {
return c.json({ success: false, message: "Unauthorized" }, 401);
}
const payload = await verify(token, Bun.env.ACCESS_TOKEN_SECRET!);
if (!payload) {
return c.json({ success: false, message: "Unauthorized" }, 401);
}
await next();
});