Skip to content

Commit

Permalink
refactor: remove unnecessary async
Browse files Browse the repository at this point in the history
  • Loading branch information
shumkov committed Oct 31, 2024
1 parent 098f8b0 commit 057ec02
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/dashmate/src/commands/ssl/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Cancel all drafted or pending validation certificates on ZeroSSL
[
{
title: 'Cleanup ZeroSSL certificate',
task: async () => cleanupZeroSSLCertificatesTask(config),
task: () => cleanupZeroSSLCertificatesTask(config),
},
],
{
Expand Down
2 changes: 1 addition & 1 deletion packages/dashmate/src/commands/ssl/obtain.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Certificate will be renewed if it is about to expire (see 'expiration-days' flag
[
{
title: 'Obtain ZeroSSL certificate',
task: async () => obtainZeroSSLCertificateTask(config),
task: () => obtainZeroSSLCertificateTask(config),
},
],
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function scheduleRenewZeroSslCertificateFactory(
}

const job = new CronJob(expiresAt, async () => {
const tasks = await obtainZeroSSLCertificateTask(config);
const tasks = obtainZeroSSLCertificateTask(config);

await tasks.run({
expirationDays: Certificate.EXPIRATION_LIMIT_DAYS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ export default function cleanupZeroSSLCertificatesTaskFactory(
cancelCertificate,
) {
/**
* @typedef {obtainZeroSSLCertificateTask}
* @typedef {cleanupZeroSSLCertificatesTask}
* @param {Config} config
* @return {Promise<Listr>}
* @return {Listr}
*/
async function cleanupZeroSSLCertificatesTask(config) {
function cleanupZeroSSLCertificatesTask(config) {
const apiKey = config.get('platform.gateway.ssl.providerConfigs.zerossl.apiKey', true);

return new Listr([
{
title: 'Collect drafted and pending validation certificates',
// Skips the check if force flag is set
task: async (ctx, task) => {
ctx.apiKey = config.get('platform.gateway.ssl.providerConfigs.zerossl.apiKey', true);

ctx.certificates = [];

let certificatesPerRequest = [];
Expand All @@ -33,7 +33,7 @@ export default function cleanupZeroSSLCertificatesTaskFactory(
// Fetch all certificates in draft or pending validation status
// with pagination
do {
certificatesPerRequest = await listCertificates(ctx.apiKey, ['draft', 'pending_validation'], page);
certificatesPerRequest = await listCertificates(apiKey, ['draft', 'pending_validation'], page);

ctx.certificates = ctx.certificates.concat(certificatesPerRequest);

Expand All @@ -57,7 +57,7 @@ export default function cleanupZeroSSLCertificatesTaskFactory(
return new Observable(async (observer) => {
for (const certificate of ctx.certificates) {
try {
await cancelCertificate(ctx.apiKey, certificate.id);
await cancelCertificate(apiKey, certificate.id);

ctx.canceled += 1;
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export default function obtainZeroSSLCertificateTaskFactory(
/**
* @typedef {obtainZeroSSLCertificateTask}
* @param {Config} config
* @return {Promise<Listr>}
* @return {Listr}
*/
async function obtainZeroSSLCertificateTask(config) {
function obtainZeroSSLCertificateTask(config) {
return new Listr([
{
title: 'Check if certificate already exists and not expiring soon',
Expand Down

0 comments on commit 057ec02

Please sign in to comment.