new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Better Auth · all subjects

client apis/elysia

5 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Elysia integration mount handler

To integrate Better Auth with Elysia, mount the auth handler using .mount(auth.handler) on the Elysia app instance. For example: const app = new Elysia().mount(auth.handler).listen(3000);

Elysia CORS configuration

To configure CORS in Elysia with Better Auth, use the @elysiajs/cors plugin with .use(cors({...})). Configure it with properties: origin (the client origin like 'http://localhost:3001'), methods (array of HTTP methods like ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS']), credentials (boolean, set to true), and allowedHeaders (array like ['Content-Type', 'Authorization']).

Elysia macro for session and user in routes

Create a Better Auth macro in Elysia using .macro({ auth: { async resolve({ status, request: { headers } }) { const session = await auth.api.getSession({ headers }); if (!session) return status(401); return { user: session.user, session: session.session }; } } }). This allows routes to access user and session by using the auth: true option. For example, .get('/user', ({ user }) => user, { auth: true }).

Elysia Better Auth requires Bun server

The Elysia integration guide for Better Auth assumes usage with a Bun server.

Elysia getSession API usage

To get the current session in Elysia routes, call auth.api.getSession() with an object containing headers from the request. This returns a session object with user and session properties, or null if not authenticated.

Give your agent this brain