libretime/api
Jonas L 4603c1759f
feat!: use nginx to serve media files (#2860)
Closes #2522

To reduce the strain on the API service, we moved the media file serving
to the Nginx web server. The API is still handling the authentication,
but delegates the serving using the `X-Accel-Redirect` header.

BREAKING CHANGE: The media file serving is now handled by Nginx instead
of the API service. The `storage.path` field is now used in the Nginx
configuration, so make sure to update the Nginx configuration file if
you change it.
2023-12-30 18:59:15 +01:00
..
install/systemd fix(api): move gunicorn worker config to python file (#2854) 2023-12-29 17:47:50 +01:00
libretime_api feat!: use nginx to serve media files (#2860) 2023-12-30 18:59:15 +01:00
Makefile feat: add sentry sdk 2023-03-14 14:59:45 +00:00
README.md feat: use dedicated 'libretime' user 2022-07-07 10:51:07 +02:00
packages.ini feat(api): install gunicorn/uvicorn from pip 2023-05-11 09:52:58 +01:00
pyproject.toml chore(api): disable duplicate-code check (#2799) 2023-12-18 18:54:07 +01:00
requirements.txt chore(deps): update dependency uvicorn to >=0.17.6,<0.26.0 (#2773) 2023-12-22 18:12:09 +01:00
schema.yml fix(api): enum schema description (#2803) 2023-12-18 19:32:48 +01:00
setup.py build: replace custom release script with release-please (#2817) 2023-12-22 19:19:12 +01:00

README.md

LibreTime API

This API provides access to LibreTime's database via a Django application.

Deploying

Deploying in a production environment is done in the install script which installs LibreTime. This is how the API is installed in the Vagrant development images too. This method does not automatically reflect changes to this API. After any changes, the libretime-api systemd service needs restarting:

sudo systemctl restart libretime-api

Connections to the API are proxied through the Apache web server by default. Endpoint exploration and documentation is available from http://example.com/api/v2/schema/swagger-ui/, where example.com is the URL for the LibreTime instance.

Development

For development, you can install all required dependencies and loading the environment using the following command:

make install
source .venv/bin/activate

You should be able to lint or format the code or run api commands:

make format
make lint

libretime-api help

In order to work with the database and message queue, you need to start the docker based development stack present at the project root:

pushd ..
docker-compose up -d
popd

You can now run the api tests:

make test

Inside Vagrant

You can develop the api using a live reloading version within Vagrant:

vagrant up bullseye
vagrant ssh bullseye

cd /vagrant/api
sudo pip3 install -e .

sudo systemctl stop libretime-api
sudo -u libretime LIBRETIME_DEBUG=True libretime-api runserver 0.0.0.0:8081

3rd Party Licences

libretime_api/tests/resources/song.mp3: Steps - Tears On The Dancefloor (Album Teaser) by mceyedol. Downloaded from https://soundcloud.com/mceyedol/steps-tears-on-the-dancefloor-album-teaser released under a Creative Commons Licence (cc-by-sa-nc-sa)