Skip to content

Commit

Permalink
fix: fetch text file resources from supabase storage
Browse files Browse the repository at this point in the history
  • Loading branch information
fabio-nettis committed Apr 15, 2024
1 parent 485cd99 commit 6dd1da1
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions utils/ascii.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from "path";
import fs from "fs/promises";
const TEXT_URL =
"https://vxspqnuarwhjjbxzgauv.supabase.co/storage/v1/object/public/ascii";

export default async function ascii(
name: string,
Expand All @@ -9,14 +9,17 @@ export default async function ascii(
return;
}

const file = await fs.readFile(
path.join(__dirname, "../ascii", `${name}.txt`),
);
try {
const response = await fetch(`${TEXT_URL}/${name}.txt`);
if (!response.ok) return;

let _ascii = file.toString();
for (const [key, value] of Object.entries(replace)) {
_ascii = _ascii.replace(`[${key.toUpperCase()}]`, value);
}
let _ascii = await response.text();
for (const [key, value] of Object.entries(replace)) {
_ascii = _ascii.replace(`[${key.toUpperCase()}]`, value);
}

console.log(`\n${_ascii}\n`);
console.log(`\n${_ascii}\n`);
} catch {
return;
}
}

0 comments on commit 6dd1da1

Please sign in to comment.