An API for my personal portfolio
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

TypeScript 93.3%
Nix 6.7%
14 1 0

Clone this repository

https://tangled.org/matthew-hre.com/api.matthew-hre.com https://tangled.org/did:plc:jb2t76xy3xkgzeddixkzvntp/api.matthew-hre.com
git@knot.matthew-hre.com:matthew-hre.com/api.matthew-hre.com git@knot.matthew-hre.com:did:plc:jb2t76xy3xkgzeddixkzvntp/api.matthew-hre.com

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

api.matthew-hre.com#

Personal API powering matthew-hre.com. Built with Hono on Cloudflare Workers, backed by D1, and managed with Wrangler.

Endpoints#

GET /vinyl#

Paginated vinyl collection, synced from Discogs every 6 hours via cron.

Param Default Options
page 1
sort added title, artist, added
order desc asc, desc

GET /activity/music#

Currently playing (or last played) track from Last.fm. Polled into D1 every minute by a cron trigger.

GET /activity/music/stream#

SSE stream that pushes track changes. Reads from the D1-cached value every 10s and emits when it changes.

Local Development#

nix develop                              # gets you bun + wrangler

bun install
wrangler d1 create api                   # one-time; copy the id into wrangler.toml
bun run migrate:local                    # applies migrations/ to local D1
bun run dev                              # starts the worker on :8787

Trigger the cron handlers locally with:

# Last.fm poll
curl 'http://localhost:8787/__scheduled?cron=*+*+*+*+*'
# Discogs sync
curl 'http://localhost:8787/__scheduled?cron=0+*/6+*+*+*'

Deployment#

bun run migrate:remote    # apply migrations to remote D1
bun run deploy            # wrangler deploy

Secrets#

Set with wrangler secret put <NAME>:

Variable Description
DISCOGS_PERSONAL_ACCESS_TOKEN Discogs API token
LASTFM_API_KEY Last.fm API key

LASTFM_USERNAME and DISCOGS_USER are plain [vars] in wrangler.toml.