Skip to content

Commit 3306fb3

Browse files
committed
doc(CONTRIBUTORS): added
1 parent 42e0b74 commit 3306fb3

12 files changed

Lines changed: 76 additions & 25 deletions

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Changelog
2+
3+
The format is based on [Keep a Changelog](https://keepachangelog.com/).
4+
15
# CHANGES
26

37
### Unreleased
@@ -39,6 +43,9 @@
3943
- lib/user.get: convert booleans
4044

4145

46+
[3.0.0-alpha.0]: https://github.com/NicTool/api/releases/tag/3.0.0-alpha.0
47+
[3.0.0-alpha.1]: https://github.com/NicTool/api/releases/tag/3.0.0-alpha.1
48+
[3.0.0-alpha.2]: https://github.com/NicTool/api/releases/tag/3.0.0-alpha.2
4249
[3.0.0-alpha.3]: https://github.com/NicTool/api/releases/tag/3.0.0-alpha.3
4350
[3.0.0-alpha.4]: https://github.com/NicTool/api/releases/tag/3.0.0-alpha.4
4451
[3.0.0-alpha.5]: https://github.com/NicTool/api/releases/tag/3.0.0-alpha.5

CONTRIBUTORS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Contributors
2+
3+
This handcrafted artisanal software is brought to you by:
4+
5+
| <img height="80" src="https://avatars.githubusercontent.com/u/261635?v=4"><br><a href="https://github.com/msimerson">msimerson</a> (<a href="https://github.com/NicTool/api/commits?author=msimerson">14</a>)|
6+
| :---: |
7+
8+
<sub>this file is generated by [.release](https://github.com/msimerson/.release).
9+
Contribute to this project to get your GitHub profile included here.</sub>

lib/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Config {
1212
this.getEnv(opts)
1313
}
1414

15-
async getEnv(opts = {}) {
15+
getEnv(opts = {}) {
1616
this.env = process.env.NODE_ENV ?? opts.env ?? ''
1717
this.debug = Boolean(process.env.NODE_DEBUG)
1818
if (this.debug) console.log(`debug: true, env: ${this.env}`)

lib/config.test.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ describe('config', () => {
1717

1818
it(`loads mysql cov config`, async () => {
1919
const cfg = await Config.get('mysql', 'cov')
20-
assert.deepEqual(cfg, mysqlTestCfg)
20+
assert.deepEqual(cfg, mysqlCovCfg)
2121
})
2222

2323
it(`loads mysql cov config (from cache)`, async () => {
2424
process.env.NODE_DEBUG = 1
2525
const cfg = await Config.get('mysql', 'cov')
26-
assert.deepEqual(cfg, mysqlTestCfg)
26+
assert.deepEqual(cfg, mysqlCovCfg)
2727
process.env.NODE_DEBUG = ''
2828
})
2929

@@ -39,20 +39,28 @@ describe('config', () => {
3939

4040
it(`detects NODE_DEBUG env`, async () => {
4141
process.env.NODE_DEBUG = 1
42-
let cfg = await Config.get('mysql', 'test')
42+
await Config.get('mysql', 'test')
4343
assert.equal(Config.debug, true)
4444

4545
process.env.NODE_DEBUG = ''
46-
cfg = await Config.get('mysql', 'test')
46+
await Config.get('mysql', 'test')
4747
assert.equal(Config.debug, false)
48-
49-
cfg = await Config.get('mysql', 'test')
50-
assert.equal(cfg.user, 'root')
5148
})
5249
})
5350
})
5451

5552
const mysqlTestCfg = {
53+
host: '127.0.0.1',
54+
port: 3306,
55+
user: 'nictool',
56+
password: 'StaySafeOutThere',
57+
database: 'nictool',
58+
timezone: '+00:00',
59+
dateStrings: ['DATETIME', 'TIMESTAMP'],
60+
decimalNumbers: true,
61+
}
62+
63+
const mysqlCovCfg = {
5664
host: '127.0.0.1',
5765
port: 3306,
5866
user: 'root',

lib/session.test.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,20 @@ import User from './user.js'
55
import Session from './session.js'
66
import userCase from './test/user.json' with { type: 'json' }
77

8+
const sessionUser = {
9+
...userCase,
10+
id: userCase.id + 100,
11+
username: `${userCase.username}-session`,
12+
email: `session-${userCase.email}`,
13+
}
14+
815
before(async () => {
9-
await User.create(userCase)
16+
await User.create(sessionUser)
1017
})
1118

1219
after(async () => {
20+
await Session.delete({ uid: sessionUser.id })
21+
await User.destroy({ id: sessionUser.id })
1322
await User.mysql.disconnect()
1423
})
1524

@@ -20,7 +29,7 @@ describe('session', function () {
2029
describe('create', () => {
2130
it('creates a login session', async () => {
2231
sessionId = await Session.create({
23-
nt_user_id: userCase.id,
32+
nt_user_id: sessionUser.id,
2433
session: '3.0.0',
2534
last_access: parseInt(Date.now() / 1000, 10),
2635
})
@@ -31,7 +40,6 @@ describe('session', function () {
3140
describe('get', () => {
3241
it('finds a session by id', async () => {
3342
const s = await Session.get({ id: sessionId })
34-
// console.log(s)
3543
assert.ok(s?.id)
3644
})
3745

lib/test/nameserver.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"interval": 0,
1313
"serials": true,
1414
"status": "last run:03-05 15:25<br>last cp :09-20 12:59",
15-
"type": "NSD"
15+
"type": "nsd"
1616
},
1717
"ttl": 3600
1818
}

lib/zone.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class Zone {
5151
for (const f of ['description', 'location']) {
5252
if ([null].includes(row[f])) row[f] = ''
5353
}
54+
if (row['last_publish'] === undefined) delete row['last_publish']
55+
if (/00:00:00/.test(row['last_publish'])) row['last_publish'] = null
5456
if (args.deleted === false) delete row.deleted
5557
}
5658

lib/zone_record.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { mapToDbColumn } from './util.js'
55

66
const zrDbMap = { id: 'nt_zone_record_id', zid: 'nt_zone_id', owner: 'name' }
77
const boolFields = ['deleted']
8+
const keepZeroWeightFor = new Set(['SRV', 'URI'])
9+
const keepZeroPriorityFor = new Set(['HTTPS', 'SVCB', 'URI'])
810

911
class ZoneRecord {
1012
constructor() {
@@ -29,6 +31,10 @@ class ZoneRecord {
2931
async get(args) {
3032
args = JSON.parse(JSON.stringify(args))
3133
if (args.deleted === undefined) args.deleted = false
34+
if (args.type !== undefined) {
35+
args.type_id = RR.typeMap[args.type]
36+
delete args.type
37+
}
3238

3339
const rows = await Mysql.execute(
3440
...Mysql.select(
@@ -107,15 +113,21 @@ function dbToObject(rows) {
107113
const map = getMap(row.type)
108114
if (map) unApplyMap(row, map)
109115

110-
for (const f of [
111-
'description',
112-
'other',
113-
'location',
114-
'weight',
115-
'priority',
116-
'timestamp',
117-
]) {
118-
if (null === row[f]) delete row[f]
116+
if ([null, ''].includes(row.description)) delete row.description
117+
if ([null, '', '0'].includes(row.other)) delete row.other
118+
if ([null, ''].includes(row.location)) delete row.location
119+
if (row.timestamp === null) delete row.timestamp
120+
121+
if (row.weight === null) {
122+
delete row.weight
123+
} else if (row.weight === 0 && !keepZeroWeightFor.has(row.type)) {
124+
delete row.weight
125+
}
126+
127+
if (row.priority === null) {
128+
delete row.priority
129+
} else if (row.priority === 0 && !keepZeroPriorityFor.has(row.type)) {
130+
delete row.priority
119131
}
120132
}
121133

lib/zone_record.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ describe('zone_record', function () {
3535
})
3636

3737
it('GET by name', async () => {
38-
const zrs = await ZoneRecord.get({ zone_record: testCase.zone_record })
38+
const zrs = await ZoneRecord.get({
39+
owner: testCase.owner,
40+
type: testCase.type,
41+
zid: testCase.zid,
42+
})
3943
delete zrs[0].last_modified
4044
assert.deepEqual(zrs[0], testCase)
4145
})

0 commit comments

Comments
 (0)