mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
ranklist using files.ts, minor loggin improvements
This commit is contained in:
parent
0f66411b96
commit
c009a6f7d4
3 changed files with 8 additions and 8 deletions
|
@ -21,6 +21,7 @@
|
|||
import logger from '../../../utils/logger'
|
||||
import utils from '../../../utils/utils'
|
||||
import { Request, SubmoduleData, User } from '../../../types/basicTypes'
|
||||
import { paths } from '../../../utils/files'
|
||||
|
||||
interface Subjects {
|
||||
[key: string]: number
|
||||
|
@ -41,9 +42,6 @@ interface IdStatWithUID extends IdStat {
|
|||
userId: number
|
||||
}
|
||||
|
||||
const idStatFile = 'stats/idstats'
|
||||
const idvStatFile = 'stats/idvstats'
|
||||
|
||||
function mergeObjSum(a: Subjects, b: Subjects) {
|
||||
const res = { ...b }
|
||||
Object.keys(a).forEach((key) => {
|
||||
|
@ -67,14 +65,14 @@ function setup(data: SubmoduleData): void {
|
|||
const user: User = req.session.user
|
||||
|
||||
if (!querySince) {
|
||||
result = utils.ReadJSON(idStatFile)
|
||||
result = utils.ReadJSON(paths.idstatsFile)
|
||||
} else {
|
||||
try {
|
||||
const since = new Date(querySince)
|
||||
if (!(since instanceof Date) || isNaN(since.getTime())) {
|
||||
throw new Error('Not a date')
|
||||
}
|
||||
const data = utils.ReadJSON(idvStatFile)
|
||||
const data = utils.ReadJSON(paths.idvstatsFile)
|
||||
result = {}
|
||||
|
||||
Object.keys(data).forEach((key) => {
|
||||
|
|
|
@ -44,7 +44,9 @@ export const validateAndSetupFiles = (): boolean => {
|
|||
}
|
||||
|
||||
if (file.warningIfMissing && !fileExists) {
|
||||
const warningMsg = [`File "${file.path}" does not exist! (${key})`]
|
||||
const warningMsg = [
|
||||
`Optional file "${file.path}" does not exist! (${key})`,
|
||||
]
|
||||
if (file.description) {
|
||||
warningMsg.push(`Should be: ${file.description}`)
|
||||
}
|
||||
|
@ -81,7 +83,7 @@ const filesFiles = {
|
|||
httpsFiles: {
|
||||
path: 'data/httpsfiles.json',
|
||||
description:
|
||||
'file paths for https functionality (privkey, chain files). Optional if https server is not used',
|
||||
'file paths for https functionality (privkey, chain files)',
|
||||
schema: HttpsFilesSchema,
|
||||
warningIfMissing: true,
|
||||
},
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 8267534a3f4279169c9ed11d0bef019b12cac2a2
|
||||
Subproject commit 338db8e1417ba4aa647a74e0a5bad70fb04bc79e
|
Loading…
Add table
Add a link
Reference in a new issue