Vitalik Yatsenko
1 year ago
9 changed files with 86 additions and 1 deletions
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
import { Controller, Get, Query } from '@nestjs/common' |
||||
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger' |
||||
import { AppSystemService } from './app-system.service' |
||||
import { AppVersionDto, GetAppVersionParamsDto } from './dto' |
||||
import { AuthGuard } from 'src/domain/sessions/decorators' |
||||
|
||||
@ApiTags('App | System') |
||||
@Controller('app/system') |
||||
export class AppSystemController { |
||||
constructor(private readonly systemService: AppSystemService) {} |
||||
|
||||
@ApiOperation({ |
||||
summary: 'Отримання актуальної версії мобільного додатку', |
||||
}) |
||||
@ApiOkResponse({ |
||||
description: 'Повертає актуальну версію мобільного додатку', |
||||
type: AppVersionDto, |
||||
}) |
||||
@AuthGuard() |
||||
@Get('app-version') |
||||
public async getAppVersion(@Query() dto: GetAppVersionParamsDto) { |
||||
return this.systemService.getAppVersion(dto) |
||||
} |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
import { DynamicModule, Module } from '@nestjs/common' |
||||
import { JwtModule } from 'src/libs' |
||||
import { AppSystemService } from './app-system.service' |
||||
import { AppSystemController } from './app-system.controller' |
||||
|
||||
@Module({}) |
||||
export class AppSystemModule { |
||||
static forRoot(): DynamicModule { |
||||
return { |
||||
module: AppSystemModule, |
||||
imports: [JwtModule.forFeature()], |
||||
providers: [AppSystemService], |
||||
controllers: [AppSystemController], |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
import { Injectable } from '@nestjs/common' |
||||
import { $config } from 'src/config' |
||||
import { GetAppVersionParamsDto } from './dto' |
||||
|
||||
@Injectable() |
||||
export class AppSystemService { |
||||
public getAppVersion(dto: GetAppVersionParamsDto) { |
||||
const version = $config.getAppVersion(dto.platform) |
||||
|
||||
if (version) return { version } |
||||
return null |
||||
} |
||||
} |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
import { IsString } from 'class-validator' |
||||
import { DtoProperty } from 'src/shared' |
||||
|
||||
export class GetAppVersionParamsDto { |
||||
@DtoProperty() |
||||
@IsString() |
||||
platform: string |
||||
} |
||||
export class AppVersionDto { |
||||
@DtoProperty() |
||||
version: string |
||||
} |
Loading…
Reference in new issue