Commit Graph

100 Commits

Author SHA1 Message Date
8cd4b42cc6 Add scripts to run migrations and to connect to the db 2026-01-10 09:05:05 -06:00
241d3e799e Use less ambiguous funcion 2026-01-10 08:55:00 -06:00
49dc0e3fe0 Mark several unused vars as such 2026-01-10 08:54:51 -06:00
c7b8cd33da Clean up imports 2026-01-10 08:54:34 -06:00
6c0895de07 Fix formatting 2026-01-10 08:51:20 -06:00
17ea6ba02d Consider block stmts without braces to be errors 2026-01-09 11:44:09 -06:00
661def8a5c Refmt 2026-01-04 15:24:29 -06:00
74d75d08dd Add Session class to provide getUser() on call.session
Wraps SessionData and user into a Session class that handlers can use
via call.session.getUser() instead of accessing services directly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-04 15:22:27 -06:00
ad6d405206 Add session data to Call type
- AuthService.validateRequest now returns AuthResult with both user and session
- Call type includes session: SessionData | null
- Handlers can access session metadata (createdAt, authMethod, etc.)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-04 09:50:05 -06:00
e9ccf6d757 Add PostgreSQL database layer with Kysely and migrations
- Add database.ts with connection pool, Kysely query builder, and migration runner
- Create migrations for users and sessions tables (0001, 0002)
- Implement PostgresAuthStore to replace InMemoryAuthStore
- Wire up database service in services/index.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-04 09:43:20 -06:00
34ec5be7ec Pull in kysely and pg deps 2026-01-03 17:20:49 -06:00
e136c07928 Add some stub user stuff 2026-01-03 17:06:54 -06:00
c926f15aab Fix circular dependency breaking ncc bundle
Don't export authRoutes from barrel file to break the cycle:
services.ts → auth/index.ts → auth/routes.ts → services.ts

Import authRoutes directly from ./auth/routes instead.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 14:24:53 -06:00
39cd93c81e Move services.ts 2026-01-03 14:12:27 -06:00
c246e0384f Add authentication system with session-based auth
Implements full auth flows with opaque tokens (not JWT) for easy revocation:
- Login/logout with cookie or bearer token support
- Registration with email verification
- Password reset with one-time tokens
- scrypt password hashing (no external deps)

New files in express/auth/:
- token.ts: 256-bit token generation, SHA-256 hashing
- password.ts: scrypt hashing with timing-safe verification
- types.ts: Session schemas, token types, input validation
- store.ts: AuthStore interface + InMemoryAuthStore
- service.ts: AuthService with all auth operations
- routes.ts: 6 auth endpoints

Modified:
- types.ts: Added user field to Call, requireAuth/requirePermission helpers
- app.ts: JSON body parsing, populates call.user, handles auth errors
- services.ts: Added services.auth
- routes.ts: Includes auth routes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 13:59:02 -06:00
788ea2ab19 Add User class with role and permission-based authorization
Foundation for authentication/authorization with:
- Stable UUID id for database keys, email as human identifier
- Account status (active/suspended/pending)
- Role-based auth with role-to-permission mappings
- Direct permissions in resource:action format
- Methods: hasRole(), hasPermission(), can(), effectivePermissions()

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 12:59:47 -06:00
6297a95d3c Reformat more files 2026-01-01 21:20:45 -06:00
63cf0a670d Update todo list 2026-01-01 21:20:38 -06:00
5524eaf18f ? 2026-01-01 21:12:55 -06:00
03980e114b Add basic template rendering route 2026-01-01 21:12:38 -06:00
539717efda Add todo item 2026-01-01 21:11:28 -06:00
8be88bb696 Move TODOs re logging to the end 2026-01-01 21:11:10 -06:00
ab74695f4c Have master start and manage the logger process
Master now:
- Starts logger on startup with configurable port and capacity
- Restarts logger automatically if it crashes
- Stops logger gracefully on shutdown

New flags:
- --logger-port (default 8085)
- --logger-capacity (default 1000000)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 20:53:29 -06:00
dc5a70ba33 Add logging service
New Go program (logger/) that:
- Accepts POSTed JSON log messages via POST /log
- Stores last N messages in a ring buffer (default 1M)
- Retrieves logs via GET /logs with limit/before/after filters
- Shows status via GET /status

Also updates express/logging.ts to POST messages to the logger service.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 20:45:34 -06:00
4adf6cf358 Add another TODO item 2026-01-01 20:37:16 -06:00
bee6938a67 Add some logging related stubs to express backend 2026-01-01 20:18:37 -06:00
b0ee53f7d5 Listen by default on port 3500
The master process will continue to start at port 3000.  In practice, this
ought to make conflicts between master-superviced processes and ones run by
hand less of an issue.
2026-01-01 20:17:26 -06:00
5c93c9e982 Add TODO items 2026-01-01 20:17:15 -06:00
5606a59614 Note that you need docker as well as docker compose 2026-01-01 17:36:22 -06:00
22dde8c213 Add wrapper script for master program 2026-01-01 17:35:56 -06:00
30463b60a5 Use CLI flags instead of environment variables for master config
Replace env var parsing with Go's flag package:
- --watch (default: ../express)
- --workers (default: 1)
- --base-port (default: 3000)
- --port (default: 8080)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 17:31:08 -06:00
e2ea472a10 Make biome happier 2026-01-01 17:22:04 -06:00
20e5da0d54 Teach fixup.sh to use biome 2026-01-01 17:16:46 -06:00
13d02d86be Pull in and set up biome 2026-01-01 17:16:02 -06:00
d35e7bace2 Make shfmt happier 2026-01-01 16:53:19 -06:00
cb4a730838 Make go fmt happier 2026-01-01 16:53:00 -06:00
58f88e3695 Add check.sh and fixup.sh scripts 2026-01-01 16:47:50 -06:00
7b8eaac637 Add TODO.md and instructions 2026-01-01 15:45:43 -06:00
f504576f3e Add first cut at a pool 2026-01-01 15:43:49 -06:00
8722062f4a Change process names again 2026-01-01 15:12:01 -06:00
9cc1991d07 Name backend process 2026-01-01 14:54:17 -06:00
5d5a2430ad Fix arg in build script 2026-01-01 14:37:11 -06:00
a840137f83 Mark build.sh as executable 2026-01-01 14:34:31 -06:00
c330da49fc Add rudimentary command line parsing to express app 2026-01-01 14:34:16 -06:00
db81129724 Add build.sh 2026-01-01 14:17:09 -06:00
43ff2edad2 Pull in nunjucks 2026-01-01 14:14:03 -06:00
Michael Wolf
ad95f652b8 Fix bogus path expansion 2026-01-01 14:10:57 -06:00
Michael Wolf
51d24209b0 Use build.sh script 2026-01-01 14:09:51 -06:00
Michael Wolf
1083655a3b Add and use a simpler run script 2026-01-01 14:08:46 -06:00
Michael Wolf
615cd89656 Ignore more node_modules directories 2026-01-01 13:24:50 -06:00