@@ -202,8 +202,8 @@ <h3 id="methods">
202202
203203 < tr >
204204 < td class ="col-md-4 ">
205- < div class ="io-line "> Defined in < a href ="" data-line ="37 "
206- class ="link-to-prism "> src/app.controller.ts:37 </ a > </ div >
205+ < div class ="io-line "> Defined in < a href ="" data-line ="73 "
206+ class ="link-to-prism "> src/app.controller.ts:73 </ a > </ div >
207207 </ td >
208208 </ tr >
209209
@@ -281,8 +281,8 @@ <h3 id="methods">
281281
282282 < tr >
283283 < td class ="col-md-4 ">
284- < div class ="io-line "> Defined in < a href ="" data-line ="45 "
285- class ="link-to-prism "> src/app.controller.ts:45 </ a > </ div >
284+ < div class ="io-line "> Defined in < a href ="" data-line ="81 "
285+ class ="link-to-prism "> src/app.controller.ts:81 </ a > </ div >
286286 </ td >
287287 </ tr >
288288
@@ -364,15 +364,51 @@ <h3 id="methods">
364364import { ApiBearerAuth, ApiOperation, ApiQuery, ApiResponse } from '@nestjs/swagger';
365365import { LRUCache } from 'lru-cache';
366366
367+ interface GithubAuthor {
368+ login: string;
369+ id: number;
370+ node_id: string;
371+ avatar_url: string;
372+ gravatar_id: string;
373+ url: string;
374+ html_url: string;
375+ followers_url: string;
376+ following_url: string;
377+ gists_url: string;
378+ starred_url: string;
379+ subscriptions_url: string;
380+ organizations_url: string;
381+ repos_url: string;
382+ events_url: string;
383+ received_events_url: string;
384+ type: string;
385+ user_view_type: string;
386+ site_admin: boolean;
387+ }
388+
389+ interface GithubAsset {
390+ [key: string]: any;
391+ }
392+
367393interface GithubUpdate {
368- name?: string;
369- commit?: {
370- sha?: string;
371- url?: string;
372- };
373- zipball_url?: string;
374- tarball_url?: string;
375- node_id?: string;
394+ url: string;
395+ assets_url: string;
396+ upload_url: string;
397+ html_url: string;
398+ id: number;
399+ author: GithubAuthor;
400+ node_id: string;
401+ tag_name: string;
402+ target_commitish: string;
403+ name: string;
404+ draft: boolean;
405+ prerelease: boolean;
406+ created_at: string;
407+ published_at: string;
408+ assets: GithubAsset[];
409+ tarball_url: string;
410+ zipball_url: string;
411+ body: string;
376412}
377413
378414const storage = new LRUCache({
@@ -405,24 +441,25 @@ <h3 id="methods">
405441 @Param('project') project?: string,
406442 @Query('current') current?: string,
407443 ): Promise<Response> {
408- let data: GithubUpdate[] | object = {};
444+ let data = <GithubUpdate> {};
409445 // console.log('this.storage', storage.get(project))
410446 if (storage.has(project)) {
411447 this.logger.log(`Fetching ${project} tags from cache`);
412- data = storage.get(project) as GithubUpdate[] | object ;
448+ data = storage.get(project) as GithubUpdate;
413449 } else {
414450 this.logger.log(`Fetching ${project} tags`);
415- const update = await fetch(`https://api.github.com/repos/Libertech-FR/${project}/tags `, {
451+ const update = await fetch(`https://api.github.com/repos/Libertech-FR/${project}/releases/latest `, {
416452 signal: AbortSignal.timeout(1000),
417453 });
418454 data = await update.json();
455+ console.log('update', data)
419456 storage.set(project, data);
420457 // console.log('this.storage', storage.get(project))
421458 }
422- if (!Array.isArray(data)) {
423- throw new BadRequestException(`Invalid data from Github <${JSON.stringify(data)}>`);
424- }
425- const lastVersion = data[0].name .replace(/^v/, '');
459+ // if (!Array.isArray(data)) {
460+ // throw new BadRequestException(`Invalid data from Github <${JSON.stringify(data)}>`);
461+ // }
462+ const lastVersion = data.tag_name .replace(/^v/, '');
426463 const pkgInfo = this.appService.getInfo();
427464 const currentVersion = current || pkgInfo.version;
428465
0 commit comments