Aktualisiere die Version auf 1.4.3, füge Validierung für Saison-Slugs hinzu und implementiere ein Logging-System für Fehler und Informationen
Some checks failed
Code Analysis and Production Deploy / analyze (push) Has been skipped
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Successful in 1m49s
Code Analysis and Production Deploy / analyze (pull_request) Failing after 2m37s
Code Analysis and Production Deploy / deploy-production (pull_request) Has been skipped
Code Analysis and Production Deploy / deploy-test (pull_request) Has been skipped
Require Package Version Change / check (pull_request) Failing after 8s
Some checks failed
Code Analysis and Production Deploy / analyze (push) Has been skipped
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Successful in 1m49s
Code Analysis and Production Deploy / analyze (pull_request) Failing after 2m37s
Code Analysis and Production Deploy / deploy-production (pull_request) Has been skipped
Code Analysis and Production Deploy / deploy-test (pull_request) Has been skipped
Require Package Version Change / check (pull_request) Failing after 8s
This commit is contained in:
27
server/utils/logger.js
Normal file
27
server/utils/logger.js
Normal file
@@ -0,0 +1,27 @@
|
||||
export function _formatMessage(level, message, context) {
|
||||
const time = new Date().toISOString()
|
||||
try {
|
||||
const ctx = context ? ` ${JSON.stringify(context)}` : ''
|
||||
return `${time} [${level}] ${message}${ctx}`
|
||||
} catch (_e) {
|
||||
return `${time} [${level}] ${message}`
|
||||
}
|
||||
}
|
||||
|
||||
export function info(message, context) {
|
||||
console.log(_formatMessage('info', message, context))
|
||||
}
|
||||
|
||||
export function warn(message, context) {
|
||||
console.warn(_formatMessage('warn', message, context))
|
||||
}
|
||||
|
||||
export function error(message, context) {
|
||||
console.error(_formatMessage('error', message, context))
|
||||
}
|
||||
|
||||
export default {
|
||||
info,
|
||||
warn,
|
||||
error
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { promises as fs } from 'fs'
|
||||
import path from 'path'
|
||||
import { getProjectPath, getServerDataPath } from './paths.js'
|
||||
import { error as loggerError, info as loggerInfo } from './logger.js'
|
||||
|
||||
const SPIELPLAN_HEADERS = [
|
||||
'Termin',
|
||||
@@ -76,10 +77,10 @@ function seasonSlugToLabel(slug) {
|
||||
}
|
||||
|
||||
function logReadError(message, filePath, error) {
|
||||
console.error(message, { filePath, error })
|
||||
loggerError(message, { filePath, error })
|
||||
}
|
||||
|
||||
function requireSeasonSlug(seasonSlug) {
|
||||
export function requireSeasonSlug(seasonSlug) {
|
||||
const value = String(seasonSlug || '')
|
||||
if (!SEASON_SLUG_PATTERN.test(value)) {
|
||||
throw new Error(`Ungueltiger Spielplan-Saison-Slug: ${value}`)
|
||||
@@ -87,6 +88,15 @@ function requireSeasonSlug(seasonSlug) {
|
||||
return value
|
||||
}
|
||||
|
||||
export function validateSeasonSlug(seasonSlug) {
|
||||
try {
|
||||
requireSeasonSlug(seasonSlug)
|
||||
return true
|
||||
} catch (_e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeSpielplanCsvPath(csvPath) {
|
||||
const value = String(csvPath || '')
|
||||
if (value.includes('\0') || path.basename(value) !== 'spielplan.csv') {
|
||||
|
||||
Reference in New Issue
Block a user