mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
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:
@@ -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}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user