consistency: snake_case for yaml
Massimo Melina committed
Jan 10, 2022 at 11:32 UTC
4dbbadf428b7725da97060de38ddeb26b2d63c08
6 files changed
+15
-12
README.md
+2
-2
@@ -41,8 +41,8 @@ Supported entries are:
41
E.g.: `"*.jpg": image/jpeg`
42
You can specify multiple entries, or separate multiple file masks with a p|pe.
43
You can use the special value `auto` to attempt automatic detection.
44
-- `max-kbps` throttle output speed. Default is Infinity.
45
-- `max-kbps-per-ip` throttle output speed on a per-ip basis. Default is Infinity.
44
+- `max_kbps` throttle output speed. Default is Infinity.
45
+- `max_kbps_per_ip` throttle output speed on a per-ip basis. Default is Infinity.
46
47
## Virtual File System (VFS)
48
config.yaml
+2
-2
@@ -1,6 +1,6 @@
1
#port: 80
2
-#max-kbps: 1000
3
-#max-kbps-per-ip: 500
2
+#max_kbps: 1000
3
+#max_kbps_per_ip: 500
4
mime:
5
"*.jpg|*.png|*.mp3|*.txt": auto
6
vfs:
dev-guidelines.md
new
+3
@@ -0,0 +1,3 @@
1
+- All objects that go in yaml should use snake_case.
2
+ - Reason: we want something that is both easy for the user and maps directly in our code.
3
+ Spaces and kebab-case don't play well with javascript and camel is less readable for the user.
src/api.auth.ts
+3
-3
@@ -22,9 +22,9 @@ export const login: ApiHandler = async ({ username, password }, ctx) => {
22
const acc = getAccount(username)
23
if (!acc)
24
return ctx.status = 401
25
- if (!acc.hashedPassword)
25
+ if (!acc.hashed_password)
26
return ctx.status = 406
27
- if (!await verifyPassword(acc.hashedPassword, password))
27
+ if (!await verifyPassword(acc.hashed_password, password))
28
return ctx.status = 401
29
if (ctx.session)
30
ctx.session.username = username
@@ -100,7 +100,7 @@ export const change_srp: ApiHandler = async ({ salt, verifier }, ctx) => {
100
return ctx.status = 401
101
await updateAccount(ctx.account, account => {
102
saveSrpInfo(account, salt, verifier)
103
- delete account.hashedPassword // remove leftovers
103
+ delete account.hashed_password // remove leftovers
104
})
105
return true
106
}
src/perm.ts
+3
-3
@@ -13,7 +13,7 @@ let path = ''
13
interface Account {
14
username: string, // we'll have username in it, so we don't need to pass it separately
15
password?: string
16
- hashedPassword?: string
16
+ hashed_password?: string
17
srp?: string
18
belongs?: string[]
19
ignore_limits?: boolean
@@ -58,12 +58,12 @@ export async function updateAccount(account: Account, changer?:Changer) {
58
if (account.password) {
59
console.debug('hashing password for', username)
60
if (getConfig(CFG_ALLOW_CLEAR_TEXT_LOGIN))
61
- account.hashedPassword = await hashPassword(account.password)
61
+ account.hashed_password = await hashPassword(account.password)
62
const res = await createVerifierAndSalt(srp6aNimbusRoutines, username, account.password)
63
saveSrpInfo(account, res.s, res.v)
64
delete account.password
65
}
66
- else if (!account.srp && account.hashedPassword) {
66
+ else if (!account.srp && account.hashed_password) {
67
console.log('please reset password for account', username)
68
process.exit(1)
69
}
src/throttler.ts
+2
-2
@@ -6,7 +6,7 @@ import { getOrSet } from './misc'
6
7
const mainThrottleGroup = new ThrottleGroup(Infinity)
8
9
-subscribeConfig({ k:'max-kbps', defaultValue:Infinity }, v =>
9
+subscribeConfig({ k:'max_kbps', defaultValue:Infinity }, v =>
10
mainThrottleGroup.updateLimit(v))
11
12
interface GroupThrottler { count:number, throttler:ThrottledStream }
@@ -20,7 +20,7 @@ export function throttler(): Koa.Middleware {
20
return
21
const ipGroup = getOrSet(ip2group, ctx.ip, ()=> {
22
const tg = new ThrottleGroup(Infinity, mainThrottleGroup)
23
- subscribeConfig({ k:'max-kbps-per-ip', defaultValue:Infinity }, v =>
23
+ subscribeConfig({ k:'max_kbps_per_ip', defaultValue:Infinity }, v =>
24
tg.updateLimit(v))
25
return { tg, count:0 }
26
})