Some checks failed
Deploy to Production / deploy (push) Failing after 0s
- Complete dark-theme redesign inspired by ai-impress.com (navy + cyan + violet palette) - New Syne display font + gradient logo mark + SVG favicon - New Navigation: glass-morphism, gradient logo, Get Started CTA - New Hero: animated glow orbs, mock focus-group chat UI, stats row - New landing: Features grid, How-It-Works steps, CTA banner - New Footer: AImpress LTD branding, © AImpress LTD. All rights reserved. - New Login page: dark card, password visibility toggle, link to Register - New Register page: full form, benefits row, 50 free credits pitch - New VerifyEmail page: token verification flow with auto-redirect - Backend: email_service.py using Resend API for verification emails - Backend: /api/auth/register, /verify-email, /resend-verification endpoints - User model: email_verified, email_verify_token, email_verify_expires fields - Gitea Actions CI/CD: auto-deploy to aimpress server on push to main Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
55 lines
1.3 KiB
Python
55 lines
1.3 KiB
Python
"""
|
|
App-wide configuration stored in MongoDB.
|
|
Single document with _id='config'. Cached in-memory for 60 seconds.
|
|
"""
|
|
|
|
import time
|
|
import logging
|
|
from typing import Any
|
|
from app.db import get_db
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
_cache: dict[str, Any] = {}
|
|
_cache_ts: float = 0
|
|
_CACHE_TTL = 60 # seconds
|
|
|
|
DEFAULTS = {
|
|
"_id": "config",
|
|
"persona_cost": 2,
|
|
"run_cost": 40,
|
|
"trial_grant": 10,
|
|
"credit_packs": [
|
|
{"id": "starter", "name": "Starter", "price_usd": 49, "credits": 50},
|
|
{"id": "pro", "name": "Pro", "price_usd": 199, "credits": 220},
|
|
{"id": "scale", "name": "Scale", "price_usd": 499, "credits": 600},
|
|
],
|
|
}
|
|
|
|
|
|
async def get_settings() -> dict:
|
|
global _cache, _cache_ts
|
|
if _cache and (time.monotonic() - _cache_ts) < _CACHE_TTL:
|
|
return _cache
|
|
|
|
db = await get_db()
|
|
doc = await db.app_settings.find_one({"_id": "config"})
|
|
if not doc:
|
|
await db.app_settings.insert_one(DEFAULTS.copy())
|
|
doc = DEFAULTS.copy()
|
|
|
|
_cache = doc
|
|
_cache_ts = time.monotonic()
|
|
return doc
|
|
|
|
|
|
async def update_settings(fields: dict) -> dict:
|
|
global _cache, _cache_ts
|
|
db = await get_db()
|
|
await db.app_settings.update_one(
|
|
{"_id": "config"},
|
|
{"$set": fields},
|
|
upsert=True,
|
|
)
|
|
_cache = {} # invalidate cache
|
|
return await get_settings()
|