import type { MiddlewareHandler } from 'astro';
import { getSessionFromRequest } from './lib/session';

export const onRequest: MiddlewareHandler = async (context, next) => {
  const session = getSessionFromRequest(context.request);
  (context.locals as any).user = session?.user || null;
  return next();
};
