11import logger from '@server/utils/logger'
2- import { CacheableStore , GithubAsset , CacheEntry , GithubRelease } from '@shared/types'
2+ import {
3+ CacheableStore ,
4+ GithubAsset ,
5+ CacheEntry ,
6+ GithubRelease ,
7+ GithubRepository
8+ } from '@shared/types'
39import { isCacheValid } from '@server/services/releases/releaseValidation'
410import { GithubStoreClass } from '@shared/stores/githubStore'
511import { handleError } from '@server/utils/errorHandler'
@@ -211,7 +217,7 @@ export class GithubStore implements CacheableStore, GithubStoreClass {
211217 ; [ , owner , repo ] = match
212218 }
213219
214- return `https://api.github.com/repos/${ owner } /${ repo } /releases `
220+ return `https://api.github.com/repos/${ owner } /${ repo } `
215221 } catch ( error ) {
216222 logger . error ( `Failed to convert repository URL to API endpoint: ${ repoUrl } ` , {
217223 function : 'convertToApiUrl' ,
@@ -229,7 +235,7 @@ export class GithubStore implements CacheableStore, GithubStoreClass {
229235 */
230236 public getAllReleases = async ( repoUrl : string , force ?: boolean ) : Promise < GithubRelease [ ] > => {
231237 try {
232- const apiUrl = this . convertToApiUrl ( repoUrl )
238+ const apiUrl = this . convertToApiUrl ( repoUrl ) + '/releases'
233239 logger . debug ( `Converted url ${ repoUrl } to ${ apiUrl } ` )
234240
235241 // Checking the cache first
@@ -294,6 +300,31 @@ export class GithubStore implements CacheableStore, GithubStoreClass {
294300 }
295301 }
296302
303+ public getRepository = async ( repoUrl : string ) : Promise < GithubRepository | undefined > => {
304+ try {
305+ const apiUrl = this . convertToApiUrl ( repoUrl )
306+
307+ const response = await this . queueRequest ( apiUrl )
308+
309+ if ( ! response . ok ) {
310+ logger . error ( `Failed to fetch repository ${ repoUrl } : ${ response . statusText } ` , {
311+ function : 'getRepository' ,
312+ source : 'githubStore'
313+ } )
314+ return undefined
315+ }
316+
317+ const data = ( await response . json ( ) ) as GithubRepository
318+ return data
319+ } catch ( error ) {
320+ logger . error ( `Error fetching repository ${ repoUrl } . ${ handleError ( error ) } !` , {
321+ function : 'getRepository' ,
322+ source : 'githubStore'
323+ } )
324+ throw error
325+ }
326+ }
327+
297328 public checkUrlValidity = async ( url : string ) : Promise < boolean > => {
298329 try {
299330 // Check if we already validated this URL recently
0 commit comments