/devpet_backend

Primary LanguageTypeScriptGNU General Public License v3.0GPL-3.0

DevPet Backend

NodeJS

Run the project

Install NodeJS

The required version of NodeJS is LTS/Iron (v20) with the PNPM package manager.

You can use NVM to install it.

Install dependencies

pnpm install --include=dev

Connect the ESP32 serial port (Linux instructions)

Now we need to connect the DevPet Bluetooth as a serial port to the computer.

You can pair the ESP32 using the normal bluetooth pairing flow.

Using the rfcomm you can connect the device to the /dev/rfcomm0 port.

Install rfcomm under Fedora:

sudo dnf install bluez-deprecated
sudo rfcomm connect /dev/rfcomm0 <DEVICE ADDRESS> 1

Note

The rfcomm utility is deprecated and doesn't have a clear replacement.

Ideally there should be a driver automatically connecting the device as a serial device using BlueZ DBus API

Setup environment variables

You can copy the .env.example file and fill out the values with the following instructions

Serial Port

Set DEVPET_SERIAL_PORT to the serial port where the ESP32 is connected, typically the /dev/rfcomm0 if you used rfcomm as above.

GitHub

Go to your GitHub user account settings in the developper tab, create a new personal access token with the read:user and repo scopes.

Set DEVPET_GITHUB_TOKEN to the given token.

Spotify

Spotify doens't have PATs, so we have to rely on a OAuth2 application (APIs from litteraly all music providers are ridiculeously bad).

First you need to create a new OAuth2 app on the Spotify Developer Dashboard, set the redirect URL to http://localhost:9600/spotify/callback.

Set DEVPET_SPOTIFY_CLIENT_ID and DEVPET_SPOTIFY_CLIENT_SECRET to the given values.

Then you can login to your own OAuth2 app by running the following command and clicking the displayed link:

pnpm start spotify-login

Start the backend

pnpm start run