init commit. Skeleton prepared
This commit is contained in:
0
services/match/src/app/__init__.py
Normal file
0
services/match/src/app/__init__.py
Normal file
0
services/match/src/app/api/__init__.py
Normal file
0
services/match/src/app/api/__init__.py
Normal file
0
services/match/src/app/api/routes/__init__.py
Normal file
0
services/match/src/app/api/routes/__init__.py
Normal file
7
services/match/src/app/api/routes/ping.py
Normal file
7
services/match/src/app/api/routes/ping.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/ping")
|
||||
def ping():
|
||||
return {"ping": "pong"}
|
||||
0
services/match/src/app/core/__init__.py
Normal file
0
services/match/src/app/core/__init__.py
Normal file
9
services/match/src/app/core/config.py
Normal file
9
services/match/src/app/core/config.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
class Settings(BaseSettings):
|
||||
database_url: str | None = None
|
||||
|
||||
class Config:
|
||||
env_prefix = ""
|
||||
env_file = ".env"
|
||||
case_sensitive = False
|
||||
0
services/match/src/app/db/__init__.py
Normal file
0
services/match/src/app/db/__init__.py
Normal file
26
services/match/src/app/db/session.py
Normal file
26
services/match/src/app/db/session.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import os
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker, DeclarativeBase
|
||||
from typing import Generator
|
||||
|
||||
DEFAULT_DB_URL = "postgresql+psycopg2://postgres:postgres@postgres:5432/match_db"
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
pass
|
||||
|
||||
DATABASE_URL = os.getenv("DATABASE_URL", DEFAULT_DB_URL)
|
||||
|
||||
engine = create_engine(
|
||||
DATABASE_URL,
|
||||
pool_pre_ping=True,
|
||||
future=True,
|
||||
)
|
||||
|
||||
SessionLocal = sessionmaker(bind=engine, autoflush=False, autocommit=False)
|
||||
|
||||
def get_db() -> Generator:
|
||||
db = SessionLocal()
|
||||
try:
|
||||
yield db
|
||||
finally:
|
||||
db.close()
|
||||
11
services/match/src/app/main.py
Normal file
11
services/match/src/app/main.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from fastapi import FastAPI
|
||||
from .api.routes.ping import router as ping_router
|
||||
|
||||
app = FastAPI(title="MATCH Service")
|
||||
|
||||
@app.get("/health")
|
||||
def health():
|
||||
return {"status": "ok", "service": "match"}
|
||||
|
||||
# v1 API
|
||||
app.include_router(ping_router, prefix="/v1")
|
||||
0
services/match/src/app/models/__init__.py
Normal file
0
services/match/src/app/models/__init__.py
Normal file
1
services/match/src/app/models/base.py
Normal file
1
services/match/src/app/models/base.py
Normal file
@@ -0,0 +1 @@
|
||||
from app.db.session import Base # re-export for convenience
|
||||
0
services/match/src/app/repositories/__init__.py
Normal file
0
services/match/src/app/repositories/__init__.py
Normal file
5
services/match/src/app/repositories/base.py
Normal file
5
services/match/src/app/repositories/base.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
class BaseRepository:
|
||||
def __init__(self, db: Session):
|
||||
self.db = db
|
||||
0
services/match/src/app/schemas/__init__.py
Normal file
0
services/match/src/app/schemas/__init__.py
Normal file
4
services/match/src/app/schemas/common.py
Normal file
4
services/match/src/app/schemas/common.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
class Message(BaseModel):
|
||||
message: str
|
||||
0
services/match/src/app/services/__init__.py
Normal file
0
services/match/src/app/services/__init__.py
Normal file
5
services/match/src/app/services/base.py
Normal file
5
services/match/src/app/services/base.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
class BaseService:
|
||||
def __init__(self, db: Session):
|
||||
self.db = db
|
||||
Reference in New Issue
Block a user