1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-22 11:42:46 +01:00
immich/server/src/repositories/server-info.repository.ts
2024-03-20 21:02:51 +00:00

21 lines
746 B
TypeScript

import { Injectable } from '@nestjs/common';
import { Instrumentation } from 'src/infra/instrumentation';
import { GitHubRelease, IServerInfoRepository } from 'src/interfaces/server-info.repository';
@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}`);
}
}
}