From 05ad3bd37b16cf687555ec90f0f16d6b6db3cc25 Mon Sep 17 00:00:00 2001 From: Brian Funk Date: Fri, 2 Oct 2026 00:46:17 -0400 Subject: [PATCH 01/12] feat: Netlify website and HTTP API - web/: static site with live results for every style, click to copy, shareable ?t= URLs, dark mode, no build step (imports index.js directly) - netlify/functions/api.js: single Functions 2.0 handler for /api/* (styles, :style/:text, all, chain, batch) with CORS, caching, limits - netlify.toml: publish web/, copy index.js at build, security headers - Tests for the API handler via Request objects and a browser-safety guard - Docs: README Try it online + HTTP API sections, CLAUDE.md, AGENTS.md --- .gitignore | 4 + AGENTS.md | 6 + CHANGELOG.md | 2 + CLAUDE.md | 10 +- README.md | 43 +++++++ eslint.config.js | 24 +++- netlify.toml | 29 +++++ netlify/functions/api.js | 235 +++++++++++++++++++++++++++++++++++ package.json | 4 +- test/api.test.js | 254 ++++++++++++++++++++++++++++++++++++++ test/browser-safe.test.js | 26 ++++ vitest.config.js | 4 +- web/app.js | 117 ++++++++++++++++++ web/index.html | 63 ++++++++++ web/style.css | 139 +++++++++++++++++++++ 15 files changed, 953 insertions(+), 7 deletions(-) create mode 100644 netlify.toml create mode 100644 netlify/functions/api.js create mode 100644 test/api.test.js create mode 100644 test/browser-safe.test.js create mode 100644 web/app.js create mode 100644 web/index.html create mode 100644 web/style.css diff --git a/.gitignore b/.gitignore index aa6f0f0..6629f3a 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,7 @@ jspm_packages # Optional REPL history .node_repl_history + +# Netlify +.netlify +web/capstring.js diff --git a/AGENTS.md b/AGENTS.md index 008728a..5b79b20 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -58,6 +58,12 @@ CATEGORIES; // frozen { case, code, fun, encoding, art } - `cli.js` - CLI logic as `main(argv, io)`; `bin/capstring.js` is the executable shim. - `index.d.ts` - hand-written types. `test/types.test.js` fails if the `Style` union drifts from `STYLES`. +## Website and API + +- `web/` - static site, imports `./capstring.js` (copied from `index.js` at Netlify build time) +- `netlify/functions/api.js` - HTTP API at `https://capstring.netlify.app/api` +- `npm run dev` runs both locally on http://localhost:8888 + ## Testing ```bash diff --git a/CHANGELOG.md b/CHANGELOG.md index 58704a4..dbdc08c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- **Website**: [capstring.netlify.app](https://capstring.netlify.app) - live preview of every style, click to copy, shareable URLs +- **HTTP API**: `/api/:style/:text`, `/api/all`, `/api/chain`, `/api/styles`, `POST /api/batch` as a single Netlify Function (replaces the archived cAPIta project) - **8 new styles** (37 total): `smallcaps`, `bubble`, `wide`, `strike`, `clap`, `morse`, `binary`, `piglatin` - **CLI**: `npx capstring