Backend API

The blog's API in Go. One SQLite file, posts served as JSON with the HTML rendered.

apps/be serves the posts the landing's blog shows. Markdown files in content/ stay the source of truth and are seeded into one SQLite file.

cd apps/be
BE_ADMIN_TOKEN=change-me go run ./cmd/be     # :8787
go vet ./... && gofmt -l . && go test -race ./...
VariableDefault
BE_ADDR:8787
BE_DB_PATHdata/helico.db
BE_ADMIN_TOKENempty; writes refused with 503
BE_CORS_ORIGINShttp://localhost:4321,http://localhost:4322
BE_CONTENT_DIRcontent
BE_REQUEST_TIMEOUT10s
RouteAuthAnswer
GET /healthzok
GET /api/posts?limit=20&cursor=items and a keyset cursor, newest first, ETag
GET /api/posts/slugthe post with html and markdown; 304 on If-None-Match
PUT /api/posts/slugbearercreate 201 or replace 200
DELETE /api/posts/slugbearer204

Errors are application/problem+json; JSON over 1 KiB is gzipped; reads carry Cache-Control: public, max-age=60, stale-while-revalidate=300.