Skip to content

wsand02/waveemapi3

Repository files navigation

waveemapi3

GitHub Release Rust Clippy check Publish Docker image GitHub repo size GitHub License

waveemapi3 is yet another WAV-to-MP3 API, but at least it's not an FFmpeg wrapper. (I wish it was at this point 😭😭).

This service is intended for internal API-to-API communication with simple API authentication. It only really exists because LAME is licensed with the LGPL license.

Installation

Building from Source

git clone https://github.com/wsand02/waveemapi3.git
cd waveemapi3
cargo build --release

Create the data directory. Ensure the user running waveemapi has the correct permissions for the directory.

mkdir data

Copy waveemapi.toml.example into waveemapi.toml.

If your data folder is not in the same directory as Cargo.toml, or is called anything other than data, please declare it under data_path in the configuration file. Alternatively as an environment variable, see the environment variable section for more info.

Docker Compose

Copy docker-compose.yml.example into docker-compose.yml.

Edit the tokens and other environment variables to your liking.

Run Docker Compose:

docker-compose up -d

Verify the service is running:

docker-compose ps

API Routes

(GET) /api/status

Returns a simple JSON status response.

Example Response:

{
  "status": "Online"
}

(POST) /api/upload

Accepts a multipart form upload:

  • wav: The WAV file to convert.
  • Requires a bearer token, if authentication is enabled.

Example Request:

curl -X POST \
  -H "Authorization: Bearer your_token" \
  -F "wav=@path/to/file.wav" \
  http://localhost:8000/api/upload

Returns a raw MP3 file, or a multitude of errors.

Configuration

waveemapi uses a configuration file named waveemapi.toml and supports environment variable overrides.

Note: waveemapi inherits all of Rocket's available settings.

waveemapi.toml

[default]
# Limits for form uploads
limits = { form = "1 GiB", data-form = "1 GB", file = "500 MB" }

# API authentication tokens. Add tokens to enable bearer token authentication.
auth_tokens = [
  "your_secret_token"
]

# Enable or disable authentication. Set to `false` to bypass authentication.
auth_enabled = true

Environment Variables

You can override the configuration using environment variables. The following variables are supported:

  • WAVEEMAPI_DATA_PATH: Path to the directory where data files are stored.
  • WAVEEMAPI_AUTH_ENABLED: Set to true or false to enable or disable authentication.
  • WAVEEMAPI_PROFILE: Specify the configuration profile to use (e.g., default).
  • WAVEEMAPI_AUTH_TOKENS: A list of API tokens.

Example:

export WAVEEMAPI_DATA_PATH="/path/to/data"
export WAVEEMAPI_AUTH_ENABLED=true

License

As stated earlier, this project is licensed under the LGPL license, see LICENSE.

About

yet another wav to mp3 api

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •