Files

1.7 KiB

decent-offchain

API to access DAO information, proposals, comments, temperature checks, and SIWE authentication.

Prerequisites

  • Install bun

    curl -fsSL https://bun.sh/install | bash
    
  • Install PostgreSQL

Setup

Database

[macOS] Start the database

brew services start postgresql@16

Configure postgresql in PATH (if you are using zsh shell)

echo 'export PATH="/opt/homebrew/opt/postgresql@16/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Create a database

createdb decent

The API depends on data from decent-ponder. In order to speed up development, seed the database from the backup file in decent-data repo release. Download the file and save it to packages/decent-offchain/database/db.sql.

Restore the database from the backup file

bash scripts/database/restore.sh

OPTIONAL: See decent-ponder to run it locally. Not required to run the API if you use the restored database.

Environment Variables

Add your RPC URLs and database URL to .env. Leave DATABASE_URL blank to use the local database.

cp example.env .env

Install Dependencies

bun install

Running

bun run dev

API

see live API docs

Websocket

Local testing: Connect to ws://localhost:81/ws