Download server/searchToken.ts from abhijeetsarkargis/MiniSearch: direct link, hf CLI and curl.
- Browser
- Download file 569 Bytes
-
https://huggingface.co/spaces/abhijeetsarkargis/MiniSearch/resolve/main/server/searchToken.ts
- Command line
-
hf download hf://spaces/abhijeetsarkargis/MiniSearch/server/searchToken.ts
-
curl -L -o searchToken.ts https://huggingface.co/spaces/abhijeetsarkargis/MiniSearch/resolve/main/server/searchToken.ts
569 Bytes
| import { existsSync, readFileSync, writeFileSync } from "node:fs"; | |
| import path from "node:path"; | |
| import temporaryDirectory from "temp-dir"; | |
| function getSearchTokenFilePath() { | |
| return path.resolve(temporaryDirectory, "minisearch-token"); | |
| } | |
| export const getSearchToken = () => { | |
| if (!existsSync(getSearchTokenFilePath())) regenerateSearchToken(); | |
| return readFileSync(getSearchTokenFilePath(), "utf8"); | |
| }; | |
| export function regenerateSearchToken() { | |
| const newToken = Math.random().toString(36).substring(2); | |
| writeFileSync(getSearchTokenFilePath(), newToken); | |
| } | |