1 2 3 4 5 6 7 8 9 10 11 12
| export class SessionStorage { async save(session: Session): Promise<void> { const filePath = `${this.sessionsDir}/${session.id}.json`; await fs.writeFile(filePath, JSON.stringify(session, null, 2)); } async load(sessionId: string): Promise<Session> { const filePath = `${this.sessionsDir}/${sessionId}.json`; const content = await fs.readFile(filePath, 'utf-8'); return JSON.parse(content); } }
|