import { throwException, Unauthorised } from "@/lib/error";
import type { Context, Next } from "hono";

export async function memberMiddleware(ctx: Context, next: Next) {
  try {
    const accountID = ctx.req.header("x-account");
    const contactID = ctx.req.header("x-contact");

    if (!accountID || !contactID) {
      throw new Unauthorised();
    }
    await next();
  } catch (error) {
    throwException(error);
  }
}
