mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-28 04:58:52 +00:00
Remove unused Cloudflare image resizing function (#4507)
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
import type { CloudflareImageOptions } from './types';
|
||||
import { copyImageResponse } from './utils';
|
||||
import { getLogger } from '@/lib/logger';
|
||||
|
||||
/**
|
||||
* Resize an image by doing a request to the image itself using the Cloudflare fetch.
|
||||
* https://developers.cloudflare.com/images/transform-images/transform-via-workers/
|
||||
*/
|
||||
export async function resizeImageWithCFFetch(
|
||||
input: string,
|
||||
options: CloudflareImageOptions & {
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
): Promise<Response> {
|
||||
const { signal, ...resizeOptions } = options;
|
||||
|
||||
const logger = getLogger().subLogger('imageResizing');
|
||||
logger.log(`resize image using cf-fetch: ${input}`);
|
||||
|
||||
return copyImageResponse(
|
||||
await fetch(input, {
|
||||
headers: {
|
||||
// Pass the `Accept` header, as Cloudflare uses this to validate the format.
|
||||
Accept:
|
||||
resizeOptions.format === 'json'
|
||||
? 'application/json'
|
||||
: `image/${resizeOptions.format || 'jpeg'}`,
|
||||
},
|
||||
signal,
|
||||
cf: { image: resizeOptions },
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -3,7 +3,6 @@ import assertNever from 'assert-never';
|
||||
|
||||
import { GITBOOK_IMAGE_RESIZE_MODE } from '../../env';
|
||||
import { SizableImageAction, checkIsSizableImageURL } from '../checkIsSizableImageURL';
|
||||
import { resizeImageWithCFFetch } from './cf-fetch';
|
||||
import { resizeImageWithGitbookServices } from './gitbook-service';
|
||||
import type { CloudflareImageJsonFormat, CloudflareImageOptions } from './types';
|
||||
import { getLogger } from '@/lib/logger';
|
||||
@@ -73,7 +72,6 @@ export async function resizeImage(
|
||||
|
||||
switch (GITBOOK_IMAGE_RESIZE_MODE) {
|
||||
case 'cf-fetch':
|
||||
return resizeImageWithCFFetch(input, options);
|
||||
case 'gitbook-service':
|
||||
case 'cdn-cgi':
|
||||
return resizeImageWithGitbookServices(input, options);
|
||||
|
||||
Reference in New Issue
Block a user