Giter Site home page Giter Site logo

difficulty-api's Introduction

difficulty-api

Travis Build Status

Description

difficulty-api is the backend for a script which helps estimate the difficulty of targets in the game Torn. It stores an attack log for each of its users. It uses its stored attacks to give an estimated difficulty rating for a target, given a would-be attacker's battle stats.

In order to achieve this functionality, difficulty-api exposes two endpoints: api-key and difficulties. The api-key endpoint is used for signing up by submitting an api key or just updating the api key for an existing player if it has changed. The difficulties endpoint requires an api key to determine the identity of the caller as well as a list of torn player ids whose difficulties will be estimated.

Installation

You will need a license for Datomic Pro, which you can get here. In order to install it, follow the instructions provided by Datomic under Leiningen setup. You can also set the environment variables $DATOMIC_USERNAME and $DATOMIC_PASSWORD. If you need persistent storage, like on a production server, you will need to provision that storage. This project is set up to use Postgres, which Datomic provides instructions for here. In order to connect to a persistent database, you will need to have a transactor running.

Create a file resources/env.edn which has a map like {:config-file "resources/dev.edn"} which points to the edn file containing your config options.

Usage

Run the application locally

lein repl
(go)

Run the tests

lein test

Packaging and running as standalone jar

Before starting the application in a production setting (with persistent storage), make sure the Datomic transactor is running.

lein do clean, uberjar
java -jar target/difficulty-api-$VERSION-standalone.jar

Connecting to the embedded repl

If you are running with the default settings (and use leiningen), you can connect to the embedded repl with

lein repl :connect localhost:7888

If you have the application running on a production server with your repl port blocked (as it should be), you can connect to the embedded repl using an ssh tunnel with port forwarding. In one terminal, set up the ssh tunnel:

ssh -nNT -L 9000:localhost:7888 username@serveraddress

Now you can connect to the embedded repl with

lein repl :connect localhost:9000

difficulty-api's People

Contributors

codonnell avatar

Watchers

 avatar James Cloos 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.