Code Monkey home page Code Monkey logo

votifier's Introduction

node-votifier

Emulates a Bukkit Votifier server in Node.js

We at CubixCraft don't like Java that much. It kinda sucks a speed. So we always try to replace it with Node.js, whenever it's possible. So is this case. Using node-votifier reduces load on your precious Bukkit and transfers it to your wonderful Node.js app. Plus it's super easy to add vote listeners. No lame .class files anymore!


Requirements

I recommend using an Ubuntu server. However it should work on Windows / OS X / whatsoever, if your computer supports the requirements listed above.

The RSA keys aren't automatically generated by node-votifier. But it's easy to create them yourself:

  1. openssl genrsa -out private.pem 2048 generates a 2048 bit private key and stores it as private.pem
  2. openssl rsa -in private.pem -pubout > public.pem extracts the public key and stores it as public.pem

Use the public key for all the server lists. Keep the private key private. Otherwise anybody is able to cheat on your vote system.

Installation

npm install votifier

You could also clone this repository. If you wanna do this, you know how.

How to use

Assuming your private.pem is in the same directory as your app, a working Votifier would look like this. An extended example with error handling can be found in the examples directory.

var Votifier = require("node-votifier");
var votifier = new Votifier(__dirname + "/private.pem");

votifier.on("vote", function(user, server, ip, date) {
  console.log(user + " voted.")
});

Complete API

  • require("node-votifier") returns a Votifier Class.
  • new Votifier(pathToPrivateKey, port, debug) return a Votifier instance. Constructor requires the absolute path to the private key file. The port is optional and defaults to 8192. Votifier inherits of EventEmitter.
    • vote event. This event passes a vote object with the following fields: user (username of the voter), service (name of the server list), ip (IP of the voter) and ts (date and time of the vote as a Date) to its listeners. It is fired, when Votifier receives a vote.
    • error event. This event passes error (Error with some infomation), to its listeners. This event is fired when something went wrong.

Contributing

Yes! Please! Fork and pull request! If you experience any issues you don't know how to fix or have any feature requests you're welcome to create an issue.

License

(The MIT License)

Copyright (c) 2012 Jan Buschtöns <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

votifier's People

Contributors

buschtoens avatar paulish avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.