feat: Initialize frontend and backend structure with essential configurations
Some checks failed
Backend CI / lint-and-test (push) Failing after 2m15s
Frontend CI / lint-and-build (push) Successful in 1m1s

- Added TypeScript build info for frontend.
- Created Vite configuration for React application.
- Implemented pre-commit hook to run checks before commits.
- Set up PostgreSQL Dockerfile with PostGIS support and initialization scripts.
- Added database creation script for PostgreSQL with necessary extensions.
- Established Python project configuration with dependencies and development tools.
- Developed pre-commit script to enforce code quality checks for backend and frontend.
- Created PowerShell script to set up Git hooks path.
This commit is contained in:
2025-10-11 15:25:32 +02:00
commit fc1e874309
74 changed files with 9477 additions and 0 deletions

View File

View File

@@ -0,0 +1,38 @@
from functools import lru_cache
from pydantic_settings import BaseSettings, SettingsConfigDict
from typing import Optional
class Settings(BaseSettings):
project_name: str = "Rail Game API"
version: str = "0.1.0"
api_prefix: str = "/api"
jwt_secret_key: str = "insecure-change-me"
jwt_algorithm: str = "HS256"
access_token_expire_minutes: int = 60
database_url: str = "postgresql+psycopg://railgame:railgame@localhost:5432/railgame"
database_echo: bool = False
test_database_url: Optional[str] = None
alembic_database_url: Optional[str] = None
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8")
@property
def sqlalchemy_database_url(self) -> str:
return self.database_url
@property
def sqlalchemy_test_url(self) -> Optional[str]:
return self.test_database_url
@property
def sqlalchemy_alembic_url(self) -> str:
return self.alembic_database_url or self.database_url
@lru_cache()
def get_settings() -> Settings:
return Settings()

View File

@@ -0,0 +1,36 @@
from __future__ import annotations
from datetime import datetime, timedelta, timezone
from typing import Any, Dict
from jose import JWTError, jwt
from passlib.context import CryptContext
from backend.app.core.config import get_settings
pwd_context = CryptContext(schemes=["pbkdf2_sha256"], deprecated="auto")
def verify_password(plain_password: str, hashed_password: str) -> bool:
return pwd_context.verify(plain_password, hashed_password)
def get_password_hash(password: str) -> str:
return pwd_context.hash(password)
def create_access_token(subject: str, expires_delta: timedelta | None = None) -> str:
settings = get_settings()
expire = datetime.now(timezone.utc) + (
expires_delta or timedelta(minutes=settings.access_token_expire_minutes)
)
to_encode: Dict[str, Any] = {"sub": subject, "exp": expire}
return jwt.encode(to_encode, settings.jwt_secret_key, algorithm=settings.jwt_algorithm)
def decode_access_token(token: str) -> Dict[str, Any]:
settings = get_settings()
try:
return jwt.decode(token, settings.jwt_secret_key, algorithms=[settings.jwt_algorithm])
except JWTError as exc: # pragma: no cover - specific error mapping handled by caller
raise ValueError("Invalid token") from exc