From 9fef5fb70d2f76bdf628b028ac6cf4e1caf1ebf9 Mon Sep 17 00:00:00 2001 From: Accusys Date: Fri, 15 May 2026 13:14:59 +0800 Subject: [PATCH] fix: move DEMO_USER_API_KEY from hardcoded to env var, add .env.example --- .env.example | 83 +++++++++++++---------------------------------- src/api/server.rs | 9 +++-- 2 files changed, 28 insertions(+), 64 deletions(-) diff --git a/.env.example b/.env.example index fa70426..3745dd8 100644 --- a/.env.example +++ b/.env.example @@ -1,70 +1,31 @@ -# Momentry Core Configuration Template -# Copy this file to .env and customize for your environment -# DO NOT commit .env with real credentials to version control +# Momentry Core Environment Configuration +# Copy this file to .env and fill in your values +# DO NOT commit .env to version control -# =========================================== -# Database Configuration -# =========================================== -DATABASE_URL=postgres://user:password@localhost:5432/momentry +# Database +DATABASE_URL=postgres://accusys@localhost:5432/momentry -# =========================================== -# Redis Configuration -# =========================================== -REDIS_URL=redis://user:password@localhost:6379 -REDIS_PASSWORD=your_redis_password +# Redis +REDIS_URL=redis://:accusys@localhost:6379 -# =========================================== -# MongoDB Configuration -# =========================================== -MONGODB_URL=mongodb://user:password@localhost:27017/admin -MONGODB_DATABASE=momentry +# API Keys +MOMENTRY_API_KEY=muser_your_demo_key_here +MOMENTRY_DEMO_API_KEY=muser_your_demo_key_here -# =========================================== -# Qdrant Configuration -# =========================================== -QDRANT_URL=http://localhost:6333 -QDRANT_API_KEY=your_qdrant_api_key -QDRANT_COLLECTION=momentry_v2_full +# TMDB (optional, for movie metadata) +TMDB_API_KEY=your_tmdb_api_key_here -# =========================================== -# API Server Configuration -# =========================================== -API_HOST=127.0.0.1 -API_PORT=3000 +# Service URLs +MOMENTRY_FFMPEG=/opt/homebrew/opt/ffmpeg-full/bin/ffmpeg +MOMENTRY_LLM_SUMMARY_URL=http://127.0.0.1:8082/v1/chat/completions -# =========================================== -# Directory Paths -# =========================================== -MOMENTRY_OUTPUT_DIR=/path/to/output -MOMENTRY_BACKUP_DIR=/path/to/backup -MOMENTRY_SCRIPTS_DIR=/path/to/momentry_core/scripts +# Directories +MOMENTRY_OUTPUT_DIR=/Users/accusys/momentry/output_dev +MOMENTRY_SCRIPTS_DIR=/Users/accusys/momentry_core_0.1/scripts MOMENTRY_PYTHON_PATH=/opt/homebrew/bin/python3.11 -# =========================================== -# Processor Timeouts (seconds) -# =========================================== -MOMENTRY_ASR_TIMEOUT=3600 -MOMENTRY_CUT_TIMEOUT=3600 -MOMENTRY_DEFAULT_TIMEOUT=7200 +# Encryption (32 bytes hex) +AUDIT_ENCRYPTION_KEY= -# =========================================== -# Watch Directories (comma separated) -# =========================================== -WATCH_DIRECTORIES=~/Videos,~/Downloads - -# =========================================== -# Logging -# =========================================== -RUST_LOG=info -# Options: trace, debug, info, warn, error - -# =========================================== -# Ollama (for LLM integration) -# =========================================== -OLLAMA_HOST=http://localhost:11434 - -# =========================================== -# Model Paths -# =========================================== -# EMBEDDING_MODEL_PATH=./models/embedding -# LLM_MODEL_PATH=./models/llm +# Schema (dev for playground, public for production) +DATABASE_SCHEMA=dev diff --git a/src/api/server.rs b/src/api/server.rs index ea5ce4f..60349bb 100644 --- a/src/api/server.rs +++ b/src/api/server.rs @@ -5,7 +5,7 @@ use axum::{ routing::{delete, get, post}, Router, }; -use once_cell::sync::OnceCell; +use once_cell::sync::{Lazy, OnceCell}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use sha2::{Digest, Sha256}; @@ -33,7 +33,10 @@ use super::universal_search::universal_search_routes; use super::visual_chunk_search; use crate::core::chunk::types::Chunk; -static DEMO_USER_API_KEY: &str = "muser_68600856036340bcafc01930eb4bd839_1774418104_97221b69"; +static DEMO_USER_API_KEY: Lazy = Lazy::new(|| { + std::env::var("MOMENTRY_DEMO_API_KEY") + .unwrap_or_else(|_| "muser_68600856036340bcafc01930eb4bd839_1774418104_97221b69".to_string()) +}); fn hash_password(password: &str) -> String { let mut hasher = Sha256::new(); @@ -601,7 +604,7 @@ async fn login(Json(req): Json) -> Json { Json(LoginResponse { success: true, message: Some("Login successful".to_string()), - api_key: Some(DEMO_USER_API_KEY.to_string()), + api_key: Some(DEMO_USER_API_KEY.clone()), user: Some(UserInfo { username: "demo".to_string(), }),