diff options
| author | yyamashita <yyamashita@mosquit.one> | 2026-05-06 22:07:53 +0900 |
|---|---|---|
| committer | yyamashita <yyamashita@mosquit.one> | 2026-05-06 22:07:53 +0900 |
| commit | be55729482296663da8c96723bfd22080e6762c1 (patch) | |
| tree | fcd94b1dc5c55f3a80796c90a555863d13fc9a95 /app/routes/api.scrape.ts | |
| parent | 014b29bc22b1c207a03dd560051ecdd5df63f0b1 (diff) | |
Add Tokyo livehouse event aggregator service
Full-stack React Router v7 app that scrapes event listings from major
Tokyo live venues (Liquid Room, WWW/WWW X, Shibuya O-EAST, Shinjuku LOFT,
Club Quattro) and stores them in SQLite for browsing and search.
- Modular scraper architecture: add a new venue by dropping a file in
app/scrapers/ and registering it in index.ts
- Routes: /events (filter by keyword/venue/date), /events/:id, /venues,
GET /api/scrape
- EventCard shows artist, date/time, venue, ticket URL, and fee
- Post-scrape per-venue Markdown files generated to events/ (dev reference)
- /add-livehouse Claude Code skill defined in .claude/commands/
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'app/routes/api.scrape.ts')
| -rw-r--r-- | app/routes/api.scrape.ts | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/app/routes/api.scrape.ts b/app/routes/api.scrape.ts new file mode 100644 index 0000000..4071985 --- /dev/null +++ b/app/routes/api.scrape.ts @@ -0,0 +1,37 @@ +/** + * Resource route: POST /api/scrape + * Triggers scraping for all venues (or a specific one via ?venue_id=xxx). + * Returns JSON results and redirects back if called from a form. + */ +import { redirect } from "react-router"; +import type { Route } from "./+types/api.scrape"; +import { runAllScrapers, runScraper } from "~/lib/scraper-runner.server"; + +export async function action({ request }: Route.ActionArgs) { + const formData = await request.formData(); + const venueId = formData.get("venue_id"); + + const results = venueId + ? [await runScraper(String(venueId))] + : await runAllScrapers(); + + // If called from a browser form, redirect back + const referer = request.headers.get("Referer"); + if (referer) { + return redirect(referer); + } + + return Response.json({ results }); +} + +// Allow GET for quick testing in the browser +export async function loader({ request }: Route.LoaderArgs) { + const url = new URL(request.url); + const venueId = url.searchParams.get("venue_id"); + + const results = venueId + ? [await runScraper(venueId)] + : await runAllScrapers(); + + return Response.json({ results }); +} |
