Commit Graph

39 Commits

Author SHA1 Message Date
Bas van Rossem
77659edf8e feat(admin): bearer auth with admin-only gate + login screen 2026-06-17 18:59:43 +02:00
Bas van Rossem
682a9dce44 feat(admin): scaffold Vite+React admin workspace 2026-06-17 18:56:28 +02:00
Bas van Rossem
02b7522b87 feat(api): include role in /api/me + allow admin origin in CORS
Add `role: Role` to the shared `PublicUser` contract and return it from
`GET /api/me` (defaulting to 'worker' when the session user has no role).
This lets the planned admin app gate access by role.

Also add the admin dev origin `http://localhost:5174` to the default
`WEB_ORIGINS` (env.ts) and to `.env.example`, so the admin SPA on :5174 can
reach the API at :3000 cross-origin (drives both hono/cors and better-auth
trustedOrigins).
2026-06-17 18:53:39 +02:00
Bas van Rossem
1631c1698d feat(worker): add logout + replace admin-only settings with Account screen
The Instellingen tab was activity management, which Phase 2 made admin-only —
workers saw add/edit/delete controls that all 403. Replace it with an Account
tab showing the signed-in name/email (via /api/me) and an Uitloggen button
(wires the existing AuthContext signOut). Activity management belongs to the
Phase 3 admin app, so the worker client drops the Settings screen and its
now-unused activity-mutation hooks (useActivities read stays).

