Skip to content

SKYNETWORK-MCBE/VotifierX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

English | 日本語

VotifierX

npm

A simple Votifier implementation in TypeScript. Including standalone server and client of Votifier v2 protocol.

Installation

npm install votifier-x

Usage

Server

import { VotifierServer } from 'votifier-x';

const server = new VotifierServer({
  port: 8192, // optional, default is 8192
  tokenPath: 'path/to/tokens.json', // optional, default is 'tokens.json'
});
server.start();

server.on('vote', (vote) => {
  console.log(`Received vote from ${vote.username} at ${vote.address}`);
});

Client

import { VotifierClient } from 'votifier-x';

const client = new VotifierClient({
  host: '0.0.0.0',
  port: 8192,
  token: 'your-token',
  serviceName: 'your-service-name',
});

await client.sendVote({
  username: 'username',
  address: 'address',
});

Tokens Configuration (tokens.json)

The server uses a tokens.json file to authenticate incoming votes from different voting lists. It is a simple key-value JSON object where keys are the serviceName and values are the corresponding token strings.

{
  "default": "auto-generated-token-string",
  "your-service-name": "another-token-here"
}

If the specified tokenPath file does not exist when the server starts, the server will automatically generate a new configuration file containing a single default token. You will need to provide this token when you register your server on a voting list.

Acknowledgements

About

Votifier implementation in TypeScript. Including standalone server and client.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors