fix(public-api): use schema fields order and type in V1BioLinksController

Aperta Adatta ai principianti
#46 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à
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
85/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
postgresql, typescript

Direzione di ricerca

Leggi apps/api/src/public-api/controllers/v1-bio-links.controller.ts insieme ai modelli indicati in packages/prisma/schema.prisma. Aggiorna i campi di ordinamento, i filtri delle analitiche e la convalida degli URL descritti nel problema, quindi esegui gli endpoint /v1/bio-links elencati o i relativi test esistenti. Il lavoro è completato quando questi endpoint funzionano con lo schema senza errori relativi ai campi Prisma e rifiutano gli URL che non usano HTTP o HTTPS.

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

Descrizione

backend bug good first issue
Problem Description

In apps/api/src/public-api/controllers/v1-bio-links.controller.ts, multiple /v1/bio-links endpoints query or write non-existent Prisma fields that do not match packages/prisma/schema.prisma, causing runtime Prisma validation errors on every call:

  1. position used instead of order:

    • getBioPageOrThrow (lines 35-38) passes orderBy: { position: 'asc' } for links, products, socialButtons, and faqs.
    • addLink (lines 104 & 113) reads l.position and writes position: maxPos + 1.
    • In packages/prisma/schema.prisma, BioProduct, BioSocialButton, BioLink, and BioFaq all use order (Int @default(0)), not position.
  2. eventType used instead of type:

    • getAnalytics (lines 170 & 173) queries bioAnalyticsEvent.count with eventType: 'PAGE_VIEW' and eventType: 'LINK_CLICK'.
    • In packages/prisma/schema.prisma, BioAnalyticsEvent (line 1006) uses type (String // "view" or "click"), not eventType.

Expected Behavior
  • All /v1/bio-links endpoints (GET /v1/bio-links, PATCH /v1/bio-links, GET/POST/DELETE /v1/bio-links/links, GET /v1/bio-links/products, GET /v1/bio-links/leads, GET /v1/bio-links/analytics) execute cleanly against the Prisma schema without runtime field errors.
  • addLink should also validate body.url uses an http: or https: scheme before saving.

Where to Look
  • apps/api/src/public-api/controllers/v1-bio-links.controller.ts (lines 31-49, 104-114, 162-189)
  • packages/prisma/schema.prisma (BioProduct, BioSocialButton, BioLink, BioFaq, BioAnalyticsEvent)

Solution / Implementation Guide
  1. In getBioPageOrThrow (lines 35-38), replace orderBy: { position: 'asc' } with orderBy: { order: 'asc' } on links, products, socialButtons, and faqs.
  2. In addLink (lines 104-114), replace l.position with l.order and position: maxPos + 1 with order: maxOrder + 1 (and validate body.url is a valid http:/https: URL).
  3. In getAnalytics (lines 170 & 173), replace eventType: 'PAGE_VIEW' with type: 'view' and eventType: 'LINK_CLICK' with type: 'click'.
Lingua principale
TypeScript
Stelle
2
Fork
1
Merge medio
6m
PR unite (30g)
27

Preparare l'ambiente

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 sumamakhan761/tryinstance

Tutte le issue di sumamakhan761/tryinstance

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.