Products affected: SoleLog worker client (apps/worker).
2026-06-17 18:23:42 +02:00
Bas van Rossem
3d8524c827 docs: Phase 2 accounts & roles — roadmap, README, session log 2026-06-17 18:04:19 +02:00
Bas van Rossem
7d200eb8fc feat(worker): login-only client (admin creates users) 2026-06-17 17:53:20 +02:00
Bas van Rossem
bd2d859e92 feat(api): seed dev admin + worker via admin createUser 2026-06-17 17:50:18 +02:00
Bas van Rossem
dc8f550665 feat(api): admin-only cross-user work-session views (/api/admin/sessions) 2026-06-17 17:47:17 +02:00
Bas van Rossem
f2cc0973c7 feat(api): role-aware session helper + admin-only activity writes 2026-06-17 17:43:37 +02:00
Bas van Rossem
c73fa0f898 feat(api): add better-auth admin plugin + close public sign-up (migration 0002) 2026-06-17 17:36:26 +02:00
Bas van Rossem
f6bd8eb036 test(api): centralize auth helpers on server-side createUser 2026-06-17 17:29:46 +02:00
Bas van Rossem
ec2bb7eec9 feat(api): seed a dev login account (worker@solelog.local) for testing
db:seed now also creates a ready-made dev account via better-auth (properly
hashed), idempotent, and SKIPPED when NODE_ENV=production so no known-password
account ships to prod. Credentials: worker@solelog.local / werkplaats123.
Documented in the worker README. API tests 37/37 green; verified live (sign-in
returns a bearer token; /api/me returns the user).
2026-06-17 17:05:56 +02:00
Bas van Rossem
34c48d6353 feat(api): drive CORS + trusted origins from CORS_ORIGINS env
Phone/LAN testing previously required editing both app.ts (cors origin) and
auth.ts (better-auth trustedOrigins). Now both read env.WEB_ORIGINS, parsed from
a comma-separated CORS_ORIGINS env var (default http://localhost:5173). To test
from a phone, set CORS_ORIGINS to include the LAN origin and restart the API — no
code edit. Documented in .env.example. Also fixed the worker README (db:migrate
creates ./data/app.db, not ./.tmp; phone step now uses CORS_ORIGINS). API tests
36/36 green; typecheck clean.
2026-06-17 16:50:21 +02:00
Bas van Rossem
bd8e8aff2a docs(worker): run instructions and Phase 1 verification 2026-06-17 16:37:28 +02:00
Bas van Rossem
134e01a2e8 feat(worker): Geschiedenis screen with session list and CSV export 2026-06-17 16:30:34 +02:00
Bas van Rossem
5af5a9c2bb feat(worker): server-authoritative Stopwatch screen with active-session recovery 2026-06-17 16:24:56 +02:00
Bas van Rossem
1ecad6bbb4 feat(worker): Instellingen screen — activities CRUD per zooltype 2026-06-17 16:17:37 +02:00
Bas van Rossem
75679256cd feat(worker): auth gate, Dutch login screen, router and 3-tab shell 2026-06-17 16:11:18 +02:00
Bas van Rossem
3511fd8a89 feat(worker): scaffold Vite+React PWA with token storage and typed API client 2026-06-17 16:03:41 +02:00
Bas van Rossem
35f9aa5574 feat(api): seed reference activities and enable CORS for the worker SPA 2026-06-17 15:54:52 +02:00
Bas van Rossem
85184d3287 feat(api): user-scoped CSV export matching legacy format 2026-06-17 15:49:20 +02:00
Bas van Rossem
b067bb65b0 feat(api): session history and active-session recovery endpoints 2026-06-17 15:45:08 +02:00
Bas van Rossem
940b06fd91 feat(api): server-authoritative session start/stop/discard with ownership scoping 2026-06-17 15:40:07 +02:00
Bas van Rossem
5e61b7720d feat(api): user-scoped activities CRUD with shared auth helper 2026-06-17 15:34:42 +02:00
Bas van Rossem
57809985fd feat(api): add activities + work_sessions domain schema and shared contracts 2026-06-17 15:29:14 +02:00
Bas van Rossem
ee113225fb fix(api): create the SQLite parent dir before opening the DB
A fresh local `yarn db:migrate`/`yarn dev` failed with SQLITE_CANTOPEN (14)
because libsql does not create the parent directory for a file: URL and the
gitignored apps/api/data/ does not exist on checkout. Added ensureDbDir() and
call it before createClient in both the client and the migrator. No-op for
non-file URLs and for the Docker /data volume. Verified: fresh db:migrate now
creates data/ and all tables; tests + typecheck still green; live round-trip
(/health, sign-up, sign-in, /api/me, 401) works.
2026-06-17 14:50:47 +02:00
Bas van Rossem
384797df7d docs: update CLAUDE.md and roadmap for single-backend (apps/api) repo 2026-06-17 14:41:07 +02:00
Bas van Rossem
64f8b2fd2c chore: remove legacy apps/mobile, apps/web, publisher and dead root config 2026-06-17 14:38:46 +02:00
Bas van Rossem
3f2c5f0179 chore(mobile): remove @expo/ngrok tunneling dependency
Dropped @expo/ngrok (and its 40 platform binary packages) from apps/mobile.
It was only used by `expo start --tunnel` (public dev-server tunnel) — never
imported in app code and unrelated to token storage (that is expo-secure-store).
Removed per IT request; no functional impact on the app or auth.
2026-06-17 14:25:28 +02:00
Bas van Rossem
efff2214d4 fix(api): make migrate.ts direct-run guard work on Windows
The guard compared import.meta.url against `file://${process.argv[1]}`, which
never matches on Windows (argv[1] is a drive-letter/backslash path), so
`yarn db:migrate` silently no-opped for local non-Docker dev. Use
pathToFileURL(process.argv[1]).href instead, which is correct on Windows and
Linux alike. Verified `yarn db:migrate` now creates all tables on Windows; the
Docker start path is unaffected.
2026-06-17 14:07:41 +02:00
Bas van Rossem
41b65f209c fix(api): reconcile better-auth schema with installed better-auth CLI output
The Task 3 schema drifted from what better-auth@1.6.18's CLI generates: it used
mode:'timestamp' (epoch seconds) instead of 'timestamp_ms', left verification
timestamps nullable, and omitted the default expressions and helper indexes.

Regenerated src/db/schema.ts from `@better-auth/cli generate` (authoritative per
the plan's version-drift rule) and rebuilt migration 0000 from scratch (no data
exists yet). Converted the index callbacks from the CLI's array form to the
object form required by drizzle-orm@0.36.4's types. Adds session_userId_idx,
account_userId_idx, verification_identifier_idx and the unixepoch defaults.

Tests (health, db, auth sign-up/sign-in, /api/me round-trip) all pass; typecheck
clean; db:generate reports no pending changes.
2026-06-17 14:06:16 +02:00
Bas van Rossem
bcb305b048 feat(api): dockerize backend with compose, migrations-on-start, and run docs 2026-06-17 13:54:48 +02:00
Bas van Rossem
04cfe0f726 feat(api): add protected GET /api/me and full auth round-trip test 2026-06-17 13:50:31 +02:00
Bas van Rossem
89f892ce0c feat(api): mount better-auth (email+password + bearer) on /api/auth 2026-06-17 13:47:20 +02:00
Bas van Rossem
e8aa2c67e8 feat(api): Drizzle + libsql DB layer with better-auth schema and migrations 2026-06-17 13:40:31 +02:00
Bas van Rossem
62c8597068 feat(api): Hono backend skeleton with /health endpoint and test 2026-06-17 13:35:28 +02:00
Bas van Rossem
b32d91bc4d docs(web): add reverse-engineered db/schema.sql
No migration shipped in the export. Recreates production_tasks and
time_logs (columns derived from the API queries) so the backend can run
against a fresh self-hosted Postgres.
2026-06-17 11:15:55 +02:00
Bas van Rossem
9689b84e8d fix(web): track and repair the /api/logs route
- .gitignore: the bare 'logs' rule was matching the api/logs/ source
  dir, so the route was never committed. Anchor it to /logs/ and repair
  two log globs where '*' had been mangled to '_'.
- route.ts: add the missing 'import sql' — the file used sql but never
  imported it, so every GET/POST /api/logs threw ReferenceError and 500'd.
2026-06-17 11:15:55 +02:00
Bas van Rossem
d94d0b188b Initial commit: code as received (Create/Anything export)
Insole-production time tracker exported from the Create/Anything AI
platform. Baseline snapshot before any reverse-engineering or cleanup.

- apps/mobile: Expo Router app (iOS/Android/web), the only workspace
- publisher/: standalone OpenNext/AWS deploy tooling for the web side
- Backend (/api/tasks, /api/logs + DB) lives remotely, not in this repo
2026-06-17 10:19:33 +02:00