Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix await lint issues #1698 #1709

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/bin/platforms/linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,12 +616,20 @@ export class LinuxInstaller extends BasePlatform {
private async createFirewallRules() {
// check ufw is present on the system (debian based linux)
if (await fs.pathExists('/usr/sbin/ufw')) {
return this.createUfwRules();
try {
return await this.createUfwRules();
} catch (err) {
throw err;
}
}

// check firewall-cmd is present on the system (enterprise linux)
if (await fs.pathExists('/usr/bin/firewall-cmd')) {
return this.createFirewallCmdRules();
try {
return await this.createFirewallCmdRules();
} catch (err) {
throw err;
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/core/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class AuthService {
*/
async signIn(username: string, password: string, otp?: string): Promise<any> {
const user = await this.authenticate(username, password, otp);
const token = this.jwtService.sign(user);
const token = await this.jwtService.sign(user);

return {
access_token: token,
Expand Down Expand Up @@ -130,7 +130,7 @@ export class AuthService {
const user = users.find(x => x.admin === true);

// generate a token
const token = this.jwtService.sign({
const token = await this.jwtService.sign({
username: user.username,
name: user.name,
admin: user.admin,
Expand Down Expand Up @@ -226,7 +226,7 @@ export class AuthService {
}

// generate a token
const token = this.jwtService.sign({
const token = await this.jwtService.sign({
username: 'setup-wizard',
name: 'setup-wizard',
admin: true,
Expand Down
1 change: 0 additions & 1 deletion src/core/spa/spa.filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from '@nestjs/common';
import * as fs from 'fs-extra';


@Catch(NotFoundException)
export class SpaFilter implements ExceptionFilter {
catch(_exception: HttpException, host: ArgumentsHost) {
Expand Down
6 changes: 5 additions & 1 deletion src/modules/accessories/accessories.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ export class AccessoriesGateway {

@SubscribeMessage('get-layout')
async getAccessoryLayout(client: any, payload: any) {
return this.accessoriesService.getAccessoryLayout(payload.user);
try {
return await this.accessoriesService.getAccessoryLayout(payload.user);
} catch (err) {
throw err;
}
}

@SubscribeMessage('save-layout')
Expand Down
6 changes: 5 additions & 1 deletion src/modules/backup/backup.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ export class BackupController {
description: 'Logs to stdout / stderr.',
})
async restoreBackupTrigger() {
return this.backupService.triggerHeadlessRestore();
try {
return await this.backupService.triggerHeadlessRestore();
} catch (err) {
throw err;
}
}

@UseGuards(AdminGuard)
Expand Down
1 change: 1 addition & 0 deletions src/modules/config-editor/config-editor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ export class ConfigEditorService {

// read source backup
return fs.readFileSync(requestedBackupPath);

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ export class PluginsSettingsUiController {
@ApiOperation({ summary: 'Returns the HTML assets for a plugin\'s custom UI' })
@ApiParam({ name: 'pluginName', type: 'string' })
async serveCustomUiAsset(@Res() reply, @Param('pluginName') pluginName, @Param('*') file, @Query('origin') origin: string, @Query('v') v?: string) {
return this.pluginSettingsUiService.serveCustomUiAsset(reply, pluginName, file, origin, v);
try {
return await this.pluginSettingsUiService.serveCustomUiAsset(reply, pluginName, file, origin, v);
} catch (err) {
throw err;
}
}

}
12 changes: 10 additions & 2 deletions src/modules/plugins/plugins.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,11 @@ export class PluginsService {
&& (query.indexOf('homebridge-') === 0 || this.isScopedPlugin(query))
&& !this.searchResultBlacklist.includes(query.toLowerCase())
) {
return this.searchNpmRegistrySingle(query.toLowerCase());
try {
return await this.searchNpmRegistrySingle(query.toLowerCase());
} catch (err) {
throw err;
}
}

return _.orderBy(result, ['verifiedPlugin'], ['desc']);
Expand Down Expand Up @@ -455,7 +459,11 @@ export class PluginsService {
if (this.configService.ui.homebridgePackagePath) {
const pjsonPath = path.join(this.configService.ui.homebridgePackagePath, 'package.json');
if (await fs.pathExists(pjsonPath)) {
return this.parsePackageJson(await fs.readJson(pjsonPath), this.configService.ui.homebridgePackagePath);
try {
return await this.parsePackageJson(await fs.readJson(pjsonPath), this.configService.ui.homebridgePackagePath);
} catch (err) {
throw err;
}
} else {
this.logger.error(`"homebridgePath" (${this.configService.ui.homebridgePackagePath}) does not exist`);
}
Expand Down
1 change: 0 additions & 1 deletion src/modules/server/server.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,3 @@ export class ServerController {
return this.serverService.setHomebridgeMdnsSetting(body);
}
}

3 changes: 1 addition & 2 deletions src/modules/server/server.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class HomebridgeMdnsSettingDto {
@IsDefined()
@IsIn(['avahi', 'resolved', 'ciao', 'bonjour-hap'])
@ApiProperty()
advertiser: 'avahi' | 'resolved' | 'ciao' | 'bonjour-hap';
advertiser: 'avahi' | 'resolved' | 'ciao' | 'bonjour-hap';
}

export class HomebridgeNetworkInterfacesDto {
Expand All @@ -20,4 +20,3 @@ export class HomebridgeNetworkInterfacesDto {
@ApiProperty()
adapters: string[];
}

1 change: 0 additions & 1 deletion src/modules/server/server.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ import { ServerService } from './server.service';
]
})
export class ServerModule { }

20 changes: 12 additions & 8 deletions src/modules/server/server.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import {
NotFoundException,
ServiceUnavailableException
} from '@nestjs/common';
import {Categories} from '@oznu/hap-client/dist/hap-types';
import { Categories } from '@oznu/hap-client/dist/hap-types';
import * as bufferShim from 'buffer-shims';
import * as fs from 'fs-extra';
import * as NodeCache from 'node-cache';
import * as si from 'systeminformation';
import * as tcpPortUsed from 'tcp-port-used';
import {ConfigService, HomebridgeConfig} from '../../core/config/config.service';
import {HomebridgeIpcService} from '../../core/homebridge-ipc/homebridge-ipc.service';
import {Logger} from '../../core/logger/logger.service';
import {AccessoriesService} from '../accessories/accessories.service';
import {ConfigEditorService} from '../config-editor/config-editor.service';
import {HomebridgeMdnsSettingDto} from './server.dto';
import { ConfigService, HomebridgeConfig } from '../../core/config/config.service';
import { HomebridgeIpcService } from '../../core/homebridge-ipc/homebridge-ipc.service';
import { Logger } from '../../core/logger/logger.service';
import { AccessoriesService } from '../accessories/accessories.service';
import { ConfigEditorService } from '../config-editor/config-editor.service';
import { HomebridgeMdnsSettingDto } from './server.dto';

@Injectable()
export class ServerService {
Expand Down Expand Up @@ -108,7 +108,11 @@ export class ServerService {
.filter(x => x.match(/AccessoryInfo\.([A-F,a-f0-9]+)\.json/));

return Promise.all(devices.map(async (x) => {
return this.getDevicePairingById(x.split('.')[1]);
try {
return await this.getDevicePairingById(x.split('.')[1]);
} catch (err) {
throw err;
}
}));
}

Expand Down
12 changes: 10 additions & 2 deletions src/modules/setup-wizard/setup-wizard.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ export class SetupWizardController {
description: 'This endpoint is not available after the Homebridge setup wizard is complete.',
})
async setupFirstUser(@Body() body: UserDto) {
return this.authService.setupFirstUser(body);
try {
return await this.authService.setupFirstUser(body);
} catch (err) {
throw err;
}
}

@Get('/get-setup-wizard-token')
Expand All @@ -33,6 +37,10 @@ export class SetupWizardController {
description: 'This endpoint is not available after the Homebridge setup wizard is complete.',
})
async generateSetupWizardToken() {
return this.authService.generateSetupWizardToken();
try {
return await this.authService.generateSetupWizardToken();
} catch (err) {
throw err;
}
}
}
4 changes: 2 additions & 2 deletions src/modules/status/status.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export class StatusService {
*/
public async getServerUptimeInfo() {
return {
time: si.time(),
time: await si.time(),
processUptime: process.uptime(),
};
}
Expand Down Expand Up @@ -427,7 +427,7 @@ export class StatusService {
nodeVersion: process.version,
os: await this.getOsInfo(),
glibcVersion: this.getGlibcVersion(),
time: si.time(),
time: await si.time(),
network: await this.getDefaultInterface() || {},
};
}
Expand Down
Loading