From de66dc57694a4b708d0684085a681110ad6cfb25 Mon Sep 17 00:00:00 2001 From: Oksana Stepanenko Date: Tue, 22 Aug 2023 11:34:28 +0300 Subject: [PATCH] CHANGE | Different app version parameters for different platforms --- .env.example | 3 ++- .env.save | 3 ++- src/config/index.ts | 6 ++++-- src/rest/app/system/app-system.controller.ts | 8 ++++---- src/rest/app/system/app-system.service.ts | 5 +++-- src/rest/app/system/dto/app-version.dto.ts | 6 ++++++ 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.env.example b/.env.example index b0bee54..5caf1b2 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,5 @@ -APP_VERSION=2.1 +APP_VERSION_IOS=2.2 +APP_VERSION_ANDROID=2.2 TEST_ENV=test diff --git a/.env.save b/.env.save index 10b6c78..7a61bce 100644 --- a/.env.save +++ b/.env.save @@ -1,4 +1,5 @@ -APP_VERSION=2.1 +APP_VERSION_IOS=2.2 +APP_VERSION_ANDROID=2.2 AUTO_SEED_ENABLED=true diff --git a/src/config/index.ts b/src/config/index.ts index 3639534..50efcbe 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -117,9 +117,11 @@ const getFilesLimitsConfig = () => { return config } -const getAppVersion = () => { +const getAppVersion = (platform: string) => { + if (!platform) return null + const paramName = `APP_VERSION_${platform.toUpperCase()}` try { - return getEnv('APP_VERSION') + return getEnv(paramName) } catch (e) { console.log('Error on get env var:', e.message) } diff --git a/src/rest/app/system/app-system.controller.ts b/src/rest/app/system/app-system.controller.ts index cb7e260..4971ea2 100644 --- a/src/rest/app/system/app-system.controller.ts +++ b/src/rest/app/system/app-system.controller.ts @@ -1,7 +1,7 @@ -import { Controller, Get } from '@nestjs/common' +import { Controller, Get, Query } from '@nestjs/common' import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger' import { AppSystemService } from './app-system.service' -import { AppVersionDto } from './dto' +import { AppVersionDto, GetAppVersionParamsDto } from './dto' import { AuthGuard } from 'src/domain/sessions/decorators' @ApiTags('App | System') @@ -18,7 +18,7 @@ export class AppSystemController { }) @AuthGuard() @Get('app-version') - public async getAppVersion() { - return this.systemService.getAppVersion() + public async getAppVersion(@Query() dto: GetAppVersionParamsDto) { + return this.systemService.getAppVersion(dto) } } diff --git a/src/rest/app/system/app-system.service.ts b/src/rest/app/system/app-system.service.ts index efc9b51..8d6bf3a 100644 --- a/src/rest/app/system/app-system.service.ts +++ b/src/rest/app/system/app-system.service.ts @@ -1,10 +1,11 @@ import { Injectable } from '@nestjs/common' import { $config } from 'src/config' +import { GetAppVersionParamsDto } from './dto' @Injectable() export class AppSystemService { - public getAppVersion() { - const version = $config.getAppVersion() + public getAppVersion(dto: GetAppVersionParamsDto) { + const version = $config.getAppVersion(dto.platform) if (version) return { version } return null diff --git a/src/rest/app/system/dto/app-version.dto.ts b/src/rest/app/system/dto/app-version.dto.ts index 97db99e..b976afb 100644 --- a/src/rest/app/system/dto/app-version.dto.ts +++ b/src/rest/app/system/dto/app-version.dto.ts @@ -1,5 +1,11 @@ +import { IsString } from 'class-validator' import { DtoProperty } from 'src/shared' +export class GetAppVersionParamsDto { + @DtoProperty() + @IsString() + platform: string +} export class AppVersionDto { @DtoProperty() version: string