• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

teableio / teable / 16043276481

03 Jul 2025 06:32AM UTC coverage: 80.748%. First build
16043276481

Pull #1637

github

web-flow
Merge 075084d48 into f995e060d
Pull Request #1637: refactor: restructure settings management and introduce OpenAPI endpo…

8086 of 8600 branches covered (94.02%)

121 of 161 new or added lines in 19 files covered. (75.16%)

38521 of 47705 relevant lines covered (80.75%)

1703.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

36.0
/apps/nestjs-backend/src/features/setting/open-api/setting-open-api.controller.ts
1
import {
4✔
2
  BadRequestException,
3
  Body,
4
  Controller,
5
  Get,
6
  Patch,
7
  UploadedFile,
8
  UseInterceptors,
9
} from '@nestjs/common';
10
import { FileInterceptor } from '@nestjs/platform-express';
11
import type { IPublicSettingVo, ISettingVo, IUploadLogoVo } from '@teable/openapi';
12
import { IUpdateSettingRo, updateSettingRoSchema } from '@teable/openapi';
13
import { ZodValidationPipe } from '../../../zod.validation.pipe';
14
import { Permissions } from '../../auth/decorators/permissions.decorator';
15
import { Public } from '../../auth/decorators/public.decorator';
16
import { SettingOpenApiService } from './setting-open-api.service';
17

18
@Controller('api/admin/setting')
19
export class SettingOpenApiController {
4✔
20
  constructor(private readonly settingOpenApiService: SettingOpenApiService) {}
439✔
21

22
  /**
439✔
23
   * Get the instance settings, now we have config for AI, there are some sensitive fields, we need check the permission before return.
24
   */
439✔
25
  @Permissions('instance|read')
439✔
26
  @Get()
27
  async getSetting(): Promise<ISettingVo> {
×
NEW
28
    return await this.settingOpenApiService.getSetting();
×
29
  }
×
30

31
  /**
439✔
32
   * Public endpoint for getting public settings without authentication
33
   */
439✔
34
  @Public()
439✔
35
  @Get('public')
36
  async getPublicSetting(): Promise<IPublicSettingVo> {
×
NEW
37
    const setting = await this.settingOpenApiService.getSetting();
×
38
    const { aiConfig, ...rest } = setting;
×
39
    return {
×
40
      ...rest,
×
41
      aiConfig: {
×
42
        enable: aiConfig?.enable ?? false,
×
43
        llmProviders:
×
44
          aiConfig?.llmProviders?.map((provider) => ({
×
45
            type: provider.type,
×
46
            name: provider.name,
×
47
            models: provider.models,
×
48
          })) ?? [],
×
49
      },
×
50
    };
×
51
  }
×
52

53
  @Patch()
439✔
54
  @Permissions('instance|update')
55
  async updateSetting(
1✔
56
    @Body(new ZodValidationPipe(updateSettingRoSchema))
1✔
57
    updateSettingRo: IUpdateSettingRo
1✔
58
  ): Promise<ISettingVo> {
1✔
59
    return await this.settingOpenApiService.updateSetting(updateSettingRo);
1✔
60
  }
1✔
61

62
  @UseInterceptors(
439✔
63
    FileInterceptor('file', {
64
      fileFilter: (_req, file, callback) => {
×
65
        if (file.mimetype.startsWith('image/')) {
×
66
          callback(null, true);
×
67
        } else {
×
68
          callback(new BadRequestException('Invalid file type'), false);
×
69
        }
×
70
      },
×
71
      limits: {
×
72
        fileSize: 500 * 1024, // limit file size is 500KB
×
73
      },
×
74
    })
75
  )
76
  @Patch('logo')
77
  @Permissions('instance|update')
78
  async uploadLogo(@UploadedFile() file: Express.Multer.File): Promise<IUploadLogoVo> {
×
NEW
79
    return this.settingOpenApiService.uploadLogo(file);
×
80
  }
×
81
}
439✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc