Church of Rick central API
A central API server to distribute pixel placement tasks to the members of the Church of Rick™
Setting it up
To run your own development testing version of the API, follow these steps:
First, setup the environmental variables
- Make a
.env
file in the project's root directory to store your environmental variables - Make an application in discord developers portal
- Go to
OAuth2
section, and set your environmental variables forCLIENT_ID
andCLIENT_SECRET
accordingly to the Client Information in this section - Decide which URL should be used to access the API (if you're just testing, use
http://localhost:8000
), and set it asBASE_URL
env variable - Set URI (redirect URL) in the discord application to:
[BASE_URL]/oauth_callback
, so in our case:http://localhost:8000/oauth_callback
- Generate the OAuth2 URL with the
identify
scope. If you plan to use autojoin, you also need theguilds.join
scope. SetOAUTH_REDIRECT_URL
to the generated URL. - Set
JWT_SECRET
variable to some secret, this will be used to encode the JWT tokens, make sure it's secure enough - Set
PIXELS_API_TOKEN
variable, this will be the token you got from the official python-discord's webpage - You can also set
LOG_LEVEL
variable, to control the logging level that should be used, this defaults toINFO
, set it toDEBUG
if you need to - To enable automatic joining of users into your discord guild, create a bot user in
the same discord application you used for OAuth and invite it to the guild you want
to use. Next, set
ENABLE_DISCORD_AUTOJOIN
to1
,DISCORD_GUILD_ID
to the ID of the guild you want to use, andDISCORD_BOT_TOKEN
to the token of your discord bot. - Refer to
rickchurch/constants.py
for more information on how to configure the application.
Setup the running environment
You can use the docker-compose
which is more than sufficient for testing:
Note: this guide is meant for linux, if you're on windows, search how to run docker-compose there
- Install docker, specifically
docker-compose
. (I won't detail this, for Arch Linux it'spacman -S docker-compose
) - Go to the into the root of the repository. (
cd /path/to/rickchurch
) - Simply run
docker-compose up
(you might needsudo
) - The API is now running at
localhost:8000
, and if you need to access the postgresql database, it's atlocalhost:5000
If you need to run production server on bare-metal, you will have to setup PostgreSQL database on your own. (Guide for Arch Linux)
After you're done, set DATABASE_URL
env variable pointing to it (see example in docker-compose.yml).
You should be able to run the API now.