This commit is contained in:
2025-11-19 22:01:25 +02:00
parent afef35b6f6
commit 3a7686713f
16 changed files with 276 additions and 212 deletions

View File

@@ -10,7 +10,9 @@ const API_URL = "https://api.e-z.host/files";
*/
export async function UploadToEZ(content: Buffer): Promise<string> {
if (!process.env.EZ_API_KEY) {
throw new Error(`Missing EZ_API_KEY, make sure you're loading the env from ${homedir()}/.ocbwoy3-dotfiles-SECRET-DO-NOT-TOUCH.env!`)
throw new Error(
`Missing EZ_API_KEY, make sure you're loading the env from ${homedir()}/.ocbwoy3-dotfiles-SECRET-DO-NOT-TOUCH.env!`,
);
}
if (!(content[0] === 0x89 && content[1] === 0x50 && content[2] === 0x4e)) {
@@ -21,7 +23,7 @@ export async function UploadToEZ(content: Buffer): Promise<string> {
form.append(
"file",
new Blob([content as any], { type: "image/png" }),
"screenshot.png"
"screenshot.png",
);
const res = await fetch(API_URL, {
@@ -34,7 +36,7 @@ export async function UploadToEZ(content: Buffer): Promise<string> {
if (!res.ok) {
throw new Error(
`Upload failed with status ${res.status}: ${await res.text()}`
`Upload failed with status ${res.status}: ${await res.text()}`,
);
}