mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
feat: add fallback redirect for cloudflare image optimization plugin
Introduced `fallbackRedirect` option to enable a redirect to the original image if image optimization fails. Added logging for platform proxy usage and adjusted `beforeBuild` to handle undefined `app`. Minor improvements and process termination for clear command flow.
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
} from "bknd/adapter/cloudflare";
|
||||
import type { GetPlatformProxyOptions, PlatformProxy } from "wrangler";
|
||||
import process from "node:process";
|
||||
import { $console } from "bknd/utils";
|
||||
|
||||
export type WithPlatformProxyOptions = {
|
||||
/**
|
||||
@@ -25,6 +26,8 @@ export function withPlatformProxy<Env extends CloudflareEnv>(
|
||||
typeof opts?.useProxy === "boolean" ? opts.useProxy : process.env.PROXY === "1";
|
||||
let proxy: PlatformProxy | undefined;
|
||||
|
||||
$console.log("Using cloudflare platform proxy");
|
||||
|
||||
async function getEnv(env?: Env): Promise<Env> {
|
||||
if (use_proxy) {
|
||||
if (!proxy) {
|
||||
|
||||
@@ -15,7 +15,7 @@ import type { Manifest } from "vite";
|
||||
export type BkndConfig<Args = any> = CreateAppConfig & {
|
||||
app?: Omit<BkndConfig, "app"> | ((args: Args) => MaybePromise<Omit<BkndConfig<Args>, "app">>);
|
||||
onBuilt?: (app: App) => MaybePromise<void>;
|
||||
beforeBuild?: (app: App, registries?: typeof $registries) => MaybePromise<void>;
|
||||
beforeBuild?: (app?: App, registries?: typeof $registries) => MaybePromise<void>;
|
||||
buildConfig?: Parameters<App["build"]>[0];
|
||||
};
|
||||
|
||||
@@ -57,6 +57,8 @@ export async function createAdapterApp<Config extends BkndConfig = BkndConfig, A
|
||||
config: Config = {} as Config,
|
||||
args?: Args,
|
||||
): Promise<App> {
|
||||
await config.beforeBuild?.(undefined, $registries);
|
||||
|
||||
const appConfig = await makeConfig(config, args);
|
||||
if (!appConfig.connection || !Connection.isConnection(appConfig.connection)) {
|
||||
let connection: Connection | undefined;
|
||||
|
||||
Reference in New Issue
Block a user