[core] move getAll sessions to session config repo

This commit is contained in:
devlikepro committed 2024-08-27 16:42:26 +07:00
1 parent 679757ccfa
commit 0784c3ae05
4 files changed
+12 -12

No files matched your search

@@ -2,6 +2,4 @@ export abstract class ISessionAuthRepository {
abstract init(sessionName?: string): Promise<void>;
abstract clean(sessionName: string): Promise<void>;
abstract getAll(): Promise<string[]>;
}
@@ -9,4 +9,6 @@ export abstract class ISessionConfigRepository {
abstract get(sessionName: string): Promise<SessionConfig | null>;
abstract delete(sessionName: string): Promise<void>;
abstract getAll(): Promise<string[]>;
}
@@ -19,14 +19,4 @@ export class LocalSessionAuthRepository extends ISessionAuthRepository {
const folder = this.store.getSessionDirectory(sessionName);
await fs.rm(folder, { recursive: true });
}
async getAll(): Promise<string[]> {
await this.init();
const content = await fs.readdir(this.store.getEngineDirectory(), {
withFileTypes: true,
});
return content
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);
}
}
@@ -62,4 +62,14 @@ export class LocalSessionConfigRepository extends ISessionConfigRepository {
}
await fs.unlink(filepath);
}
async getAll(): Promise<string[]> {
await this.store.init();
const content = await fs.readdir(this.store.getEngineDirectory(), {
withFileTypes: true,
});
return content
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);
}
}