Giter Site home page Giter Site logo

lottery-jug-rust's Introduction

Jug Lottery (v3)

Rust implementation of Montpellier Jug lottery (third version).
This implementation is a project to demonstrate the utilisation of several crates :

Configuration

The application should run with the following env vars :

  • ORGANIZER_TOKEN : Organization id in eventbrite
  • EVENTBRITE_TOKEN : Personal OAuth Token in eventbrite
  • RUST_LOG : Log level (example : info)
  • DATABASE_URL : Database SQLite url (example : test.db)

Development

The databases migrations will be executed by the application on startup.
If you want to executed the migrations manually (to check your scripts) :

# DATABASE_URL env var is mandatory
cargo install diesel_cli # to install diesel command
diesel setup # initialize database if needed
diesel migration run

Requirements

Needed packages for build:

  • libssl
  • libsqlite3

Docker

The application can be build in Docker Dockerfile : docker build -t lottery-jug-actix .

Run the application : docker run -e ORGANIZER_TOKEN=91672475603 -e EVENTBRITE_TOKEN=E7N7QDHSXM2V2YB6AC2I -p 8088:8088 lottery-jug-actix

The DATABASE_URL is by default on /var/data/lottery-jug/lottery.db.
The RUST_LOG is be default set to info.

API

Draw winners

GET -> /winners?nb=X

Results :

  • 200 :
[
  {
    "first_name": "Francois",
    "last_name": "Teychene"
  },
  {
    "first_name": "Jean-Luc",
    "last_name": "Racine"
  },
  {
    "first_name": "Renard",
    "last_name": "Chenapan"
  }
]
  • 400 : Invalid parameter
  • 503 : No live events
  • 500 : Unxepected error

Record a winner

POST -> /record

Body :

{
  "first_name": "Francois",
  "last_name": "Teychene"
}

Results :

  • 200 :
{
   "id": "b3f0182e-b2f4-47a2-9c6f-9ea3a67b588c",
   "first_name": "Francois",
   "last_name": "Teychene",
   "event_id": "52097259305"
}
  • 500 : Unexpected error

lottery-jug-rust's People

Contributors

fteychene avatar

Stargazers

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