| 1 | /** |
| 2 | * Static Better Auth instance for the `@better-auth/cli` only. |
| 3 | * |
| 4 | * The CLI (`bunx @better-auth/cli generate|migrate`) needs a top-level `auth` |
| 5 | * export, which is exactly what the Nest DI setup avoids. So this file builds |
| 6 | * its own short-lived connection; the running app never imports it and instead |
| 7 | * gets its instance from `AuthModule.forRootAsync` in `src/app.module.ts`. |
| 8 | * |
| 9 | * Run it from the repo root so the root `.env` is picked up: |
| 10 | * bunx @better-auth/cli generate --config apps/api/auth.ts |
| 11 | */ |
| 12 | import { createDatabase } |
| 13 | |
| 14 | import { createAuth } |
| 15 | |
| 16 | const { db } |
| 17 | |
| 18 | export const auth = |
| 19 | secret: process.env |
| 20 | baseURL: process.env |
| 21 | }); |