Spaces:
Running
Running
| import { readFile } from "fs/promises"; | |
| import { join } from "path"; | |
| export class DocumentationService { | |
| private cache: string | null = null; | |
| private readonly docsPath: string; | |
| constructor(filename: string = "llms.txt") { | |
| this.docsPath = join(process.cwd(), filename); | |
| } | |
| async load(): Promise<string | null> { | |
| if (this.cache !== null) { | |
| return this.cache; | |
| } | |
| try { | |
| this.cache = await readFile(this.docsPath, "utf-8"); | |
| return this.cache; | |
| } catch { | |
| return null; | |
| } | |
| } | |
| clearCache(): void { | |
| this.cache = null; | |
| } | |
| } | |
| export const documentationService = new DocumentationService(); | |