Commit Graph
122 Commits
Author SHA1 Message Date
David Santos 8b0044be82 feat(api): CRM parity mutations and recent-errors filters (BIT-726)
Add POST /api/error-monitoring/resolve, bulk-resolve, and purge-resolved with
resolve key or admin JWT (errors:triage / errors:delete). Extend GET
recent-errors with status, severity, project_slug, q, offset, and stable
ordering. Document contracts in api/docs/ERROR_MONITORING_PUBLIC_API.md;
add vitest for public auth helpers. Proxy new routes and widen admin-ui
middleware for /api/error-monitoring/*.

Paperclip-Issue: BIT-726
Paperclip-Run: 3fbf92be-736e-4b11-8e90-cf993d8cd5ca
Paperclip-Agent: Pedro Alves (id d706f4e6-5d05-4cec-b6e8-f8fb1f203aae)
Made-with: Cursor
2026-04-02 10:50:06 +00:00
David Santos e0af92eda1 fix(admin-ui): allow public recent-errors API path without login redirect
Keep /api/error-monitoring/recent-errors reachable for Paperclip error loop (including path variants) so central hub returns JSON instead of 307 /login.
2026-04-02 08:50:21 +00:00
David Santos bc8bd8707f feat(api): expose CRM-shaped GET /api/error-monitoring/recent-errors on Fastify
Register the same handler as /v1/paperclip/recent-errors so NPM and direct
API probes (e.g. :3200) match Paperclip default PAPERCLIP_ERROR_API_QUERY.
Admin UI proxy now calls the Fastify path for a single contract end-to-end.

Paperclip-Agent: David Santos (urlKey david-santos; id 0b1fcf92-5fe3-4ac0-9f29-df4ab72f5376)
Paperclip-Issue: BIT-702
Paperclip-Run: 4ba525c4-3929-475c-a845-400c49eda817
Made-with: Cursor
2026-04-01 16:28:43 +00:00
David Santos 6811dba303 Expose recent-errors for Paperclip via api_key (BIT-684)
Add Fastify GET /v1/paperclip/recent-errors returning CRM-compatible JSON (data
envelope, project_slug per row, status open for open/investigating incidents).

Admin UI proxies the public path /api/error-monitoring/recent-errors to the API
base; middleware bypasses the session redirect for that path only.

Auth matches CRM env names: ERROR_RESOLVE_API_KEY or ERROR_REPORTING_API_KEY for
?api_key=, DEBUG_VIEW_ERRORS_KEY for ?view_errors=.

Paperclip-Agent: David Santos (urlKey david-santos; id 0b1fcf92-5fe3-4ac0-9f29-df4ab72f5376)
Paperclip-Issue: BIT-684
Paperclip-Run: cf7cb964-6953-4476-af09-3feb5d10da17
Made-with: Cursor
2026-04-01 14:18:00 +00:00
1sonhador c899cef6e1 fix(admin-ui): SSR sees ERROR_REPORTING_ADMIN_API_BASE at runtime
Next build inlines bare process.env.* as undefined without .env at build time.
Use Reflect.get for admin API base and demo flag; add .env.production default for LXC.
2026-03-29 21:20:19 +01:00
1sonhador 0a8918ed00 chore(api): add admin stats routes source (required by index register) 2026-03-29 21:17:55 +01:00
1sonhador 988f9b8987 feat(api): register GET /v1/incidents and detail; wire stats routes
Admin UI SSR calls /v1/incidents; routes were missing (404). Add incidents list/detail with errors:read and register admin stats routes in index.
2026-03-29 21:17:48 +01:00
1sonhador a3b65b4b3f chore(admin-ui): generic login copy; trim infra hints in comments and .env.example 2026-03-29 18:35:53 +01:00
1sonhador 83308b465b fix(admin-ui): middleware login gate; add admin API systemd unit
- Middleware: require development+demo or SKIP_LOGIN for unauthenticated access.
- Document SKIP_LOGIN and stricter demo in .env.example.
- Ship bitreport-error-reporting-api.service (PORT via ExecStart env; shared env has PORT for ingest).
2026-03-29 18:32:05 +01:00
1sonhador c02c300dc3 feat(deploy): version.json generation, webhook promote, verify (BIT-468)
Align LXC deploy with BIT-465: write-version-json.sh, optional
webhook-deploy.sh, verify.sh fails when ER_VERSION_JSON_PATH is set but
missing/invalid, env.example + nginx sketch + runbook updates.
Ignore deploy/lxc/runtime/ (generated on server).
2026-03-24 18:33:37 +00:00
1sonhadorandPaperclip e17acc983c fix(admin-ui): require session for dashboard in production (BIT-403)
- Add middleware redirecting unauthenticated users to /login unless dev+demo
- Disable demo incident data when NODE_ENV=production
- Forward __Host-access cookie on SSR fetches to admin API
- Document NPM /admin/ proxy to Fastify api (§14.2.2)

Co-Authored-By: Paperclip <[email protected]>
2026-03-23 23:00:20 +00:00
1sonhadorandPaperclip e3a7efc1a3 docs(NPM): domain without :3040 needs no path rewrite; forward + headers
Co-Authored-By: Paperclip <[email protected]>
2026-03-23 21:26:10 +00:00
1sonhadorandPaperclip 4a32bb3b0c fix(admin-ui): force-dynamic routes so DEMO/API env is not CDN-cached stale
Co-Authored-By: Paperclip <[email protected]>
2026-03-23 21:13:46 +00:00
1sonhadorandPaperclip b95aee6f85 deploy(lxc): systemd After=mariadb (not postgresql); note Gitea clone on CT
Co-Authored-By: Paperclip <[email protected]>
2026-03-23 21:10:52 +00:00
1sonhadorandPaperclip ff11f79acb docs(compose): admin-ui port 3040 verify + troubleshooting when host not redeployed
Co-Authored-By: Paperclip <[email protected]>
2026-03-23 20:56:50 +00:00
1sonhadorandPaperclip 563f644861 compose: add admin-ui service on port 3040 (Next standalone)
Expose Velzon admin dashboard in docker-compose with ERROR_REPORTING_UI_DEMO=1
by default until admin API serves /v1/incidents. Document env vars in .env.example.

Co-Authored-By: Paperclip <[email protected]>
2026-03-23 19:50:30 +00:00
1sonhadorandPaperclip a9d85a2fec fix: use regular unique index for MariaDB 10.6 compat (BIT-277)
MariaDB 10.6 does not support functional indexes. Replace the
LOWER(email) functional index with a plain unique index on email;
case-insensitive uniqueness is enforced at the application layer.

Paperclip-Agent: DevOps Engineer (urlKey devops-engineer; id 5d084b36-f38f-42a5-a92a-520005afda4f)
Paperclip-Issue: BIT-277
Paperclip-Run: 7cc9257b-0d1a-475b-9133-8d0aa78d0f08

Co-Authored-By: Paperclip <[email protected]>
2026-03-23 16:26:19 +00:00
1sonhadorandPaperclip 09eef93b34 docs(deployment): add public NPM/DNS/Cloudflare runbook for LXC (BIT-277)
Document Nginx Proxy Manager (CT 102), DNS for errors.bitreport.pt and
ingest.errors.bitreport.pt, Cloudflare 525 troubleshooting, and external
verification curls alongside existing verify.sh checks.

Co-Authored-By: Paperclip <[email protected]>
2026-03-22 23:33:56 +00:00
1sonhadorandPaperclip 4604606033 feat(errors): migrate error-reporting stack from PostgreSQL to MariaDB (BIT-255)
Replace Postgres with MariaDB 11 in docker-compose; convert all
database/error_reporting and db/migrations SQL to InnoDB-friendly syntax
(DATETIME(6), AUTO_INCREMENT, ON DUPLICATE KEY). Run admin portal DDL in the
same migrate one-shot as error_reporting.

Switch ingest-api, collector-worker, and api from pg to mysql2 (pools,
parameterized queries, transactions). Align ingest writes with
er_incident_occurrences and include project_id on idempotency inserts.

Add scripts/run-mysql-migrations.sh for host-side applies; update LXC
run-migrate/verify, deployment docs, and .env.example (mysql://, ER_MYSQL_*).

Verified: npm run build + npm test in ingest-api and collector-worker;
npm run build in api. Full docker compose not run here (no local daemon).

Co-Authored-By: Paperclip <[email protected]>
2026-03-22 19:29:11 +00:00
1sonhadorandPaperclip b0b733d5e1 feat(BIT-247): consolidate error reporting repo from OTT
Merge ingest-api, collector-worker, admin-ui, database/error_reporting, deploy/lxc,
docker-compose, and deployment docs into the dedicated repository. Paths updated
for repo root (ER_REPO_ROOT, systemd WorkingDirectory). Root README documents layout.

Co-Authored-By: Paperclip <[email protected]>
2026-03-22 18:20:27 +00:00
1sonhadorandPaperclip eeb5039a3c feat(BIT-183): admin auth, RBAC, audit logging, rate limiting
Implements BIT-154.7 — Auth administrativa, RBAC e quotas:

- api/src/types/auth.ts: 3 roles (superadmin/admin/viewer), 18 permissions,
  ROLE_PERMISSIONS map as single source of truth
- api/src/plugins/auth.ts: JWT via HTTP-only __Host- cookies (15min access /
  7d refresh), token rotation, timing-safe login
- api/src/plugins/rbac.ts: requirePermission() + requireRole() Fastify
  decorators for route-level enforcement
- api/src/plugins/audit.ts: auditLog() helper + Fastify plugin; writes to
  audit_logs table; failure never aborts main operation
- api/src/plugins/rate-limit.ts: per-route limits (login: 10/5min IP,
  ingest: 1000/min token, global: 500/min) + payload size enforcement
- api/src/routes/admin/auth.ts: POST login, POST refresh, POST logout,
  GET /me — with audit events on all operations
- db/migrations/001–004: admin_users, refresh_tokens, audit_logs tables +
  dev seed (bcrypt superadmin)
- web/src/app/(admin)/login: Velzon Bootstrap 5 login page (Next.js client
  component, credentials:include, HTTP-only cookie flow)
- docs/permission-matrix.md: full permission matrix + audit event catalogue
  + rate/payload limit table (BIT-183 acceptance criterion)

Co-Authored-By: Paperclip <[email protected]>
2026-03-22 04:22:57 +00:00
1sonhadorandPaperclip d455a26333 chore: init errors.bitreport.pt repo
Co-Authored-By: Paperclip <[email protected]>
2026-03-22 04:18:09 +00:00