https://github.com/kiritocode1/backend-csv-backup
https://github.com/kiritocode1/backend-csv-backup
Last synced: 20 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/kiritocode1/backend-csv-backup
- Owner: kiritocode1
- Created: 2025-09-03T14:40:56.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-09-03T14:42:22.000Z (11 months ago)
- Last Synced: 2025-12-11T13:57:46.002Z (8 months ago)
- Language: TypeScript
- Size: 116 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# db-stuff
## CSV grep API (Hono + Bun)
Run:
```bash
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:
```bash
bun install
```
To run:
```bash
bun run index.ts
```
This project was created using `bun init` in bun v1.2.13. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.