Statystyki serwer贸w
Pobieranie
import { getServersStatistics } from 'margonemski-harvester'
;(async () => {
const result = await getServersStatistics()
if (result.success) {
console.log(result.data)
} else {
console.error({
cause: result.cause,
errorName: result.errorName,
})
}
})()
Walidacja i parsowanie
Pomy艣lna walidacja i parsowanie s膮 wymagane do zwr贸cenia obiektu zawieraj膮cego pobrane dane, dlatego nie ma potrzeby ich ponownego wykonywania.
import {
type ServerStatistics,
serverStatisticsSchema,
serversStatisticsSchema,
} from 'margonemski-harvester'
const serverStatistics: ServerStatistics = {
maxOnline: 2313,
name: 'Tempest',
online: 241,
total: 10000,
}
const servers: ServerStatistics[] = [
serverStatistics,
serverStatistics,
serverStatistics,
]
const parsedServerStatistics = serverStatisticsSchema.parse(serverStatistics)
const parsedServers = serversStatisticsSchema.parse(servers)