This repository contains the code for api.mediamod.dev.
This API allows MediaMod users to publish themes, login to Spotify via the Authorization Code Flow, and more.
We encourage users to contribute to the API, and host it themselves if they want to. Read the MediaMod Wiki for instructions on how to use a custom API host instead of the default.
-
Create another directory for your container (i.e.
/data/containers/api.mediamod.dev
will be used in our example) -
Copy
docker-compose.yml
andDockerfile.migration
to this new directory -
Create a
.env
file/data/containers/api.mediamod.dev/.env
# The SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET can be found on the Spotify Developer Dashboard SPOTIFY_CLIENT_ID=... SPOTIFY_CLIENT_SECRET=... SPOTIFY_REDIRECT_URI=http://localhost:9103/callback PORT=3001 DATABASE_URL=postgresql://user:password@ip:port/db_name
-
Run the migration container to initialize the database
Note: you should also do this whenever the DB schema changes
$ docker-compose run migration
-
Start the containers and the API should be accessible on your port!
$ docker-compose up -d
-
Install dependencies
$ yarn
-
Ensure that you have postgresql installed and setup correctly on your system (i.e. user created, etc)
-
Create a
.env
file.env
# The SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET can be found on the Spotify Developer Dashboard SPOTIFY_CLIENT_ID=... SPOTIFY_CLIENT_SECRET=... SPOTIFY_REDIRECT_URI=http://localhost:9103/callback PORT=3001 DATABASE_URL=postgresql://user:password@ip:port/db_name
-
Start the API, it should now be accessible on the port specified in your
.env
file$ yarn start