Skip to content

feat: Netlify website and HTTP API, Node 22 floor - #9

Open
brianfunk wants to merge 4 commits into
feat/v1.1.0-hardeningfrom
feat/netlify-site-api
Open

brianfunk wants to merge 4 commits into
feat/v1.1.0-hardeningfrom
feat/netlify-site-api

Conversation

@brianfunk

@brianfunk brianfunk commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

Stacked on #8. Adds the fun face (website) and the serious face (HTTP API) of capstring, in this repo, with zero build step. Also raises the Node floor to 22.12 so the test toolchain can move to vitest 5 / eslint 10 and clear every Dependabot alert.

Website (web/)

  • Textarea in, every style out, grouped by category. Click a row to copy, toast confirms.
  • Chain builder: press + on any row to compose up to 10 styles; result, copy button, and /api/chain curl update live. Shareable as ?chain=upper+reverse.
  • Shareable ?t= URLs, dark mode, mobile layout, Open Graph + Twitter meta, 404 page, version in footer from /api.
  • No frameworks, no analytics. Imports ./capstring.js, which the Netlify build copies from index.js.

API (netlify/functions/api.js, one Functions 2.0 handler owning /api/*)

  • GET /api/styles, GET /api/:style/:text, GET /api/all/:text, GET /api/chain/:styles/:text, POST /api/batch
  • Ported from cAPIta: GET /api/badge/:style/:text (shields-style SVG, ?label=), GET /api/lorem/:count?style=, GET /api/spell/:text?style= (nspell + dictionary-en, lazy-loaded so other routes don't pay for it)
  • CORS on everything, Cache-Control public except for random and POST, ?format=txt, ?pretty=1, ?text= override
  • Limits: 2,000 chars, 100 texts per batch, 10 styles per chain, 1,000 lorem words. Structured { error: { code, message } } responses.

Dependencies: nspell and dictionary-en are devDependencies on purpose. esbuild bundles them into the function; the npm package stays zero-dependency. dictionary-en is marked external + included_files in netlify.toml because it reads its .aff/.dic files by path.

Node: engines >=22.12.0, CI matrix 22 and 24. Node 18 and 20 are end-of-life. Documented under Behavior changes in CHANGELOG.

Test plan

  • npm run lint clean (eslint 10)
  • npm run test:coverage 141 tests, 100% statements / branches / functions / lines on index.js, cli.js, api.js
  • npm audit 0 vulnerabilities
  • npm pack --dry-run still excludes web/ and netlify/
  • npm run dev: curled transform, slug, batch, spell (helo speling → Hello Spelling), badge (SVG), lorem (?style=kebab), 404 page, /capstring.js
  • Loaded the page in Chrome: grid rendered from ?t=, click-to-copy toast fired, curl line switched to the selected style, no console errors

After merging: netlify init in the Brian Funk team as site capstring, production branch master, branch deploys for dev.

- 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
- Trigger CI for pull requests against any branch so stacked PRs get checks
- npm audit fix: clears 22 Dependabot alerts in dev-only transitive deps
… in range

npm audit fix had bumped vitest to 4.1 / vite 8, which requires Node 20.19+
and broke the Node 18 CI job. Revert that and update only the transitive
packages that have fixes within vitest 4.0.18's ranges (18 of 22 alerts).
The remaining 4 are in vite 7 / @vitest/mocker and are dev-only; they clear
when Node 18 support is dropped.
… polish

- Require Node 22.12+; CI matrix 22/24; vitest 5, eslint 10; zero audit findings
- API: GET /api/badge/:style/:text (SVG), /api/lorem/:count?style=,
  /api/spell/:text?style= (nspell + dictionary-en as devDependencies,
  bundled into the function; the npm package stays zero-dependency)
- Site: chain builder (+ on each row, ?chain= in the URL), Open Graph and
  Twitter meta tags, 404 page, version in footer from /api
- 141 tests, 100% coverage on index.js, cli.js, api.js
@brianfunk brianfunk changed the title feat: Netlify website and HTTP API feat: Netlify website and HTTP API, Node 22 floor Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant