feat(ADM-018): completed feature

This commit is contained in:
chattie
2026-08-17 22:23:10 +02:00
parent cf1c69fc8b
commit d595b4871f
871 changed files with 47411 additions and 281 deletions

View File

@@ -0,0 +1,50 @@
# Implementer — F-007 Categories module
done -> work/artifacts/F-007/implementer.md
## Summary
Implemented the categories module as a hexagonal backend slice with PostgreSQL persistence, Fastify routes, validation, tree handling, slug public URLs, and tests.
## Changed files
- `project/src/modules/categories/domain/category.ts`
- `project/src/modules/categories/domain/errors.ts`
- `project/src/modules/categories/domain/ports.ts`
- `project/src/modules/categories/application/category-use-cases.ts`
- `project/src/modules/categories/infrastructure/pg-category-repository.ts`
- `project/src/modules/categories/api/categories.routes.ts`
- `project/src/modules/categories/index.ts`
- `project/migrations/005_categories.js`
- `project/src/app/build-app.ts`
- `project/src/modules/categories/tests/category-use-cases.test.ts`
- `project/src/app/tests/categories.itest.ts`
- `backlog/features.json`
- `work/current.md`
- `work/artifacts/F-007/architect.md`
## Acceptance traceability
1. Duplicate slug returns HTTP 409
- Implemented through `categories_categories.slug UNIQUE` and `CATEGORY_SLUG_EXISTS` mapping.
- Covered by `project/src/app/tests/categories.itest.ts` (`returns HTTP 409 for duplicate slug`).
2. Category tree supports parent/child and blocks cycles
- Implemented with adjacency list `parent_id`, tree builder, self-parent guard, recursive descendant check.
- Covered by unit and integration tests.
3. Public URL is `/categoria/<slug>`, never internal id
- Implemented `GET /categoria/:slug` and serialized `url: /categoria/<slug>`.
- Covered by integration test.
4. `verify.sh` green
- Verified after implementation.
## Commands run
- `cd project && npm run typecheck` — PASS
- `cd project && npm test` — PASS: 55 passed, 25 skipped (DB integration skipped without `TEST_DATABASE_URL`)
- `cd project && npm run lint` — PASS after Prettier normalization
- `cd project && npm run build` — PASS
- `cd project && npm run lint:boundaries` — PASS: 61 files checked
- `./scripts/verify.sh` — PASS
## Notes
- No new npm dependencies.
- Category mutation routes are admin-only using the existing shared auth contract injected from the composition root.
- Public reads (`GET /categories/tree`, `GET /categoria/:slug`) are unauthenticated.
- Corrected delete behavior during review preparation: missing category now maps to `404 NOT_FOUND`; category with children maps to `409 CATEGORY_HAS_CHILDREN`.
- Documentation stage should update README/API notes because new user-facing endpoints were added.