@tf2pickup-org/serveme-tf-client
v0.1.2
Published
A serveme.tf API client
Downloads
3,113
Readme
Installation
npm i @tf2pickup-org/serveme-tf-client
Usage
Create a new reservation
import { Client, KnownEndpoint } from '@tf2pickup-org/serveme-tf-client';
const client = new Client({ apiKey: process.env.SERVEME_TF_API_KEY, endpoint: KnownEndpoint.europe });
// fetch all servers, configs and whitelists that serveme.tf provides
const { servers, serverConfigs, whitelists } = await client.findOptions();
// select a server
const selectedServer = servers[0];
// create a new reservation
const reservation = await client.create({ serverId: selectedServer.id });
console.log(`connect string: connect ${reservation.server.ip_and_port}; password ${reservation.password}`);
console.log(`rcon password: ${reservation.rcon}`);
Fetch and manage an existing reservation
import { Client, KnownEndpoint, ReservationId } from '@tf2pickup-org/serveme-tf-client';
const client = new Client({ apiKey: process.env.SERVEME_TF_API_KEY, endpoint: KnownEndpoint.europe });
const reservation = await client.fetch(1383514 as ReservationId);
console.log(`connect string: connect ${reservation.server.ip_and_port}; password ${reservation.password}`);
console.log(`rcon password: ${reservation.rcon}`);
// end the reservation
await reservation.end();