32 lines
737 B
Python
32 lines
737 B
Python
from dataclasses import dataclass
|
|
from db import init_db
|
|
from fastapi import FastAPI, Header
|
|
import os
|
|
from routers import imp_routers
|
|
from system.auth import AuthRepo
|
|
|
|
tam_env = os.getenv("TAM_ENV", "prod")
|
|
|
|
@dataclass
|
|
class MainRoute:
|
|
whoami: str = "TAM Server"
|
|
authenticated: bool = False
|
|
healthy: bool = True
|
|
|
|
init_db()
|
|
|
|
app = FastAPI(
|
|
title="TAM Server",
|
|
description="Server for Ticket Auction Manager",
|
|
version="0.0.1",
|
|
docs_url=None if tam_env == "prod" else "/docs",
|
|
redoc_url=None,
|
|
openapi_url=None if tam_env == "prod" else "/openapi.json"
|
|
)
|
|
|
|
@app.get("/api")
|
|
def get_main_route(tam_key: str = Header("")):
|
|
return MainRoute(authenticated=AuthRepo().check_key(tam_key))
|
|
|
|
imp_routers(app)
|