Files
Homarr/src/tools/server/images/abstract-icons-repository.ts

33 lines
707 B
TypeScript
Raw Normal View History

2023-02-20 22:11:30 +01:00
export abstract class AbstractIconRepository {
constructor(readonly copyright?: string) {}
async fetch(): Promise<NormalizedIconRepositoryResult> {
try {
return await this.fetchInternally();
} catch (err) {
return {
success: false,
count: 0,
entries: [],
name: '',
copyright: this.copyright,
};
}
}
protected abstract fetchInternally(): Promise<NormalizedIconRepositoryResult>;
}
export type NormalizedIconRepositoryResult = {
name: string;
success: boolean;
count: number;
copyright: string | undefined;
entries: NormalizedIcon[];
};
export type NormalizedIcon = {
url: string;
name: string;
size: number;
};