Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Virtual environments
.venv/
venv/
ENV/
env/

# Environment variables
.env
.env.local

# Database files
*.db
*.sqlite
*.sqlite3

# IDE files
.vscode/
.idea/
*.swp
*.swo
*~

# Testing
.pytest_cache/
.coverage
htmlcov/

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg

# Logs
*.log
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# LifeLine-ICT

![CI](https://github.com/buayism/LifeLine-ICT/actions/workflows/ci.yml/badge.svg)

## Project Summary

LifeLine-ICT is a digital infrastructure management platform that supports the
Expand Down
18 changes: 17 additions & 1 deletion backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from .core.config import settings
from .core.logging import configure_logging
Expand Down Expand Up @@ -56,6 +57,15 @@ def create_app() -> FastAPI:

errors.register_exception_handlers(app)

# Configure CORS for frontend integration
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

app.include_router(projects_router)
app.include_router(resources_router)
app.include_router(locations_router)
Expand All @@ -65,7 +75,13 @@ def create_app() -> FastAPI:
app.include_router(alert_router)
app.include_router(auth_router)

@app.get("/health", tags=["health"])
@app.get("/", tags=["root"])
async def root_redirect():
"""Redirect root URL to API documentation."""
from fastapi.responses import RedirectResponse
return RedirectResponse(url="/docs")

@app.get("/api/v1/health", tags=["health"])
async def healthcheck() -> dict[str, str]:
"""
Provide a basic health indicator confirming application availability.
Expand Down
17 changes: 17 additions & 0 deletions backend/tests/api/test_health.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""Tests for the health check endpoint."""

from fastapi.testclient import TestClient


def test_health_check_returns_ok(client: TestClient) -> None:
"""Health endpoint should return status ok."""
response = client.get("/api/v1/health")
assert response.status_code == 200
assert response.json() == {"status": "ok"}


def test_root_redirects_to_docs(client: TestClient) -> None:
"""Root URL should redirect to API documentation."""
response = client.get("/", follow_redirects=False)
assert response.status_code == 307
assert response.headers["location"] == "/docs"
Loading