fix errors
This commit is contained in:
@@ -4,12 +4,14 @@ import { Repository } from 'typeorm';
|
||||
import { Setting } from './entities/setting.entity';
|
||||
import * as dns from 'dns/promises';
|
||||
import { COUNTRIES } from './countries';
|
||||
import { XuiService } from 'src/xui/xui.service';
|
||||
|
||||
@Controller('settings')
|
||||
export class SettingsController {
|
||||
constructor(
|
||||
@InjectRepository(Setting)
|
||||
private settingsRepo: Repository<Setting>,
|
||||
private xuiService: XuiService
|
||||
) {}
|
||||
|
||||
@Get()
|
||||
@@ -18,6 +20,12 @@ export class SettingsController {
|
||||
return settings.reduce((acc, curr) => ({ ...acc, [curr.key]: curr.value }), {});
|
||||
}
|
||||
|
||||
@Post('check')
|
||||
async checkConnection(@Body() body: { xui_url: string; xui_login: string; xui_password: string }) {
|
||||
const success = await this.xuiService.checkConnection(body.xui_url, body.xui_login, body.xui_password);
|
||||
return { success };
|
||||
}
|
||||
|
||||
@Post()
|
||||
async update(@Body() settings: Record<string, string>) {
|
||||
if (settings.xui_url) {
|
||||
|
||||
@@ -2,9 +2,10 @@ import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { SettingsController } from './settings.controller';
|
||||
import { Setting } from './entities/setting.entity';
|
||||
import { XuiModule } from 'src/xui/xui.module';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([Setting])],
|
||||
imports: [TypeOrmModule.forFeature([Setting]), XuiModule],
|
||||
controllers: [SettingsController],
|
||||
})
|
||||
export class SettingsModule {}
|
||||
Reference in New Issue
Block a user