docs: plugins, cloudflare, sdk, elements, database (#240)

* docs: added plugins docs, updated cloudflare docs

* updated cli help text

* added `systemEntity` and added docs on how to work with system entities

* docs: added defaults to cloudflare image plugin

* docs: updated sdk and elements
This commit is contained in:
dswbx
2025-08-29 12:50:23 +02:00
committed by GitHub
parent 5b879ac6bf
commit 5ed1cf19b6
17 changed files with 655 additions and 100 deletions

View File

@@ -19,22 +19,46 @@ const schema = s.partialObject({
type ImageOptimizationSchema = 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?: ImageOptimizationSchema;
/**
* The fixed options to use
* @default {}
*/
fixedOptions?: ImageOptimizationSchema;
/**
* The cache control to use
* @default public, max-age=31536000, immutable
*/
cacheControl?: string;
};
export function cloudflareImageOptimization({
accessUrl = "/_plugin/image/optimize",
accessUrl = "/api/plugin/image/optimize",
resolvePath = "/api/media/file",
explain = false,
defaultOptions = {},
fixedOptions = {},
}: CloudflareImageOptimizationOptions = {}): AppPlugin {
const disallowedAccessUrls = ["/api", "/admin", "/_optimize"];
const disallowedAccessUrls = ["/api", "/admin", "/api/plugin"];
if (disallowedAccessUrls.includes(accessUrl) || accessUrl.length < 2) {
throw new Error(`Disallowed accessUrl: ${accessUrl}`);
}