0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-03-11 02:23:09 -05:00
immich/server/src/repositories/server-info.repository.ts

22 lines
745 B
TypeScript
Raw Normal View History

import { Injectable } from '@nestjs/common';
import { GitHubRelease, IServerInfoRepository } from 'src/interfaces/server-info.interface';
2024-03-20 22:15:09 -05:00
import { Instrumentation } from 'src/utils/instrumentation';
@Instrumentation()
@Injectable()
export class ServerInfoRepository implements IServerInfoRepository {
async getGitHubRelease(): Promise<GitHubRelease> {
try {
const response = await fetch('https://api.github.com/repos/immich-app/immich/releases/latest');
if (!response.ok) {
throw new Error(`GitHub API request failed with status ${response.status}: ${await response.text()}`);
}
return response.json();
} catch (error) {
throw new Error(`Failed to fetch GitHub release: ${error}`);
}
}
}