Skip to content

Oliboy50/blindtester

Repository files navigation

blindtester

Send a video URL (e.g. YouTube) => Get a blindtest

CircleCI

User documentation

Install

Local

  1. cp docker-compose.dev.yaml docker-compose.override.yaml
  2. Edit docker-compose.override.yaml file to setup your environment variables
  3. docker-compose up
  4. Go to http://localhost:3030 to make sure blindtester is up and running

Heroku

  1. Create a new app with a pipeline on heroku (e.g. MY_APP)
  2. heroku login
  3. heroku stack:set container --app MY_APP
  4. heroku git:remote --app MY_APP
  5. git push heroku master
  6. Go to https://dashboard.heroku.com/apps/MY_APP/settings to setup your environment variables
  7. Go to https://MY_APP.herokuapp.com to make sure blindtester is up and running

Usage

GET /save?url=YOUR_VIDEO_URL

Produce a new blind test using the url query param, then redirect to the blind test.

GET /stream/BLIND_TEST_ID

Listen to the given blind test id.

Configuration

Configuration is done using environment variables (some good defaults can be found in docker-compose.dev.yaml) which are listed below:

Variable Description
PORT Port on which the web server will listen (default value is 3030)
API_BASE_URL Your blindtester installation base URL used to programmatically build links (example: http://localhost:3030)
ENDPOINT_SAVE_ENABLED If equals to true, the API will expose the save endpoint
ENDPOINT_STREAM_ENABLED If equals to true, the API will expose the stream endpoint
ENDPOINT_SLACK_ENABLED If equals to true, the API will expose special endpoints to be compatible with Slack.
VALIDATE_MAX_FILE_DURATION_IN_SECONDS If set, blindtester will make sure the file duration is less than this limit before downloading it.
DATABASE_TYPE Database type. Could be one of json (will store application data in a JSON object).
DATABASE_JSON_TYPE Used if DATABASE_TYPE is json. Could be one of filesystem
DATABASE_JSON_FILESYSTEM_PATH Used if DATABASE_JSON_TYPE is filesystem. Path to a readable/writable file which will be created (if it does not already exist) and used as database.
DATABASE_JSON_BACKBLAZEB2_KEY_ID Used if DATABASE_JSON_TYPE is backblazeb2. Backblaze B2 key ID used to access the bucket containing the database. More information: b2_authorize_account
DATABASE_JSON_BACKBLAZEB2_APPLICATION_KEY Used if DATABASE_JSON_TYPE is backblazeb2. Backblaze B2 application key used to access the bucket containing the database. More information: b2_authorize_account
DATABASE_JSON_BACKBLAZEB2_BUCKET_ID Used if DATABASE_JSON_TYPE is backblazeb2. Backblaze B2 bucket ID where database will be stored. More information: b2_update_bucket
DATABASE_JSON_BACKBLAZEB2_BUCKET_NAME Used if DATABASE_JSON_TYPE is backblazeb2. Backblaze B2 bucket name where database will be stored. More information: b2_download_file_by_name
DATABASE_JSON_BACKBLAZEB2_FILE_NAME Used if DATABASE_JSON_TYPE is backblazeb2. Name of the file containing the JSON database in the bucket. More information: b2_download_file_by_name
FILES_STORAGE_TYPE Files storage type. Could be one of filesystem, backblazeb2
FILES_STORAGE_FILESYSTEM_PATH Path to a readable/writable directory which will be created (if it does not already exist) and used to store extracted audio files
FILES_STORAGE_BACKBLAZEB2_KEY_ID Used if FILES_STORAGE_TYPE is backblazeb2. Backblaze B2 key ID used to access the bucket containing the audio files. More information: b2_authorize_account
FILES_STORAGE_BACKBLAZEB2_APPLICATION_KEY Used if FILES_STORAGE_TYPE is backblazeb2. Backblaze B2 application key used to access the bucket containing the audio files. More information: b2_authorize_account
FILES_STORAGE_BACKBLAZEB2_BUCKET_ID Used if FILES_STORAGE_TYPE is backblazeb2. Backblaze B2 bucket ID where audio files will be stored. More information: b2_update_bucket
SLACK_CLIENT_ID Used if ENDPOINT_SLACK_ENABLED is true. Your Slack application "Client ID".
SLACK_CLIENT_SECRET Used if ENDPOINT_SLACK_ENABLED is true. Your Slack application "Client Secret".
SLACK_VERIFICATION_TOKEN Used if ENDPOINT_SLACK_ENABLED is true. If defined, this value must match your Slack application "Verification Token" to make sure incoming requests come from your Slack application. More information: Slack verification token
SLACK_SLACK_BUTTON_STATE Used if ENDPOINT_SLACK_ENABLED is true. If defined, this value must be the same as the state query param used in the request used to distribute your Slack application in a Slack workspace (e.g. https://slack.com/oauth/authorize?client_id=YOUR_SLACK_CLIENT_ID&scope=commands&state=YOUR_SLACK_SLACK_BUTTON_STATE). More information: Slack button

Third party integrations

Slack

In order to be easily used in Slack, blindtester provides special endpoints.

Here's how to create a blindtester Slack application:

  1. Configure ENDPOINT_SLACK_ENABLED blindtester variable to expose Slack endpoints
  2. Create a Slack App from your workspace
  3. Create a Slash Command for your app where Request URL will point to the API_BASE_URL/slack-command endpoint of your blindtester installation and Escape channels, users, and links sent to your app will be checked
  4. Install App to your workspace

If you want to distribute your application to other workspaces:

  1. Configure SLACK_CLIENT_ID and SLACK_CLIENT_SECRET blindtester variables using your Slack application credentials
  2. Add a Redirect URL which will point to the API_BASE_URL/slack-oauth-slack-button endpoint of your blindtester installation
  3. Activate Public Distribution
  4. Use your Add to Slack button to install the app to other workspaces

Developer documentation

Start hacking

cp docker-compose.dev.yaml docker-compose.override.yaml

# edit docker-compose.override.yaml file to setup your environment variables and uncomment the last lines of the file to run in "development" environment

# download "node_modules" locally for a better developer experience (smarter IDE, fix lint on commit, etc.)
cd api && npm install && cd -

docker-compose up

Lint

If you've run npm install locally (outside of the container running the app), you should already have the "fix lint on commit" feature available.

If you want to lint your code manually:

# while docker-compose is up

docker-compose exec api npm run lint:fix

Test

# while docker-compose is up

docker-compose exec api npm run test

License

GPLv3 - See LICENSE.md file.