diff --git a/lib/group.js b/lib/group.js index 111590a..332a5de 100644 --- a/lib/group.js +++ b/lib/group.js @@ -59,11 +59,9 @@ class Group { async delete(args) { const r = await Mysql.execute( - ...Mysql.update( - `nt_group`, - `nt_group_id=${args.id}`, - { deleted: args.deleted ?? 1 }, - ), + ...Mysql.update(`nt_group`, `nt_group_id=${args.id}`, { + deleted: args.deleted ?? 1, + }), ) return r.changedRows === 1 } diff --git a/lib/nameserver.js b/lib/nameserver.js index 256ed54..f349b98 100644 --- a/lib/nameserver.js +++ b/lib/nameserver.js @@ -90,11 +90,9 @@ class Nameserver { async delete(args) { const r = await Mysql.execute( - ...Mysql.update( - `nt_nameserver`, - `nt_nameserver_id=${args.id}`, - { deleted: args.deleted ?? 1 }, - ), + ...Mysql.update(`nt_nameserver`, `nt_nameserver_id=${args.id}`, { + deleted: args.deleted ?? 1, + }), ) return r.changedRows === 1 } diff --git a/lib/permission.js b/lib/permission.js index 75bfd67..84cc41d 100644 --- a/lib/permission.js +++ b/lib/permission.js @@ -88,11 +88,9 @@ class Permission { async delete(args) { if (!args.id) return false const r = await Mysql.execute( - ...Mysql.update( - `nt_perm`, - `nt_perm_id=${args.id}`, - { deleted: args.deleted ?? 1 }, - ), + ...Mysql.update(`nt_perm`, `nt_perm_id=${args.id}`, { + deleted: args.deleted ?? 1, + }), ) return r.changedRows === 1 } diff --git a/lib/user.js b/lib/user.js index 1260c95..be2cf46 100644 --- a/lib/user.js +++ b/lib/user.js @@ -122,11 +122,9 @@ class User { async delete(args) { const r = await Mysql.execute( - ...Mysql.update( - `nt_user`, - `nt_user_id=${args.id}`, - { deleted: args.deleted ?? 1 }, - ), + ...Mysql.update(`nt_user`, `nt_user_id=${args.id}`, { + deleted: args.deleted ?? 1, + }), ) return r.changedRows === 1 } diff --git a/lib/zone.js b/lib/zone.js index 2c3818a..e19a6e1 100644 --- a/lib/zone.js +++ b/lib/zone.js @@ -74,11 +74,9 @@ class Zone { async delete(args) { const r = await Mysql.execute( - ...Mysql.update( - `nt_zone`, - `nt_zone_id=${args.id}`, - { deleted: args.deleted ?? 1 }, - ), + ...Mysql.update(`nt_zone`, `nt_zone_id=${args.id}`, { + deleted: args.deleted ?? 1, + }), ) return r.changedRows === 1 } diff --git a/lib/zone_record.js b/lib/zone_record.js index b85bc75..212a804 100644 --- a/lib/zone_record.js +++ b/lib/zone_record.js @@ -20,8 +20,7 @@ class ZoneRecord { try { const zr = new RR[args.type](args) console.log(zr) - } - catch (e) { + } catch (e) { console.error(e.message) } @@ -109,7 +108,7 @@ function dbToObject(rows) { row.type = RR.typeMap[row.type_id] delete row.type_id - + for (const f of [ 'description', 'other', @@ -138,8 +137,10 @@ function objectToDb(obj) { break case 'CNAME': applyMap(obj, { address: 'cname' }) + break case 'DNAME': applyMap(obj, { address: 'target' }) + break case 'DNSKEY': applyMap(obj, { address: 'public key', @@ -149,8 +150,11 @@ function objectToDb(obj) { }) break case 'HINFO': - obj.name = `${obj.cpu} ${obj.os}`; delete obj.cpu; delete obj.os - obj.address = obj.description; delete obj.description + obj.name = `${obj.cpu} ${obj.os}` + delete obj.cpu + delete obj.os + obj.address = obj.description + delete obj.description break case 'IPSECKEY': applyMap(obj, { @@ -159,7 +163,7 @@ function objectToDb(obj) { weight: 'precedence', priority: 'gateway type', other: 'algorithm', - }) + }) break case 'NAPTR': applyMap(obj, { @@ -168,7 +172,9 @@ function objectToDb(obj) { description: 'replacement', }) obj.address = `${obj.flags} ${obj.service} ${obj.regexp}` - delete obj.flags; delete obj.service; delete obj.regexp + delete obj.flags + delete obj.service + delete obj.regexp break case 'SSHFP': applyMap(obj, { @@ -191,8 +197,9 @@ function objectToDb(obj) { return obj } -function applyMap (obj, map) { +function applyMap(obj, map) { for (const [key, value] of Object.entries(map)) { - obj[key] = obj[value]; delete obj[value] + obj[key] = obj[value] + delete obj[value] } }