feat(auth): @mosaic/auth — BetterAuth email/password setup

Implements P0-004: authentication package with BetterAuth + Drizzle adapter.

- BetterAuth configured with Drizzle adapter (usePlural for table mapping)
- Email/password authentication enabled
- Role field (admin/member/viewer) as additional user field
- 7-day sessions with daily refresh
- Mounted at /api/auth/* basePath
- createAuth() factory takes Db instance for DI flexibility
- BETTER_AUTH_SECRET and BETTER_AUTH_URL env vars added to .env.example

Verified: auth instance created, handler and API methods confirmed.

Closes #4

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-12 21:20:42 -05:00
parent 2b1723e898
commit d03f78ae17
6 changed files with 544 additions and 4 deletions

View File

@@ -6,7 +6,7 @@
| ------ | ----------- | --------- | ------------------------------------------------------------- | --- | ----- |
| P0-001 | done | Phase 0 | Scaffold monorepo | #60 | #1 |
| P0-002 | done | Phase 0 | @mosaic/types — migrate and extend shared types | #65 | #2 |
| P0-003 | not-started | Phase 0 | @mosaic/db — Drizzle schema and PG connection | | #3 |
| P0-003 | done | Phase 0 | @mosaic/db — Drizzle schema and PG connection | #67 | #3 |
| P0-004 | not-started | Phase 0 | @mosaic/auth — BetterAuth email/password setup | — | #4 |
| P0-005 | done | Phase 0 | Docker Compose — PG 17, Valkey 8, SigNoz | #65 | #5 |
| P0-006 | done | Phase 0 | OTEL foundation — OpenTelemetry SDK setup | #65 | #6 |