Skip to content

kiritocode1/backend-csv-backup

Repository files navigation

db-stuff

CSV grep API (Hono + Bun)

Run:

bun run server.ts

Base URL: http://localhost:8787

Endpoints

  • GET /health

    • Returns: { ok: true }
  • GET /csv

    • Returns raw CSV (text/csv)
  • GET /columns

    • Returns: { columns: string[] }
    • Notes: Header normalization applied
      • "Uplad Date" → "Upload Date"
      • Duplicate "Latitude" → last becomes "Longitude"
  • GET /grep

    • Query:
      • pattern (required): regex pattern
      • flags (optional): JS regex flags (e.g. i, m)
      • max (optional): max matches (default 200, cap 1000)
    • Returns: { count: number, matches: { line: number, text: string }[] }
  • GET /unique

    • Query:
      • column (required): column name (raw or normalized)
      • limit (optional): max unique values (default 1000, cap 5000)
    • Returns: { column: string, values: string[] }
    • Aliases supported:
      • Upload Date: ["Uplad Date","Upload Date","Timestamp","Date"]
      • Latitude: ["Latitude","Lat"]
      • Longitude: ["Longitude","Lat_1","Latitude_1","Latitude (2)","Lng"]
      • Police Station: ["Police Station","PoliceStation","police_station"]
      • Festival/Event Name: ["Festival/Event Name","FestivalEventName","festival_event_name"]
      • Point Name: ["Point Name","PointName","point_name"]
      • Section/Appendix: ["Section/Appendix","SectionAppendix","section_appendix"]
  • GET /counts

    • Query:
      • column (required): column name (raw or normalized)
    • Returns: { column: string, counts: { value: string, count: number }[] } sorted desc by count

Quick links (after starting the server)

  • Health: /health
  • Columns: /columns
  • Raw CSV: /csv
  • Grep (example): /grep?pattern=Sinnar&flags=i&max=50
  • Unique police stations: /unique?column=Police%20Station
  • Counts by police station: /counts?column=Police%20Station
  • Unique longitude (normalized): /unique?column=Longitude To install dependencies:
bun install

To run:

bun run index.ts

This project was created using bun init in bun v1.2.13. Bun is a fast all-in-one JavaScript runtime.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published