import { createAuthMiddleware } from 'better-auth/api'; export type AuthMiddlewareContext = Parameters[0]>[0]; /** * Array of all hooks to run after better-auth requests * * Add new hooks here to register them */ const afterHooks: Array<(context: AuthMiddlewareContext) => Promise> = [ // add hooks here ]; /** * Combines all after hooks into a single function * This function will be called by better-auth after each request */ export const combineAfterHooks = async (context: AuthMiddlewareContext) => { console.log('[auth] combineAfterHooks: running'); for (const hook of afterHooks) { try { await hook(context); } catch (error) { console.error('Error executing hook:', error); } } };