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

Đang mở Phù hợp với người mới
#46 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
85/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
postgresql, typescript

Hướng nghiên cứu

Đọc apps/api/src/public-api/controllers/v1-bio-links.controller.ts cùng với các model được nêu trong packages/prisma/schema.prisma. Cập nhật các trường sắp xếp, bộ lọc analytics và xác thực URL được mô tả trong issue, sau đó chạy các endpoint /v1/bio-links được liệt kê hoặc các bài kiểm tra hiện có của chúng. Hoàn tất khi các endpoint đó chạy với schema mà không gặp lỗi trường Prisma và từ chối URL không sử dụng HTTP hoặc HTTPS.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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'.
Ngôn ngữ chính
TypeScript
Star
2
Fork
1
Merge trung bình
6 phút
Pull request đã merge (30 ngày)
27

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của sumamakhan761/tryinstance

Tất cả issue của sumamakhan761/tryinstance

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.