This API backend provides database storage using PostgreSQL and access to Discord API. It is currently used by the bot lizzyfuzzy and the website redmodding.org.
- bun v1.2+
- postgresql v17.5+
You must follow the instructions below if you wish to run and develop this project locally.
- Create a new GitHub App for local development:
- Name:
<whatever>
- Homepage URL:
http://localhost:4000
- Callback URL:
http://localhost:3000
- Webhook Active:
uncheck
- Where can this GitHub App be installed?
Only on this account
- Write down
App ID
somewhere. - Click on
generate a private key
in the notification. Generate a new private key and save the file insrc/token/github/[filename].pem
(create missing directories). - In the left panel, go to
Install App
. ClickInstall
for your account. After the application is installed, write down the last segment of the URL. It will be used as the GitHub installation ID.
Caution
DO NOT commit the private key file src/token/github/[filename].pem
.
- Go to https://discord.com/developers/applications/
- Create a
new application
- Define a name (e.g.
cp2077-lizzy-dev
) - Go to
Settings
>Bot
- Enable the following options under
Privileged Gateway Intents
:
- PRESENCE INTENT
- SERVER MEMBERS INTENT
- MESSAGE CONTENT INTENT
- Go to
Settings
>OAuth2
, underOAuth2 URL Generator
enable optionbot
. - Copy
GENERATED URL
at the bottom, open it with your browser. You'll be redirected to Discord application (or webapp), you can then allow/install the bot on a custom server of yours. - Click on
Reset Token
to generate a new token, and write it down.
In PostgreSQL, create a new user
with a password
. Create a new database
named redapi_dev
using the user created previously.
- Copy
.env_default
to.env
- Define the following fields with values previously generated:
postgresql://[user]:[password]@localhost:5432/redapi_dev?schema=public
GITHUB_APP_ID=[App ID]
GITHUB_APP_KEY_FILE=[filename].pem
GITHUB_INSTALLATION_ID=[last URL segment]
JWT_SECRET=[generate yourself/use dummy key]
DISCORD_TOKEN=[token]
![TIP]
.env
file is defined in.gitignore
.
- Clone this repository:
git clone https://github.com/WolvenKit/redapi.git
- Install dependencies:
bun install
- Run the project locally:
bun dev