style: auto-fix linting issues

This commit is contained in:
EduardPrigoanaAlt 2026-02-21 11:27:11 +00:00 committed by github-actions[bot]
parent 2a05de8b34
commit 5fe3a7068a

View file

@ -1,37 +1,37 @@
const BASE = "https://temp.imgur.gg"; const BASE = 'https://temp.imgur.gg';
export async function onRequest(context) { export async function onRequest(context) {
const { request } = context; const { request } = context;
if (request.method !== "POST") { if (request.method !== 'POST') {
return new Response("Method not allowed", { status: 405 }); return new Response('Method not allowed', { status: 405 });
} }
const formData = await request.formData(); const formData = await request.formData();
const file = formData.get("file"); const file = formData.get('file');
if (!file) { if (!file) {
return new Response("No file", { status: 400 }); return new Response('No file', { status: 400 });
} }
const buffer = await file.arrayBuffer(); const buffer = await file.arrayBuffer();
// 1. GET site to grab cookie // 1. GET site to grab cookie
const getRes = await fetch(BASE, { const getRes = await fetch(BASE, {
method: "GET", method: 'GET',
}); });
const setCookie = getRes.headers.get("set-cookie") || ""; const setCookie = getRes.headers.get('set-cookie') || '';
const cookie = setCookie.split(";")[0]; // _s=xxxxx const cookie = setCookie.split(';')[0]; // _s=xxxxx
// 2. Request metadata WITH cookie // 2. Request metadata WITH cookie
const metadataRes = await fetch(`${BASE}/api/upload`, { const metadataRes = await fetch(`${BASE}/api/upload`, {
method: "POST", method: 'POST',
headers: { headers: {
"Content-Type": "application/json", 'Content-Type': 'application/json',
Cookie: cookie, Cookie: cookie,
Origin: BASE, Origin: BASE,
Referer: BASE + "/", Referer: BASE + '/',
}, },
body: JSON.stringify({ body: JSON.stringify({
files: [ files: [
@ -46,7 +46,7 @@ export async function onRequest(context) {
if (!metadataRes.ok) { if (!metadataRes.ok) {
const text = await metadataRes.text(); const text = await metadataRes.text();
return new Response("Metadata failed: " + text, { status: 500 }); return new Response('Metadata failed: ' + text, { status: 500 });
} }
const metadata = await metadataRes.json(); const metadata = await metadataRes.json();
@ -55,21 +55,20 @@ export async function onRequest(context) {
// 3. Upload to signed URL // 3. Upload to signed URL
const uploadRes = await fetch(uploadInfo.uploadUrl, { const uploadRes = await fetch(uploadInfo.uploadUrl, {
method: "PUT", method: 'PUT',
headers: { headers: {
"Content-Type": file.type, 'Content-Type': file.type,
}, },
body: buffer, body: buffer,
}); });
if (!uploadRes.ok) { if (!uploadRes.ok) {
return new Response("Upload failed", { status: 500 }); return new Response('Upload failed', { status: 500 });
} }
// 4. Return public URL // 4. Return public URL
const publicUrl = const publicUrl = `https://i.imgur.gg/${uploadInfo.fileId}-${uploadInfo.fileName}`;
`https://i.imgur.gg/${uploadInfo.fileId}-${uploadInfo.fileName}`;
return new Response( return new Response(
JSON.stringify({ JSON.stringify({
@ -77,7 +76,7 @@ export async function onRequest(context) {
url: publicUrl, url: publicUrl,
}), }),
{ {
headers: { "Content-Type": "application/json" }, headers: { 'Content-Type': 'application/json' },
} }
); );
} }