1
0
Fork 0

rm cname dns record POST

refactor/models
Matthew 2021-03-31 16:02:00 -04:00
parent 458b7c9788
commit a28fbc5f34
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
1 changed files with 2 additions and 11 deletions

View File

@ -130,9 +130,9 @@ export default class CWG_Create extends Command {
return Promise.all(completed); return Promise.all(completed);
} catch (err) { } catch (err) {
this.client.util.handleError(err, message, this);
const tasks = [fs.unlink(`/etc/nginx/sites-enabled/${args[1]}`), fs.unlink(`/etc/nginx/sites-available/${args[1]}`), this.client.db.Domain.deleteMany({ domain: args[1] })]; const tasks = [fs.unlink(`/etc/nginx/sites-enabled/${args[1]}`), fs.unlink(`/etc/nginx/sites-available/${args[1]}`), this.client.db.Domain.deleteMany({ domain: args[1] })];
await Promise.allSettled(tasks); return Promise.allSettled(tasks);
return this.client.util.handleError(err, message, this);
} }
} }
@ -172,15 +172,6 @@ export default class CWG_Create extends Command {
x509, x509,
enabled: true, enabled: true,
}); });
if (domain.includes('cloud.libraryofcode.org')) {
const dmn = domain.split('.');
await axios({
method: 'post',
url: 'https://api.cloudflare.com/client/v4/zones/5e82fc3111ed4fbf9f58caa34f7553a7/dns_records',
headers: { Authorization: `Bearer ${this.client.config.cloudflare}`, 'Content-Type': 'application/json' },
data: JSON.stringify({ type: 'CNAME', name: `${dmn[0]}.${dmn[1]}`, content: 'cloud.libraryofcode.org', proxied: false }),
});
}
return entry.save(); return entry.save();
} catch (error) { } catch (error) {
const tasks = [fs.unlink(`/etc/nginx/sites-enabled/${domain}`), fs.unlink(`/etc/nginx/sites-available/${domain}`), this.client.db.Domain.deleteMany({ domain })]; const tasks = [fs.unlink(`/etc/nginx/sites-enabled/${domain}`), fs.unlink(`/etc/nginx/sites-available/${domain}`), this.client.db.Domain.deleteMany({ domain })];