bknd
Version:
Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.
55 lines (54 loc) • 2.26 kB
TypeScript
import type { AppPlugin } from "../..";
import { s } from "bknd/utils";
/**
* check RequestInitCfPropertiesImage
*/
declare const schema: s.ObjectSchema<{
readonly dpr: s.Schema<s.ISchemaOptions, number | undefined, number | undefined>;
readonly fit: s.Schema<s.ISchemaOptions, "contain" | "cover" | "scale-down" | "crop" | "pad" | undefined, "contain" | "cover" | "scale-down" | "crop" | "pad" | undefined>;
readonly format: s.Schema<s.ISchemaOptions, "jpeg" | "webp" | "avif" | "json" | "auto" | "baseline-jpeg" | undefined, "jpeg" | "webp" | "avif" | "json" | "auto" | "baseline-jpeg" | undefined>;
readonly height: s.Schema<s.ISchemaOptions, number | undefined, number | undefined>;
readonly width: s.Schema<s.ISchemaOptions, number | undefined, number | undefined>;
readonly metadata: s.Schema<s.ISchemaOptions, "none" | "keep" | "copyright" | undefined, "none" | "keep" | "copyright" | undefined>;
readonly quality: s.Schema<s.ISchemaOptions, number | undefined, number | undefined>;
}, s.IObjectOptions>;
export type CloudflareImageOptimizationSchema = s.Static<typeof schema>;
export type CloudflareImageOptimizationOptions = {
/**
* The url to access the image optimization plugin
* @default /api/plugin/image/optimize
*/
accessUrl?: string;
/**
* The path to resolve the image from
* @default /api/media/file
*/
resolvePath?: string;
/**
* Whether to explain the image optimization schema
* @default false
*/
explain?: boolean;
/**
* The default options to use
* @default {}
*/
defaultOptions?: CloudflareImageOptimizationSchema;
/**
* The fixed options to use
* @default {}
*/
fixedOptions?: CloudflareImageOptimizationSchema;
/**
* The cache control to use
* @default public, max-age=31536000, immutable
*/
cacheControl?: string;
/**
* Whether to fallback to the original image if the image optimization fails
* @default false
*/
fallbackRedirect?: boolean;
};
export declare function cloudflareImageOptimization({ accessUrl, resolvePath, explain, defaultOptions, fixedOptions, fallbackRedirect, }?: CloudflareImageOptimizationOptions): AppPlugin;
export {};