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

オープン 初心者向け
#46 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
85/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
postgresql, typescript

調査の方向性

apps/api/src/public-api/controllers/v1-bio-links.controller.tsを、packages/prisma/schema.prisma内の指定されたモデルとあわせて読みます。Issueに記載された並び順フィールド、分析フィルター、URL検証を更新し、一覧にある/v1/bio-linksエンドポイントまたは既存のテストを実行します。これらのエンドポイントがPrismaのフィールドエラーなしでスキーマに対して実行でき、HTTPまたはHTTPSを使用しないURLを拒否すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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'.
主要言語
TypeScript
スター
2
フォーク
1
平均マージ
6分
マージ済み PR(30日)
27

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

sumamakhan761/tryinstance のほかの issue

sumamakhan761/tryinstance の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。