Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
.DS_Store
.venv/
__pycache__/
*.pyc
.env
node_modules/
24 changes: 24 additions & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"dotenv": "^17.2.3"
}
}
40 changes: 32 additions & 8 deletions db/create-schema.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,38 @@
#!/bin/bash

set -euo pipefail

# Get the directory of this script
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"

source "$SCRIPT_DIR/../backend/.env"
# Load environment variables from backend/.env
if [ -f "$SCRIPT_DIR/../backend/.env" ]; then
source "$SCRIPT_DIR/../backend/.env"
else
echo "❌ .env file not found in backend/"
exit 1
fi

# Function to run psql (local or Docker)
run_psql() {
if [[ "${POSTGRES_HOST:-127.0.0.1}" == "localhost" ]] || [[ "${POSTGRES_HOST:-127.0.0.1}" == "127.0.0.1" ]]; then
# Use local psql
echo "Using local psql..."
PGPASSWORD="$POSTGRES_PASSWORD" psql \
--dbname "${POSTGRES_DB:-postgres}" \
--file "${SCRIPT_DIR}/schema.sql" \
--host "${POSTGRES_HOST:-127.0.0.1}" \
--port "${POSTGRES_PORT:-5432}" \
--username "${POSTGRES_USER:-postgres}"
else
# Assume POSTGRES_HOST is a Docker container name
echo "Using Docker container '${POSTGRES_HOST}'..."
docker exec -i "$POSTGRES_HOST" psql \
-U "${POSTGRES_USER:-postgres}" \
-d "${POSTGRES_DB:-postgres}" < "${SCRIPT_DIR}/schema.sql"
fi
}

# Run it
run_psql

PGPASSWORD="$POSTGRES_PASSWORD" psql \
--dbname "${POSTGRES_DB:-postgres}" \
--file "${SCRIPT_DIR}/schema.sql" \
--host "${POSTGRES_HOST:-127.0.0.1}" \
--port "${POSTGRES_PORT:-5432}" \
--username "${POSTGRES_USER:-postgres}"
echo "✅ Schema applied successfully!"
1 change: 1 addition & 0 deletions front-end/lib/api.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ async function signup(username, password) {

function logout() {
state.destroyState();
window.location.href = "index.html"; // Added a redirect to home page after logout
return {success: true};
}

Expand Down