Let people delete their own comments

Aperta
#128 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
express, nodejs, react, typescript
Ambito
backend, frontend

Direzione di ricerca

Start in apps/api/src/controllers/postController.ts and read createComment next to listComments to see how authorship and the post's commentCount are handled, then check apps/api/src/models/Comment.ts for the fields you can authorize against. Add a DELETE /api/comments/:id route with backend tests covering the author, the post author, an admin and a refused third party. On the web side, add the confirm-and-delete button in apps/web/src/pages/PostPage.tsx and reuse the cache helpers in usePosts.ts so the count updates without a reload. Done means npm run typecheck, npm test and lint pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

api enhancement good first issue web

Difficulty: Beginner to Intermediate · Estimated size: half a day to 1 day

Context

Comments can be listed and created (/api/posts/:id/comments), but there is no way to remove one you wrote by mistake.

Problem or goal

Add deleting a comment. The author, the post's author and admins can delete a comment.

Suggested approach

  • API: DELETE /api/comments/:id, decrement commentCount on the post in the same step, and write a test for each allowed and refused role.
  • Web: a delete button (with a confirm step) on each comment on the post page; update the comment count in all cached lists using the helpers in usePosts.ts.

Where to look

  • apps/api/src/controllers/postController.ts (listComments, createComment)
  • apps/api/src/models/Comment.ts
  • apps/web/src/pages/PostPage.tsx

Acceptance criteria

  • The count never goes below zero or drifts.
  • A person cannot delete someone else's comment unless they own the post or are an admin.
  • The list updates without a reload.

How to work on it

  1. Comment here to claim it, so two people do not do the same work.
  2. Fork the repo and branch from main (feat/short-name or fix/short-name). Setup steps are in docs/DEVELOPMENT.md.
  3. Keep the change focused and add tests for backend logic.
  4. Run npm run typecheck, npm test and npm run lint and npm run format before opening the pull request.
  5. Use a Conventional Commits title (for example feat(web): add bookmarks). More in CONTRIBUTING.md.

Stuck? Ask in this issue. Questions are welcome.


Generated by Claude Code

Lingua principale
TypeScript
Stelle
6
Fork
6
Merge medio
1h 59m
PR unite (30g)
59

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Haseeb-MernStack/commune

Tutte le issue di Haseeb-MernStack/commune

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.