Cybersecurity-Projects/PROJECTS/beginner/canary-token-generator/backend/internal/token
CarterPerez-dev 9e82f70841 feat(canary): admin handler (stats + tokens list + disable) + repo methods
- internal/admin/handler.go: replaces unused template stats handler
  with the canonical Phase 12 endpoints from spec §8.1:
    GET  /stats                — tokens_count, events_count, by_type,
                                 by_alert_channel
    GET  /tokens               — offset-based pagination, default 50,
                                 cap 100; returns full token.Response
                                 list with trigger/manage URLs via
                                 injected URLBuilder; 400 BAD_PARAM on
                                 negative/non-int offset
    POST /tokens/{id}/disable  — 204 on success; 404 NOT_FOUND envelope
                                 when token.ErrNotFound; 500 envelope
                                 on other repo errors
  Handler takes TokenRepository + EventRepository + URLBuilder
  interfaces (test seam); wire-up supplies *token.Repository,
  *event.Repository, *token.Service (which already implements
  TriggerURL/ManageURL).
- internal/admin/dto.go: Stats, TokenListPage, TokenListResponse.
- token.Repository.CountByType / CountByAlertChannel: GROUP BY type
  and GROUP BY alert_channel; returned shapes typed as TypeCount /
  ChannelCount with json+db tags for direct JSON emission.
- event.Repository.CountAll: global event count.
- Handler tests cover happy path + 500 propagation for each repo
  dependency; pagination (default/limit-cap/offset paging); 400 on
  bad offset; 404 on disable miss; 405 on GET to disable endpoint
  (sanity check that POST-only routing is intentional).
2026-05-14 06:57:28 -04:00
..
generators refactor(canary): consolidate realIP into middleware across 5 generators 2026-05-14 00:31:49 -04:00
contract.go feat(canary): event + notify domain — contracts, senders, services 2026-05-14 00:30:42 -04:00
dto.go feat(canary): manage page handlers + DTOs (GET + DELETE /m/{manage_id}) 2026-05-14 01:07:09 -04:00
entity.go feat(canary): Phase 1 — Postgres schema + token & event repositories 2026-05-10 05:47:24 -04:00
handler.go fix(canary-phase11): use repo-supplied HasMore/NextCursor before rollup 2026-05-14 01:12:07 -04:00
handler_test.go feat(canary): manage page handlers + DTOs (GET + DELETE /m/{manage_id}) 2026-05-14 01:07:09 -04:00
repository.go feat(canary): admin handler (stats + tokens list + disable) + repo methods 2026-05-14 06:57:28 -04:00
repository_test.go feat(canary): admin handler (stats + tokens list + disable) + repo methods 2026-05-14 06:57:28 -04:00
service.go feat(canary): event.CountActiveDedup + token.DeleteByManageID for manage page 2026-05-14 01:06:45 -04:00
service_test.go feat(canary): event.CountActiveDedup + token.DeleteByManageID for manage page 2026-05-14 01:06:45 -04:00
types.go feat(canary): token HTTP handlers (API + trigger routes) 2026-05-13 15:16:41 -04:00