refactor(api): extract shared artifact-admin helpers (list query, scope defaults, slugify)

オープン
#2,002 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
静か

調査の方向性

Start by comparing the duplicated logic in admin/events/index.ts, admin/events/byId.ts, admin/announcements/index.ts, admin/announcements/byId.ts, and eventsSubmit.ts. Extract the three named helpers into shared modules while preserving the per-artifact route structure, then run the existing test suite; done means all listed routes use the helpers and tests pass.

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

説明

Summary

The admin routes for events and announcements are 80%+ identical: zod validation schemas, list-query where builder, scope-by-author-class defaulting, pagination shape, audit-row writing on PATCH. Plans 4 (forms) and 5 (broadcast) will add more parallel surfaces; extract before that hardens.

Requirements

  • Extract buildArtifactListWhere(table, query, allowedStatuses, allowedScopes) to a shared module
  • Extract inferDefaultScope(actor) helper
  • Extract slugify(name) to packages/api/src/lib/slug.ts (currently duplicated in admin/events/index.ts and eventsSubmit.ts)
  • Refactor admin/events/index.ts, admin/events/byId.ts, admin/announcements/index.ts, admin/announcements/byId.ts, and eventsSubmit.ts to use the shared helpers
  • All existing tests still pass

Context

Flagged in both the Plan 2 and Plan 3 final reviews. Parallel artifact types are intentionally separated at the table level, but the route-construction code wants to be shared.

Implementation Notes

Keep the per-artifact-type sub-app structure (one folder per artifact under routes/admin/) — only the helpers move out. Don't introduce a polymorphic router; that fights Drizzle's type narrowing.

主要言語
HTML
スター
33
フォーク
107
平均マージ
14時間 6分
マージ済み PR(30日)
19

環境構築

はじめの一歩

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

USRSE/usrse.github.io のほかの issue

USRSE/usrse.github.io の issue をすべて見る

似ている issue

Backend & API Design の issue をもっと見る

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

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