Skip to content

Commit 19814dc

Browse files
committed
chore(grabber): add more comments in config.example.yml
1 parent 265c72e commit 19814dc

File tree

3 files changed

+57
-27
lines changed

3 files changed

+57
-27
lines changed

config.example.yml

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,56 @@
1-
# NyaaStats configuration
2-
web:
3-
title: Nyaa Stats # website title
4-
servername: Minecraft Server # Server Name
5-
homepage: https://minecraft.example.com # Your homepage
1+
# NYAA-STATS CONFIGURATION FILE
62

3+
# Grabber (main program) configuration
74
render:
8-
crafatar: https://crafatar.com # crafatar service host, required
9-
level: data/level.dat # file path here, required
10-
playerdata: data/playerdata # directory path here, required
11-
stats: data/stats # directory path here, required
12-
advancements: data/advancements # advancements path here, required
13-
whitelist: whitelist.json # file path here, leave blank to disable
14-
banned-players: banned-players.json # file path here, leave blank to disable
15-
render-banned: false # do not render banned players
16-
output: web/public/data # directory path here, required
5+
# Data sources
6+
7+
# [Required] `level.dat` file path. Example: "/opt/minecraft/world/level.dat"
8+
level: data/level.dat
9+
# [Required] `playerdata` directory path. Example: "/opt/minecraft/world/playerdata"
10+
playerdata: data/playerdata
11+
# [Required] `stats` directory path. Example: "/opt/minecraft/world/stats"
12+
stats: data/stats
13+
# [Required] `advancements` directory path. Example: "/opt/minecraft/world/advancements"
14+
advancements: data/advancements
15+
# Whether to only process whitelisted players. Possible values:
16+
# {string} - `whitelist.json` file path. Example: "/opt/minecraft/whitelist.json"
17+
# (unset) - Disable this feature (to process all reachable players)
18+
whitelist: whitelist.json
19+
# Banned UUID list. Possible values:
20+
# {string} - `banned-players.json` file path. Example: "/opt/minecraft/banned-players.json"
21+
# (unset) - Disable this feature (to assume no bans)
22+
banned-players: banned-players.json
23+
# Whether to render banned players. Default value: `false`
24+
render-banned: false
25+
# [Required] Crafatar service URL, used for player avatar/skin model generating
26+
crafatar: https://crafatar.com
27+
28+
# Output
29+
30+
# [Required] Output data directory path (absolute or relative to runtime `config.yml`)
31+
# Example: "webroot/data"
32+
output: web/public/data
33+
# Whether to prompt confirmation to clear output directory. You may want to set `false` if you're
34+
# using cronjob. Possible values:
35+
# `true` | (unset) - Prompt confirmation. You can choose yes or no to output directory clearing
36+
# `false` - Disable this feature (will not clear output directory)
37+
confirm-clear-data: true
38+
# [Deprecated]
1739
time-format: # time format on display, details http://momentjs.com/docs/#/displaying/format/
1840
full: dddd, MMMM Do, YYYY HH:mm:ss ZZ
1941
short: MMMM Do, YYYY
2042
compact: YYYY-M-D HH:mm:ss
21-
# prompt confirmation to remove old data.
22-
# Set to false if you are using cronjob,
23-
# true when you run it manually.
24-
# data directory will be cleared when manipulating new data.
25-
confirm-clear-data: true
2643

44+
# API usage configuration
2745
api:
28-
ratelimit: 2 # set to 1 request per sec as per mojang api rate limit
46+
# [Required] Mojang API request rate limit (N req per second)
47+
ratelimit: 2
48+
49+
# Web app configuration
50+
web:
51+
# [Required] Web app title, will be displayed at page header and as window title
52+
title: Nyaa Stats
53+
# [Required] Server name, will be displayed at welcome section and page footer
54+
servername: Minecraft Server
55+
# [Required] Server homepage URL, will be displayed at welcome section
56+
homepage: https://minecraft.example.com

types/nyaa-stats.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ interface NSConfig {
1010
playerdata: string
1111
stats: string
1212
advancements: string
13-
whitelist: string
14-
'banned-players': string
15-
'render-banned': boolean
13+
whitelist?: string
14+
'banned-players'?: string
15+
'render-banned'?: boolean
1616
output: string
1717
'time-format': {
1818
full: string

utils.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,17 @@ export default class Utils {
6363

6464
getWhitelistedPlayers (): LongUuid[] {
6565
const uuids: LongUuid[] = []
66-
JSON.parse(fs.readFileSync(this.config.render.whitelist, 'utf8')).forEach((p: McWhitelistRecord) => {
66+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
67+
JSON.parse(fs.readFileSync(this.config.render.whitelist!, 'utf8')).forEach((p: McWhitelistRecord) => {
6768
uuids.push(p.uuid)
6869
})
6970
return uuids
7071
}
7172

7273
getBannedPlayers (): LongUuid[] {
7374
const banlist: LongUuid[] = []
74-
const banned = JSON.parse(fs.readFileSync(path.join(this.config.render['banned-players']), 'utf8')) as McBannedPlayersJson
75+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
76+
const banned = JSON.parse(fs.readFileSync(path.join(this.config.render['banned-players']!), 'utf8')) as McBannedPlayersJson
7577
banned.forEach((ban) => {
7678
banlist.push(ban.uuid)
7779
})
@@ -259,9 +261,9 @@ export default class Utils {
259261
let data
260262
try {
261263
if (fs.existsSync(path.join(playerpath, 'stats.json'))) {
262-
data = JSON.parse(fs.readFileSync(path.join(playerpath, 'stats.json'), 'utf-8'))
264+
data = JSON.parse(fs.readFileSync(path.join(playerpath, 'stats.json'), 'utf-8'))
263265
} else {
264-
data = await this.getPlayerTotalData(uuid)
266+
data = await this.getPlayerTotalData(uuid)
265267
}
266268
} catch (error) {
267269
throw new Error(error)

0 commit comments

Comments
 (0)