Browse Source

CHANGE | Different app version parameters for different platforms

pull/2/head
Oksana Stepanenko 1 year ago
parent
commit
de66dc5769
  1. 3
      .env.example
  2. 3
      .env.save
  3. 6
      src/config/index.ts
  4. 8
      src/rest/app/system/app-system.controller.ts
  5. 5
      src/rest/app/system/app-system.service.ts
  6. 6
      src/rest/app/system/dto/app-version.dto.ts

3
.env.example

@ -1,4 +1,5 @@
APP_VERSION=2.1 APP_VERSION_IOS=2.2
APP_VERSION_ANDROID=2.2
TEST_ENV=test TEST_ENV=test

3
.env.save

@ -1,4 +1,5 @@
APP_VERSION=2.1 APP_VERSION_IOS=2.2
APP_VERSION_ANDROID=2.2
AUTO_SEED_ENABLED=true AUTO_SEED_ENABLED=true

6
src/config/index.ts

@ -117,9 +117,11 @@ const getFilesLimitsConfig = () => {
return config return config
} }
const getAppVersion = () => { const getAppVersion = (platform: string) => {
if (!platform) return null
const paramName = `APP_VERSION_${platform.toUpperCase()}`
try { try {
return getEnv('APP_VERSION') return getEnv(paramName)
} catch (e) { } catch (e) {
console.log('Error on get env var:', e.message) console.log('Error on get env var:', e.message)
} }

8
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 { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger'
import { AppSystemService } from './app-system.service' import { AppSystemService } from './app-system.service'
import { AppVersionDto } from './dto' import { AppVersionDto, GetAppVersionParamsDto } from './dto'
import { AuthGuard } from 'src/domain/sessions/decorators' import { AuthGuard } from 'src/domain/sessions/decorators'
@ApiTags('App | System') @ApiTags('App | System')
@ -18,7 +18,7 @@ export class AppSystemController {
}) })
@AuthGuard() @AuthGuard()
@Get('app-version') @Get('app-version')
public async getAppVersion() { public async getAppVersion(@Query() dto: GetAppVersionParamsDto) {
return this.systemService.getAppVersion() return this.systemService.getAppVersion(dto)
} }
} }

5
src/rest/app/system/app-system.service.ts

@ -1,10 +1,11 @@
import { Injectable } from '@nestjs/common' import { Injectable } from '@nestjs/common'
import { $config } from 'src/config' import { $config } from 'src/config'
import { GetAppVersionParamsDto } from './dto'
@Injectable() @Injectable()
export class AppSystemService { export class AppSystemService {
public getAppVersion() { public getAppVersion(dto: GetAppVersionParamsDto) {
const version = $config.getAppVersion() const version = $config.getAppVersion(dto.platform)
if (version) return { version } if (version) return { version }
return null return null

6
src/rest/app/system/dto/app-version.dto.ts

@ -1,5 +1,11 @@
import { IsString } from 'class-validator'
import { DtoProperty } from 'src/shared' import { DtoProperty } from 'src/shared'
export class GetAppVersionParamsDto {
@DtoProperty()
@IsString()
platform: string
}
export class AppVersionDto { export class AppVersionDto {
@DtoProperty() @DtoProperty()
version: string version: string

Loading…
Cancel
Save