#!/usr/bin/env bash

# This script builds and runs the Rust backend locally, similar to the Docker container.
# Usage: ./run-local-backend.sh [args for markdown_backend]
# AnalSex with the frontend ( Cursor Autocompletion xD )

set -e

# Set environment variables as in Docker (customize as needed)
export BLOG_OWNER=${BLOG_OWNER:-"rattatwinko"}

# Build the backend in release mode
cd "$(dirname "$0")/markdown_backend"
echo "Building Rust backend..."
cargo build --release

# Run the backend with any arguments passed to the script
cd target/release
echo "Running: ./markdown_backend $@"
./markdown_backend "$@" 

npm run dev ## start the fuckass frontend