Add dotenv

This commit is contained in:
Jon Staab
2026-02-25 15:16:48 -08:00
parent 9bc6c42aee
commit de4a16adbf
11 changed files with 3790 additions and 7 deletions
+2
View File
@@ -1,3 +1,5 @@
ref
node_modules
target
.env
**/.env
+3 -3
View File
@@ -1,4 +1,4 @@
# Nostr Community Relay Hosting Platform
# Caravel
A multi-tenant platform for hosting Nostr community relays, built on top of [zooid](./ref/zooid) — a multi-tenant relay implementation configured via TOML and an HTTP API.
@@ -121,7 +121,7 @@ When a relay is created, an async worker is spawned that sends the appropriate A
### Environment Variables
| Variable | Description |
|---|---|
| `HOSTING_ADMIN_PUBKEYS` | Comma-separated Nostr pubkeys with super admin access |
| `PLATFORM_ADMIN_PUBKEYS` | Comma-separated Nostr pubkeys with super admin access |
| `PLATFORM_SECRET` | Nostr private key used by the platform to send NIP-17 DMs |
| `NWC_URL` | Nostr Wallet Connect URL used by the platform to generate Lightning invoices |
| `NOSTR_INDEXER_RELAYS` | Relays used to fetch kind `10050` DM relay lists |
@@ -174,7 +174,7 @@ When a relay is created, an async worker is spawned that sends the appropriate A
- Toggle for recurring billing via Nostr Wallet Connect (tenant provides their own NWC URL)
### Super Admin Dashboard (`/admin`)
- Authenticated via NIP-98 against `HOSTING_ADMIN_PUBKEYS`
- Authenticated via NIP-98 against `PLATFORM_ADMIN_PUBKEYS`
- No link to this page from any other page
#### Tenants Page (`/admin/tenants`)
+26
View File
@@ -0,0 +1,26 @@
# Server
HOST=127.0.0.1
PORT=3000
# Database
DATABASE_URL=sqlite://data/caravel.db
# Nostr
PLATFORM_ADMIN_PUBKEYS= # Comma-separated hex pubkeys with super admin access
PLATFORM_SECRET= # Nostr private key (hex) used to send NIP-17 DMs and sign events
# Zooid
ZOOID_API_URL=http://127.0.0.1:8032
RELAY_DOMAIN=spaces.coracle.social
# Billing
NWC_URL= # Nostr Wallet Connect URL for generating Lightning invoices
# Indexer
NOSTR_INDEXER_RELAYS=wss://purplepag.es/,wss://relay.damus.io/,wss://relay.nostr.band/
# Platform identity (published as kind 0)
PLATFORM_NAME=
PLATFORM_DESCRIPTION=
PLATFORM_PICTURE=
PLATFORM_MESSAGING_RELAYS= # Comma-separated relay URLs published in kind 10050
+3740
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -19,3 +19,4 @@ tower-http = { version = "0.5", features = ["cors"] }
reqwest = { version = "0.12", features = ["json", "rustls-tls"] }
rand = "0.8"
hex = "0.4"
dotenvy = "0.15.7"
+2 -2
View File
@@ -33,7 +33,7 @@ Environment variables:
| Variable | Description | Default |
|---|---|---|
| `DATABASE_URL` | SQLite database URL | `sqlite://data/hosting.db` |
| `DATABASE_URL` | SQLite database URL | `sqlite://data/caravel.db` |
| `HOST` | Bind host | `127.0.0.1` |
| `PORT` | Bind port | `3000` |
| `ZOOID_API_URL` | Zooid API base URL | `http://127.0.0.1:8032` |
@@ -116,7 +116,7 @@ Tenant routes (all require NIP-98 auth; pubkey is inferred from the token):
- `GET /tenant/invoices` — list invoices
- `PUT /tenant/billing` — update tenant billing (NWC URL)
Admin routes (all require NIP-98 auth; pubkey must be in `HOSTING_ADMIN_PUBKEYS`):
Admin routes (all require NIP-98 auth; pubkey must be in `PLATFORM_ADMIN_PUBKEYS`):
- `GET /admin/tenants` — list tenants
- `GET /admin/tenants/:pubkey` — tenant detail (includes relays)
+2 -2
View File
@@ -20,13 +20,13 @@ pub struct Config {
impl Config {
pub fn from_env() -> Self {
let database_url =
env::var("DATABASE_URL").unwrap_or_else(|_| "sqlite://data/hosting.db".to_string());
env::var("DATABASE_URL").unwrap_or_else(|_| "sqlite://data/caravel.db".to_string());
let host = env::var("HOST").unwrap_or_else(|_| "127.0.0.1".to_string());
let port = env::var("PORT")
.ok()
.and_then(|v| v.parse().ok())
.unwrap_or(3000);
let admin_pubkeys = env::var("HOSTING_ADMIN_PUBKEYS")
let admin_pubkeys = env::var("PLATFORM_ADMIN_PUBKEYS")
.unwrap_or_default()
.split(',')
.map(|v| v.trim().to_string())
+2
View File
@@ -27,6 +27,8 @@ use crate::repo::Repo;
#[tokio::main]
async fn main() -> Result<()> {
dotenvy::dotenv().ok();
tracing_subscriber::registry()
.with(tracing_subscriber::EnvFilter::from_default_env())
.with(tracing_subscriber::fmt::layer())
+2
View File
@@ -0,0 +1,2 @@
# Backend API base URL
VITE_API_URL=http://127.0.0.1:3000
+8
View File
@@ -6,4 +6,12 @@ declare global {
}
}
interface ImportMetaEnv {
readonly VITE_API_URL: string
}
interface ImportMeta {
readonly env: ImportMetaEnv
}
export {}
+2
View File
@@ -2,6 +2,8 @@ import { EventStore } from "applesauce-core"
import { RelayPool } from "applesauce-relay"
import { AccountManager } from "applesauce-accounts"
export const API_URL = import.meta.env.VITE_API_URL
export const eventStore = new EventStore()
export const pool = new RelayPool()
export const accounts = new AccountManager()