ReviewOS

also looking at this

stacks/rpx

feat: imgx integration — on-the-fly image transforms from query params

#2264
Merged glennmichael123 wants to merge feat/imgx-integration into main
15 files +1118 -16
packages/rpx/src/types.tsmodified+36-2
Changes to packages/rpx/src/types.ts
@@ -404,6 +404,34 @@ export interface LocalCaConfig {
404404 renewBeforeDays?: number
405405}
406406
407/**
408 * imgx integration: serve on-the-fly image transforms driven by
409 * imgix/meema-style query params (`?w=200&h=1200&q=80&format=webp`), powered by
410 * the pure-TypeScript `ts-images` pipeline. `true` enables the defaults; an
411 * object tunes them. Enabled globally or per proxy; transformed variants are
412 * cached in memory keyed by the upstream bytes, so an unchanged image is never
413 * re-encoded twice.
414 */
415export interface ImgxOptions {
416 /** Encode quality used when the request has no `q` param. @default 80 */
417 quality?: number
418 /** Upper clamp for the requested output width. @default 8192 */
419 maxWidth?: number
420 /** Upper clamp for the requested output height. @default 8192 */
421 maxHeight?: number
422 /**
423 * Responses larger than this many bytes pass through untransformed (they
424 * keep streaming; nothing is buffered past the cap). @default 33554432 (32 MiB)
425 */
426 maxInputBytes?: number
427 /** Cache transformed variants in memory. @default true */
428 cache?: boolean
429 /** Total byte budget for the transform cache. @default 67108864 (64 MiB) */
430 cacheMaxBytes?: number
431 /** Max entries in the transform cache. @default 500 */
432 cacheMaxEntries?: number
433}
434
407435export interface SharedProxyConfig {
408436 /**
409437 * `true` mints and trusts a local dev certificate, a {@link TlsOption} points
@@ -419,6 +447,12 @@ export interface SharedProxyConfig {
419447 start?: StartOptions
420448 cleanUrls: boolean
421449 changeOrigin?: boolean // default: false - changes the origin of the host header to the target URL
450 /**
451 * Transform image responses on the fly from imgix/meema-style query params
452 * (`?w=200&h=1200&q=80`) via the imgx (ts-images) pipeline — see {@link ImgxOptions}.
453 * Default: `false`. Overridable per proxy in multi-proxy configs.
454 */
455 imgx?: boolean | ImgxOptions
422456 regenerateUntrustedCerts?: boolean // If true, will regenerate and re-trust certs that exist but are not trusted by the system.
423457 /**
424458 * Route every proxy through a single shared listener instead of binding a
@@ -512,7 +546,7 @@ export type SharedProxyOptions = Partial<SharedProxyConfig>
512546export interface SingleProxyConfig extends BaseProxyConfig, SharedProxyConfig {}
513547
514548export interface MultiProxyConfig extends SharedProxyConfig {
515 proxies: Array<BaseProxyConfig & { cleanUrls: boolean, pathRewrites?: PathRewrite[] }>
549 proxies: Array<BaseProxyConfig & { cleanUrls: boolean, pathRewrites?: PathRewrite[], imgx?: boolean | ImgxOptions }>
516550}
517551
518552export type ProxyConfig = SingleProxyConfig
@@ -530,7 +564,7 @@ export type ProxyOptions = Partial<SingleProxyConfig> | Partial<MultiProxyConfig
530564 * single and multi shapes without falling back to `any`.
531565 */
532566export type ResolvedProxyOptions = Partial<SingleProxyConfig> & {
533 proxies?: Array<BaseProxyConfig & { cleanUrls?: boolean, changeOrigin?: boolean, pathRewrites?: PathRewrite[] }>
567 proxies?: Array<BaseProxyConfig & { cleanUrls?: boolean, changeOrigin?: boolean, pathRewrites?: PathRewrite[], imgx?: boolean | ImgxOptions }>
534568}
535569
536570export interface SSLConfig {