Skip to content

High performance self-hosted photo and video management solution.

1.4 KB
Raw Blame
import { Controller, Get } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Endpoint, HistoryBuilder } from 'src/decorators.js';
import { UserConfigDto } from 'src/dtos/config.dto.js';
import { ApiTag, Permission } from 'src/enum.js';
import { Authenticated } from 'src/middleware/auth.guard.js';
import { SystemConfigService } from 'src/services/system-config.service.js';

@ApiTags(ApiTag.ConfigUser)
@Controller('config')
export class ConfigUserController {
  constructor(private service: SystemConfigService) {}

  @Get()
  @Authenticated({ permission: Permission.UserConfigRead })
  @Endpoint({
    summary: 'Get the configuration with user visibility',
    description: 'Retrieve the system configuration properties that are visible to logged in users.',
    history: new HistoryBuilder().added('v3.2.0').alpha('v3.2.0'),
  })
  getUserConfig(): Promise<UserConfigDto> {
    return this.service.getUserConfig();
  }

  @Get('defaults')
  @Authenticated({ permission: Permission.UserConfigRead })
  @Endpoint({
    summary: 'Get the default configuration with user visibility',
    description: 'Retrieve the default value of the configuration properties that are visible to logged in users.',
    history: new HistoryBuilder().added('v3.2.0').alpha('v3.2.0'),
  })
  getUserConfigDefaults(): UserConfigDto {
    return this.service.getUserConfigDefaults();
  }
}