this repo has no description
1import type { CDNUploadResponse } from "../types";
2
3export async function uploadToCDN(
4 fileUrls: string[],
5): Promise<CDNUploadResponse> {
6 const response = await fetch("https://cdn.hackclub.com/api/v3/new", {
7 method: "POST",
8 headers: {
9 Authorization: `Bearer ${process.env.CDN_TOKEN}`,
10 "X-Download-Authorization": `Bearer ${process.env.SLACK_BOT_TOKEN}`,
11 "Content-Type": "application/json",
12 },
13 body: JSON.stringify(fileUrls),
14 });
15
16 if (!response.ok) {
17 throw new Error(`CDN upload failed: ${response.statusText}`);
18 }
19
20 return (await response.json()) as CDNUploadResponse;
21}