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

Open Beginner friendly
#46 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
postgresql, typescript

Research direction

Read apps/api/src/public-api/controllers/v1-bio-links.controller.ts alongside the named models in packages/prisma/schema.prisma. Update the ordering fields, analytics filters, and URL validation described in the issue, then exercise the listed /v1/bio-links endpoints or their existing tests. Done means those endpoints run against the schema without Prisma field errors and reject URLs that do not use HTTP or HTTPS.

Written by the indexing model from the issue text.

Description

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'.
Dominant language
TypeScript
Stars
2
Forks
1
Avg merge
6m
Merged PRs (30d)
27

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sumamakhan761/tryinstance

All issues in sumamakhan761/tryinstance

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.