Skip to content

Commit 2bb93c1

Browse files
committed
feat: Add ApiQuery decorator to update endpoint
1 parent fbd73e8 commit 2bb93c1

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/app.controller.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { AppService } from './app.service';
33
import { Response } from 'express';
44
import { AbstractController } from '~/_common/abstracts/abstract.controller';
55
import { Public } from './_common/decorators/public.decorator';
6-
import { ApiBearerAuth, ApiOperation, ApiResponse } from '@nestjs/swagger';
6+
import { ApiBearerAuth, ApiOperation, ApiQuery, ApiResponse } from '@nestjs/swagger';
77

88
interface GithubUpdate {
99
name?: string;
@@ -34,19 +34,20 @@ export class AppController extends AbstractController {
3434
});
3535
}
3636

37+
@ApiQuery({ name: 'current', required: false })
3738
@Get('/get-update/:project(sesame-orchestrator|sesame-daemon|sesame-app-manager)')
3839
public async update(
3940
@Res() res: Response,
40-
@Param('project') project: string,
41-
@Query('current') current: string,
41+
@Param('project') project?: string,
42+
@Query('current') current?: string,
4243
): Promise<Response> {
4344
const update = await fetch(`https://api.github.com/repos/Libertech-FR/${project}/tags`)
4445
const data: GithubUpdate = await update.json()
4546
const lastVersion = data[0].name.replace(/^v/, '')
4647
const pkgInfo = this.appService.getInfo()
4748
const currentVersion = current || pkgInfo.version
4849

49-
if (project !== pkgInfo.name) {
50+
if (project !== pkgInfo.name || current) {
5051
if (!/[0-9]+\.[0-9]+\.[0-9]+/.test(current)) {
5152
throw new BadRequestException('Invalid version for current parameter')
5253
}

src/core/backends/_enum/action-type.enum.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export enum ActionType {
22
LIST_BACKENDS = 'LIST_BACKENDS',
3+
DUMP_PACKAGE_CONFIG = 'DUMP_PACKAGE_CONFIG',
34
PING_TARGET = 'PING_TARGET',
45
IDENTITY_CREATE = 'IDENTITY_CREATE',
56
IDENTITY_UPDATE = 'IDENTITY_UPDATE',

0 commit comments

Comments
 (0)