Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Mar 9, 2024
1 parent 85599c7 commit f00011f
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 34 deletions.
8 changes: 3 additions & 5 deletions lib/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 3 additions & 5 deletions lib/nameserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 3 additions & 5 deletions lib/permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 3 additions & 5 deletions lib/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 3 additions & 5 deletions lib/zone.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
25 changes: 16 additions & 9 deletions lib/zone_record.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Check warning on line 25 in lib/zone_record.js

View check run for this annotation

Codecov / codecov/patch

lib/zone_record.js#L24-L25

Added lines #L24 - L25 were not covered by tests

Expand Down Expand Up @@ -109,7 +108,7 @@ function dbToObject(rows) {

row.type = RR.typeMap[row.type_id]
delete row.type_id

for (const f of [
'description',
'other',
Expand Down Expand Up @@ -138,8 +137,10 @@ function objectToDb(obj) {
break

Check warning on line 137 in lib/zone_record.js

View check run for this annotation

Codecov / codecov/patch

lib/zone_record.js#L132-L137

Added lines #L132 - L137 were not covered by tests
case 'CNAME':
applyMap(obj, { address: 'cname' })
break

Check warning on line 140 in lib/zone_record.js

View check run for this annotation

Codecov / codecov/patch

lib/zone_record.js#L139-L140

Added lines #L139 - L140 were not covered by tests
case 'DNAME':
applyMap(obj, { address: 'target' })
break

Check warning on line 143 in lib/zone_record.js

View check run for this annotation

Codecov / codecov/patch

lib/zone_record.js#L142-L143

Added lines #L142 - L143 were not covered by tests
case 'DNSKEY':
applyMap(obj, {
address: 'public key',
Expand All @@ -149,8 +150,11 @@ function objectToDb(obj) {
})
break

Check warning on line 151 in lib/zone_record.js

View check run for this annotation

Codecov / codecov/patch

lib/zone_record.js#L145-L151

Added lines #L145 - L151 were not covered by tests
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

Check warning on line 158 in lib/zone_record.js

View check run for this annotation

Codecov / codecov/patch

lib/zone_record.js#L153-L158

Added lines #L153 - L158 were not covered by tests
case 'IPSECKEY':
applyMap(obj, {
Expand All @@ -159,7 +163,7 @@ function objectToDb(obj) {
weight: 'precedence',
priority: 'gateway type',
other: 'algorithm',
})
})
break

Check warning on line 167 in lib/zone_record.js

View check run for this annotation

Codecov / codecov/patch

lib/zone_record.js#L160-L167

Added lines #L160 - L167 were not covered by tests
case 'NAPTR':
applyMap(obj, {
Expand All @@ -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

Check warning on line 178 in lib/zone_record.js

View check run for this annotation

Codecov / codecov/patch

lib/zone_record.js#L169-L178

Added lines #L169 - L178 were not covered by tests
case 'SSHFP':
applyMap(obj, {
Expand All @@ -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]
}
}

Check warning on line 205 in lib/zone_record.js

View check run for this annotation

Codecov / codecov/patch

lib/zone_record.js#L200-L205

Added lines #L200 - L205 were not covered by tests

0 comments on commit f00011f

Please sign in to comment.