Coder
2 years ago
15 changed files with 189 additions and 15 deletions
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
import { DynamicModule, Module } from '@nestjs/common' |
||||
import { JwtModule } from 'src/libs' |
||||
import { COMMON_CONFIGS_CONTROLLERS } from './controllers' |
||||
import { COMMON_CONFIGS_SERVICES } from './services' |
||||
|
||||
@Module({}) |
||||
export class CommonConfigsModule { |
||||
static forRoot(): DynamicModule { |
||||
return { |
||||
module: CommonConfigsModule, |
||||
imports: [JwtModule.forFeature()], |
||||
controllers: COMMON_CONFIGS_CONTROLLERS, |
||||
providers: COMMON_CONFIGS_SERVICES, |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
import { Controller, Get } from '@nestjs/common' |
||||
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger' |
||||
import { AuthGuard } from 'src/domain/sessions/decorators' |
||||
import { FilesLimitsConfigDto } from '../dtos' |
||||
import { CommonConfigsService } from '../services' |
||||
|
||||
@ApiTags('Common | Configs') |
||||
@Controller('common/configs') |
||||
export class CommonConfigsController { |
||||
constructor(private configsService: CommonConfigsService) {} |
||||
|
||||
@ApiOperation({ summary: 'Отримання параметрів конфігурації для файлів' }) |
||||
@ApiOkResponse({ |
||||
status: 200, |
||||
description: 'Повертає параметри конфігурації', |
||||
type: FilesLimitsConfigDto, |
||||
}) |
||||
@AuthGuard() |
||||
@Get('files-config') |
||||
public async getFilesConfig() { |
||||
return this.configsService.getFilesLimitsConfig() |
||||
} |
||||
} |
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
import { CommonConfigsController } from './common-configs.controller' |
||||
|
||||
export const COMMON_CONFIGS_CONTROLLERS = [CommonConfigsController] |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
import { DtoProperty, DtoPropertyOptional } from 'src/shared' |
||||
|
||||
export class FilesParametersDto { |
||||
@DtoPropertyOptional() |
||||
avatarWidth: string |
||||
|
||||
@DtoPropertyOptional() |
||||
avatarHeight: string |
||||
|
||||
@DtoPropertyOptional() |
||||
avatarSize: string |
||||
|
||||
@DtoPropertyOptional() |
||||
avatarTypes: string |
||||
|
||||
@DtoPropertyOptional() |
||||
taskFilesSize: string |
||||
|
||||
@DtoPropertyOptional() |
||||
taskFilesTypes: string |
||||
|
||||
@DtoPropertyOptional() |
||||
chatFilesSize: string |
||||
|
||||
@DtoPropertyOptional() |
||||
chatVideosSize: string |
||||
} |
||||
|
||||
export class FilesLimitsConfigDto { |
||||
@DtoProperty({ type: FilesParametersDto }) |
||||
config: FilesParametersDto |
||||
} |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
export * from './files-config' |
@ -0,0 +1,10 @@
@@ -0,0 +1,10 @@
|
||||
import { Injectable } from '@nestjs/common' |
||||
import { $config } from 'src/config' |
||||
|
||||
@Injectable() |
||||
export class CommonConfigsService { |
||||
public getFilesLimitsConfig() { |
||||
const config = $config.getFilesLimitsConfig() |
||||
return { config } |
||||
} |
||||
} |
@ -0,0 +1,5 @@
@@ -0,0 +1,5 @@
|
||||
import { CommonConfigsService } from './configs.service' |
||||
|
||||
export const COMMON_CONFIGS_SERVICES = [CommonConfigsService] |
||||
|
||||
export { CommonConfigsService } |
@ -1,3 +1,7 @@
@@ -1,3 +1,7 @@
|
||||
import { CommonChatsModule } from './chats/chats.module' |
||||
import { CommonConfigsModule } from './configs/configs.module' |
||||
|
||||
export const getRestCommonModules = () => [CommonChatsModule.forRoot()] |
||||
export const getRestCommonModules = () => [ |
||||
CommonChatsModule.forRoot(), |
||||
CommonConfigsModule.forRoot(), |
||||
] |
||||
|
Loading…
Reference in new issue