Giter Club home page Giter Club logo

bananas-api's Introduction

BaNaNaS API

GitHub License GitHub Tag GitHub commits since latest release

GitHub Workflow Status (Testing) GitHub Workflow Status (Publish Image) GitHub Workflow Status (Deployments)

GitHub deployments (Staging) GitHub deployments (Production)

This is the HTTP API for OpenTTD's content service, called BaNaNaS. It works together with bananas-server, which serves the in-game client.

Development

This API is written in Python 3.8 with aiohttp, and makes strong use of asyncio.

Running a local server

Dependencies

  • Python3.8 or higher.
  • tusd. For example, copy the tusd binary in your ~/.local/bin.

Preparing your venv

To start it, you are advised to first create a virtualenv:

python3 -m venv .env
.env/bin/pip install -r requirements.txt

Starting a local server

You can start the HTTP server by running:

.env/bin/python -m bananas_api --web-port 8080 --tusd-port 1080 --storage local --index local --user developer --client-file clients-development.yaml

This will start the API on port 8080 for you to work with locally.

Running via docker

docker build -t openttd/bananas-api:local .
export BANANAS_COMMON=$(pwd)/../bananas-common
mkdir -p "${BANANAS_COMMON}/local_storage" "${BANANAS_COMMON}/BaNaNaS"
docker run --rm -p 127.0.0.1:8080:80 -p 127.0.0.1:1080:1080 -v "${BANANAS_COMMON}/local_storage:/code/local_storage" -v "${BANANAS_COMMON}/BaNaNaS:/code/BaNaNaS" openttd/bananas-api:local

The mount assumes that bananas-server and this repository has the same parent folder on your disk, as both servers need to read the same local storage.

Files upload (tusd)

tusd runs on its own port (1080 by default), and listens on /new-package/files. With other words: the webserver does not forward that URL to tusd. This means that for clients, you need to contact two endpoints:

  • the web-port for everything except /new-package/files.
  • the tusd-port for /new-package/files.

In production the Load Balancer redirects the URLs to the right ports, but during development this is something to keep in mind.

bananas-frontend-cli for example allows you to define the web-endpoint and the tusd-endpoint.

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.