mirror of
https://github.com/OHV-IT/collabrix.git
synced 2025-12-15 16:48:36 +01:00
- Complete chat application similar to Microsoft Teams - Code snippet library with syntax highlighting - Real-time messaging with WebSockets - File upload with Office integration - Department-based permissions - Dark/Light theme support - Production deployment with SSL/Reverse Proxy - Docker containerization - PostgreSQL database with SQLModel ORM
73 lines
1.9 KiB
Python
73 lines
1.9 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.staticfiles import StaticFiles
|
|
from pathlib import Path
|
|
from app.database import create_db_and_tables
|
|
from app.config import get_settings
|
|
from app.routers import auth, departments, channels, messages, files, websocket, snippets, admin, direct_messages
|
|
|
|
settings = get_settings()
|
|
|
|
app = FastAPI(
|
|
title="Team Chat API",
|
|
description="Internal chat application similar to Microsoft Teams",
|
|
version="1.0.0"
|
|
)
|
|
|
|
# CORS middleware
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=[
|
|
settings.frontend_url,
|
|
"http://localhost:5173",
|
|
"http://localhost:3000",
|
|
"https://collabrix.apex-project.de",
|
|
"http://collabrix.apex-project.de"
|
|
],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Mount uploads directory as static files
|
|
# Get the directory where this file is located
|
|
current_dir = Path(__file__).parent.parent
|
|
uploads_dir = current_dir / "uploads"
|
|
uploads_dir.mkdir(exist_ok=True)
|
|
app.mount("/uploads", StaticFiles(directory=str(uploads_dir)), name="uploads")
|
|
|
|
|
|
# Event handlers
|
|
@app.on_event("startup")
|
|
def on_startup():
|
|
"""Create database tables on startup"""
|
|
create_db_and_tables()
|
|
|
|
|
|
# Include routers
|
|
app.include_router(auth.router)
|
|
app.include_router(admin.router)
|
|
app.include_router(departments.router)
|
|
app.include_router(channels.router)
|
|
app.include_router(messages.router)
|
|
app.include_router(direct_messages.router)
|
|
app.include_router(files.router)
|
|
app.include_router(snippets.router)
|
|
app.include_router(websocket.router)
|
|
|
|
|
|
@app.get("/")
|
|
def read_root():
|
|
"""Root endpoint"""
|
|
return {
|
|
"message": "Welcome to Team Chat API",
|
|
"docs": "/docs",
|
|
"version": "1.0.0"
|
|
}
|
|
|
|
|
|
@app.get("/health")
|
|
def health_check():
|
|
"""Health check endpoint"""
|
|
return {"status": "healthy"}
|