Relocate the ~6k-file docs tree from the repo root into plugins/document-navigator/docs/ so the plugin is self-contained and portable. docs/superpowers/ (specs and plans) stays at the repo root. Moved via cp+rm rather than git mv because directory rename() fails with EPERM on this WSL /mnt DrvFs mount; git rename-detection pairs the identical-content files at commit time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@suaveplan/caddy-imgproxy - Universal TypeScript port of the Caddy imgproxy URL rewriter — compact-grammar parser, aspect / pixel dimension resolver, gravity + operation translator, HMAC-SHA256 URL signer, full handler with Zod-validated config and OTel telemetry
Universal TypeScript port of the Caddy imgproxy URL rewriter.
Parses the compact /u<op><gravity><dims><modifiers>/<path>.<format>
grammar, resolves aspect-ratio + hint dimensions, translates gravity +
operations into imgproxy's URL DSL, signs the result with
HMAC-SHA256, and exposes a high-level ImgproxyHandler orchestrator
with injectable Clock, LoggerLike, and signing hash, plus
Zod-validated configuration and OTel telemetry.
Documentation tree
- config — The
configmodule exposes the Zod schema and the validatingparseConfigfunction for the package's public `Imgproxy…- config — The
configmodule exposes the Zod schema and the validatingparseConfigfunction for the package's public `Imgproxy…
- config — The
- dimensions —
calculateDimensionsresolves aParsedImgproxyUrlplus the configureddefaultWidthinto a concrete `{ width, heigh…- calculate-dimensions —
calculateDimensionsresolves aParsedImgproxyUrlplus the configureddefaultWidthinto a concrete `{ width, heigh…
- calculate-dimensions —
- domain —
extractDomaintranslates an incoming HTTPHostheader into the S3 sub-path segment that the URL builder interpolate…- extract-domain —
extractDomaintranslates an incoming HTTPHostheader into the S3 sub-path segment that the URL builder interpolate…
- extract-domain —
- error-codes — The
error-codesmodule is the canonical home of the package's stable error-code registry and the typed `CaddyImgproxy…- error-codes — The
error-codesmodule is the canonical home of the package's stable error-code registry and the typed `CaddyImgproxy…
- error-codes — The
- gravity — The
gravitymodule exposes the bidirectional translation between the compact one- or two-character grammar codes (t…- gravity — The
gravitymodule exposes the bidirectional translation between the compact one- or two-character grammar codes (t…
- gravity — The
- handler —
ImgproxyHandleris the high-level orchestrator that wrapsparseImgproxyUrl,extractDomain, andbuildImgproxyUrl…- handler —
ImgproxyHandleris the high-level orchestrator that wrapsparseImgproxyUrl,extractDomain, andbuildImgproxyUrl…
- handler —
- operation —
operationToImgproxyconverts a resolved operation + concrete pixel dimensions + gravity into the imgproxy processing-…- operation —
operationToImgproxyconverts a resolved operation + concrete pixel dimensions + gravity into the imgproxy processing-…
- operation —
- parse —
parseImgproxyUrlparses the compact imgproxy URL grammar used by the Caddy module — `/[s|u]<modifi…- parse-url —
parseImgproxyUrlparses the compact imgproxy URL grammar used by the Caddy module — `/[s|u]<modifi…
- parse-url —
- signing —
signImgproxyPathcomputes the HMAC-SHA256 URL signature that imgproxy requires when it is configured with a key + sal…- sign-path —
signImgproxyPathcomputes the HMAC-SHA256 URL signature that imgproxy requires when it is configured with a key + sal…
- sign-path —
- telemetry — The
telemetrymodule owns the OTel instruments emitted by every public entry point in@suaveplan/caddy-imgproxy. It…- telemetry — The
telemetrymodule owns the OTel instruments emitted by every public entry point in@suaveplan/caddy-imgproxy. It…
- telemetry — The
- types — The
typesmodule declares every cross-feature type that flows between the package's runtime modules: `ParsedImgproxyU…- types — The
typesmodule declares every cross-feature type that flows between the package's runtime modules: `ParsedImgproxyU…
- types — The
- url-builder —
buildImgproxyUrlcomposes the final imgproxy URL path from a parsed grammar representation. It is the orchestrator th…- url-builder —
buildImgproxyUrlcomposes the final imgproxy URL path from a parsed grammar representation. It is the orchestrator th…
- url-builder —
Install
bun add @suaveplan/caddy-imgproxy
Quick start
import { ImgproxyHandler, parseConfig } from "@suaveplan/caddy-imgproxy";
const handler = new ImgproxyHandler({
config: parseConfig({
upstream: "imgproxy:8080",
s3Bucket: "media",
defaultWidth: 1200,
key: "aa11bbcc",
salt: "deadbeef",
}),
});
const result = handler.rewrite({
path: "/uvt9:16h1080/photos/hero.webp",
host: "images.example.com",
});
if (result.rewritten) {
forwardToImgproxy(result.targetPath);
} else if (result.reason === "passthrough") {
forwardToImgproxy(originalPath);
}
Modules
- parse — compact-grammar parser.
- dimensions — aspect / hint → pixel resolution.
- gravity — grammar gravity → imgproxy compass tokens.
- operation — operation + dimensions → imgproxy processing string.
- signing — HMAC-SHA256 URL signing.
- url-builder — composes the final imgproxy path.
- domain — Host header → S3 sub-path.
- handler —
ImgproxyHandlerorchestrator. - config — Zod-validated
ImgproxyConfig. - error-codes —
CADDY_IMGPROXY_CODES+CaddyImgproxyError. - telemetry — OTel counters + histogram.
Tier & dependencies
Universal — no DOM or Node-only APIs at the package boundary.
sideEffects: false. Internal deps: @suaveplan/crypto-hash,
@suaveplan/error, @suaveplan/types. External deps:
@opentelemetry/api, tslib, zod.