Skip to content

Commit 42e0b74

Browse files
authored
Release v3.0.0-alpha.6 (#33)
- dep(eslint): upgrade to v9 - dep(\*): bump versions to latest - feat(conf.d/http): added tls - feat(session): added JWT for session auth - feat(zone): removed location - feat(routes/zone_record): added, fixes #17 - change(routes/users): result is always array - change(routes/ns): GET id is optional, result is always array - change(routes/zone): GET id is optional, result is always array
1 parent c739a73 commit 42e0b74

30 files changed

Lines changed: 456 additions & 285 deletions

.eslintrc.yaml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
env:
1010
CI: true
1111
NODE_ENV: test
12+
NODE_VER: 22
1213

1314
jobs:
1415
lint:
@@ -21,7 +22,7 @@ jobs:
2122
run: sudo /etc/init.d/mysql start
2223
- uses: actions/setup-node@v4
2324
with:
24-
node-version: 20
25+
node-version: ${{ env.NODE_VER }}
2526
- uses: actions/checkout@v4
2627
- run: npm install
2728
- name: Initialize MySQL
@@ -43,17 +44,19 @@ jobs:
4344
- id: get
4445
uses: msimerson/node-lts-versions@v1
4546
outputs:
46-
lts: ${{ steps.get.outputs.lts }}
4747
active: ${{ steps.get.outputs.active }}
48+
maintenance: ${{ steps.get.outputs.maintenance }}
49+
lts: ${{ steps.get.outputs.lts }}
50+
current: ${{ steps.get.outputs.current }}
51+
min: ${{ steps.get.outputs.min }}
4852

4953
test:
5054
needs: [ get-lts ]
5155
runs-on: ${{ matrix.os }}
5256
strategy:
5357
matrix:
5458
os: [ubuntu-latest]
55-
# node-version: ${{ fromJson(needs.get-lts.outputs.active) }}
56-
node-version: [ 20 ]
59+
node-version: ${{ fromJson(needs.get-lts.outputs.active) }}
5760
fail-fast: false
5861
steps:
5962
- run: sudo /etc/init.d/mysql start
@@ -70,15 +73,13 @@ jobs:
7073
runs-on: macos-latest
7174
strategy:
7275
matrix:
73-
# node-version: ${{ fromJson(needs.get-lts.outputs.active) }}
74-
node-version: [ 20 ]
76+
node-version: ${{ fromJson(needs.get-lts.outputs.active) }}
7577
fail-fast: false
7678
steps:
7779
- name: Install & Start MySQL
7880
run: |
79-
brew install mysql
80-
brew tap homebrew/services
81-
brew services start mysql
81+
brew install mysql@8.4
82+
brew services start mysql@8.4
8283
- uses: actions/checkout@v4
8384
- uses: actions/setup-node@v4
8485
name: Node ${{ matrix.node-version }} on ${{ matrix.os }}
@@ -94,8 +95,7 @@ jobs:
9495
runs-on: windows-latest
9596
strategy:
9697
matrix:
97-
node-version: [ 20 ]
98-
# node-version: ${{ fromJson(needs.get-lts.outputs.active) }}
98+
node-version: ${{ fromJson(needs.get-lts.outputs.active) }}
9999
experimental: [true]
100100
fail-fast: false
101101
steps:

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
### Unreleased
44

5+
### [3.0.0-alpha.6] - 2025-04-08
6+
7+
- dep(eslint): upgraded to v9
8+
- dep(\*): bump versions to latest
9+
- feat(conf.d/http): added tls
10+
- feat(session): added JWT for session auth
11+
- feat(zone): removed location
12+
- feat(routes/zone_record): added, fixes #17
13+
- change(routes/users): result is always array
14+
- change(routes/ns): GET id is optional, result is always array
15+
- change(routes/zone): GET id is optional, result is always array
516

617
### [3.0.0-alpha.5] - 2024-03-06
718

@@ -31,3 +42,4 @@
3142
[3.0.0-alpha.3]: https://github.com/NicTool/api/releases/tag/3.0.0-alpha.3
3243
[3.0.0-alpha.4]: https://github.com/NicTool/api/releases/tag/3.0.0-alpha.4
3344
[3.0.0-alpha.5]: https://github.com/NicTool/api/releases/tag/3.0.0-alpha.5
45+
[3.0.0-alpha.6]: https://github.com/NicTool/api/releases/tag/3.0.0-alpha.6

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Running one of these commands:
2929

3030
`npm run start (production)`
3131

32-
or
32+
or
3333

3434
`npm run develop (development)`
3535

conf.d/http.yml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
default:
22
host: localhost
33
port: 3000
4+
tls:
5+
key: null
6+
cert: null
7+
jwt:
8+
key: 'af1b926a5e21f535c4f5b6c42941c4cf'
49
cookie:
510
# https://hapi.dev/module/cookie/api/?v=12.0.1
611
name: sid-nictool
@@ -11,7 +16,7 @@ default:
1116
clearInvalid: true
1217
isSameSite: Strict
1318
isSecure: true
14-
isHttpOnly: true
19+
isHttpOnly: false
1520
keepAlive: false
1621
# redirectTo:
1722
group: NicTool
@@ -28,6 +33,32 @@ test:
2833
password: ^NicTool.Is,The#Best_Dns-Manager$
2934

3035
development:
36+
host: box-under-my-desk.example.com
37+
tls:
38+
key: |
39+
-----BEGIN PRIVATE KEY-----
40+
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDwBx1Qt9309i89
41+
O9Y8bhHO9BqyWWzd0hXI1o3d8Zn4aT2lhwmeeu2oSQsczvny0cJSs6HYe6asI6XZ
42+
<snip>
43+
Ane1BnOJ6/E+7Clo463N++OS
44+
-----END PRIVATE KEY-----
45+
46+
cert: |
47+
-----BEGIN CERTIFICATE-----
48+
MIID9DCCAtygAwIBAgIUF+ziLgjIA3qCf95DmVskHqSNvLUwDQYJKoZIhvcNAQEL
49+
BQAwfDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xGjAYBgNVBAoM
50+
<snip>
51+
juZxYqQoPYBpk+eG/sudGGFKKGow1RbGbbNUrqATYxJCqPrN0mZuNkAgATbQtBjS
52+
vyvASCDueS0=
53+
-----END CERTIFICATE-----
54+
-----BEGIN CERTIFICATE-----
55+
MIID2TCCAsGgAwIBAgIUF+ziLgjIA3qCf95DmVskHqSNvLEwDQYJKoZIhvcNAQEL
56+
BQAwfDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xGjAYBgNVBAoM
57+
<snip>
58+
iMt4AE3zfKgj/OLyAeseUlqukbnBQYlTiMUuPLTTp6d7uBi8/VuXBTrZ9nafPvSZ
59+
TqccpFMgxCeImsJCgO5hBJYUTELDNEmJS5Vgy3Y=
60+
-----END CERTIFICATE-----
61+
3162
cookie:
32-
isSecure: false
63+
# isSecure: false
3364
password: ^NicTool.Is,The#Best_Dns-Manager$

eslint.config.mjs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import globals from "globals";
2+
import babelParser from "@babel/eslint-parser";
3+
import path from "node:path";
4+
import { fileURLToPath } from "node:url";
5+
import js from "@eslint/js";
6+
import { FlatCompat } from "@eslint/eslintrc";
7+
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = path.dirname(__filename);
10+
const compat = new FlatCompat({
11+
baseDirectory: __dirname,
12+
recommendedConfig: js.configs.recommended,
13+
allConfig: js.configs.all
14+
});
15+
16+
export default [...compat.extends("eslint:recommended"), {
17+
languageOptions: {
18+
globals: {
19+
...globals.node,
20+
},
21+
22+
parser: babelParser,
23+
ecmaVersion: "latest",
24+
sourceType: "module",
25+
26+
parserOptions: {
27+
babelOptions: {
28+
configFile: false,
29+
plugins: ["@babel/plugin-syntax-import-attributes"],
30+
},
31+
32+
requireConfigFile: false,
33+
},
34+
},
35+
36+
rules: {
37+
"no-unused-vars": "warn"
38+
},
39+
}];

lib/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class Config {
4040

4141
const str = fsSync.readFileSync(`./conf.d/${name}.yml`, 'utf8')
4242
const cfg = YAML.parse(str)
43+
if (this.debug) console.debug(cfg)
4344

4445
this.cfg[cacheKey] = applyDefaults(cfg[env ?? this.env], cfg.default)
4546
return this.cfg[cacheKey]

lib/config.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,21 @@ const httpCfg = {
6868
port: 3000,
6969
cookie: {
7070
clearInvalid: true,
71-
isHttpOnly: true,
71+
isHttpOnly: false,
7272
isSameSite: 'Strict',
7373
isSecure: false,
7474
name: 'sid-nictool',
7575
password: '^NicTool.Is,The#Best_Dns-Manager$',
7676
path: '/',
7777
ttl: 3600000,
7878
},
79+
jwt: {
80+
key: 'af1b926a5e21f535c4f5b6c42941c4cf',
81+
},
82+
tls: {
83+
cert: null,
84+
key: null,
85+
},
7986
keepAlive: false,
8087
group: 'NicTool',
8188
}

lib/session.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@ class Session {
5353

5454
if (args.last_access) {
5555
const p = await this.get({ id: args.id })
56+
if (!p) return false
57+
5658
// if less than 60 seconds old, do nothing
5759
const now = parseInt(Date.now() / 1000, 10)
5860
const oneMinuteAgo = now - 60
61+
5962
// update only when +1 minute old (save DB writes)
6063
if (p.last_access > oneMinuteAgo) return true
6164
args.last_access = now

0 commit comments

Comments
 (0)