Skip to content

Commit

Permalink
Simplify checkVariable (#181)
Browse files Browse the repository at this point in the history
* Fix JSON could be a string

Co-authored-by: Val <[email protected]>
  • Loading branch information
vpowler and v-0-0 authored Feb 14, 2022
1 parent 2de5a1e commit ce7506c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/controller/bundle.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ export class BundleController extends BaseController {
});

await streamFinished(bundleStream);
res.status(200).json(result).end();

res.status(200).send(result).end();
}

@httpGet('/:bundleId/info')
Expand Down
6 changes: 2 additions & 4 deletions src/model/admin/email-settings.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ export interface IEmailSettings {
export class EmailSettings implements IEmailSettings {

private static checkVariable(variable) {
if (variable === undefined) {
return false;
}
return true;
return variable !== undefined;
}

public from: string;
public orgRegTo: string;
public apiKey: string;
Expand Down
4 changes: 2 additions & 2 deletions src/service/email.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ export class EmailService {
config.email.templateIdOrgReqApprove = mailInfo.templateIds.orgReqApprove;
config.email.templateIdOrgReqRefuse = mailInfo.templateIds.orgReqRefuse;
sgMail.setApiKey(config.email.api);
} catch (e) {
this.logger.error('unable to get mailInfo from state.json');
} catch (err) {
this.logger.error(`unable to get mailInfo from state.json: ${err}`);
}
this.checkVariable('config.dashboardUrl', config.dashboardUrl);
this.checkVariable('config.email.api', config.email.api);
Expand Down
2 changes: 1 addition & 1 deletion src/util/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const readFile = async (filepath: string) =>
export const readFileSync = (filepath: string): string => {
try {
return fs.readFileSync(filepath).toString();
} catch (error) {
} catch {
return '';
}
};
Expand Down

0 comments on commit ce7506c

Please sign in to comment.