diff options
| author | yyamashita <yyamashita@mosquit.one> | 2026-05-09 11:21:28 +0900 |
|---|---|---|
| committer | yyamashita <yyamashita@mosquit.one> | 2026-05-09 11:21:28 +0900 |
| commit | cd8787b77dadf752826a967d404b718b3ec92601 (patch) | |
| tree | a1e5471ba59404caf5c3c7684a4cfc08027a5a4b /README.md | |
| parent | 08c410c28eeb3d7a4c41014d8926b765441546c4 (diff) | |
Add JSON API endpoints and CLI script for band/artist management
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 74 |
1 files changed, 74 insertions, 0 deletions
@@ -25,6 +25,80 @@ | `/artists/of/:uuid/history` | アーティスト編集履歴 | | `/artists/new` | アーティスト新規作成 | +## API + +サーバー起動中に JSON API で操作できます。 + +### バンド + +```bash +# 一覧取得 +curl http://localhost:5173/api/bands + +# 新規作成 +curl -X POST http://localhost:5173/api/bands \ + -H "Content-Type: application/json" \ + -d '{ + "name": "バンド名", + "area": "Tokyo", + "status": "active", + "description": "説明文", + "links": [{"label": "Twitter", "url": "https://..."}], + "artists": [{"id": "<artist-uuid>", "role": "Vocal"}], + "message": "初回登録" + }' +``` + +### アーティスト + +```bash +# 一覧取得 +curl http://localhost:5173/api/artists + +# 新規作成 +curl -X POST http://localhost:5173/api/artists \ + -H "Content-Type: application/json" \ + -d '{"name": "アーティスト名", "links": [{"label": "Twitter", "url": "https://..."}]}' +``` + +`slug` は省略すると名前から自動生成。成功時は `201` + 作成したレコードの JSON を返します。slug 重複時は `409`。 + +## CLI + +サーバー不要でローカルの DB に直接書き込みます。プロジェクトルートから実行してください。 + +```bash +# アーティスト登録 +npm run add -- artist --name "アーティスト名" + +# バンド登録 +npm run add -- band --name "バンド名" --area Tokyo --status active + +# JSON ファイルから一括インポート +npm run add -- import --file data.json +``` + +### 一括インポートの JSON 形式 + +```json +{ + "artists": [ + {"name": "アーティスト A", "links": [{"label": "Twitter", "url": "https://..."}]} + ], + "bands": [ + { + "name": "バンド X", + "area": "Tokyo", + "status": "active", + "artists": [{"name": "アーティスト A", "role": "Vocal"}], + "links": [{"label": "Twitter", "url": "https://..."}] + } + ] +} +``` + +`artists` を先に処理するので、`bands` 側でアーティスト名を参照できます。既存のアーティスト(名前一致)はスキップ。 + ## 技術スタック - [React Router v7](https://reactrouter.com/) (SSR フレームワーク) |
