Skip to content

Commit

Permalink
fix: wordle, pull from gist instead
Browse files Browse the repository at this point in the history
  • Loading branch information
royce-mathew committed Feb 13, 2025
1 parent bf4c852 commit 3a3b81b
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/app/(app)/apps/wordle/get-word.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
"use server"

import fs from "fs/promises"
import path from "path"

let validWords: string[] | null = null
let allWords: string[] | null = null

const allWordsGistUrl =
"https://gist.githubusercontent.com/royce-mathew/ff9bb6455fbd4f7cff532b2a5b4900c4/raw/possible-words.txt"
const validWordsGistUrl =
"https://gist.githubusercontent.com/royce-mathew/50f4a64ee7ea9793fa00c903ea4e7dcf/raw/words.txt"

async function loadWords() {
if (!validWords) {
const wordsFile = await fs.readFile(
path.join(process.cwd(), "public/files/words.txt"),
"utf8"
)
const response = await fetch(validWordsGistUrl)
const wordsFile = await response.text()
validWords = wordsFile.split("\n").map((word) => word.trim())
}
}

async function loadAllWords() {
if (!allWords) {
const allWordsFile = await fs.readFile(
path.join(process.cwd(), "public/files/possible-words.txt"),
"utf8"
)
allWords = allWordsFile.split("\n").map((word) => word.trim())
const response = await fetch(allWordsGistUrl)
const wordsFile = await response.text()
allWords = wordsFile.split("\n").map((word) => word.trim())
}
}

Expand Down

0 comments on commit 3a3b81b

Please sign in to comment.