Skip to content
Merged
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
10 changes: 5 additions & 5 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint and test
name: Check and test

env:
IMAGE_NAME: nbe95/apigator
Expand Down Expand Up @@ -41,8 +41,8 @@ jobs:
base-branch: true
with-v: false

lint:
name: Lint Python code
check:
name: Lint and check code
runs-on: ubuntu-latest
needs:
- validate-release
Expand All @@ -55,6 +55,6 @@ jobs:
- name: Install dependencies
run: |
pdm sync -d
- name: Run linters
- name: Run linter and type checker
run: |
pdm run lint
pdm run check
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
ARG PYTHON_BASE=3.11-slim


# Build stage for pdm modules
FROM python:$PYTHON_BASE AS builder

WORKDIR /app

RUN pip install -U pdm
ENV PDM_CHECK_UPDATE=false

COPY pyproject.toml pdm.lock README.md /app/
COPY src/ /app/src

RUN pdm install --check --prod --no-editable


# Run stage
FROM python:$PYTHON_BASE

WORKDIR /app

RUN apt-get update && apt-get install -y --no-install-recommends \
jq \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

COPY --from=builder /app/.venv/ /app/.venv
ENV PATH="/app/.venv/bin:$PATH"
COPY src /app/src

EXPOSE 8080

ARG VERSION
ARG VERSION_SHA
ENV APIGATOR_VERSION="${VERSION}"
ENV APIGATOR_VERSION_SHA="${VERSION_SHA}"

CMD ["python", "src/apigator/main.py"]
10 changes: 0 additions & 10 deletions dockerfile

This file was deleted.

343 changes: 342 additions & 1 deletion pdm.lock

Large diffs are not rendered by default.

25 changes: 13 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
[project]
name = "apigator"
dynamic = ["version"]
description = "APIgator - Standalone API documentation and testing tool"
description = "APIgator - Lightweight HTTP API Aggregator with jq filtering"
readme = "README.md"
license = { text = "MIT" }
requires-python = ">=3.11"
authors = [
{name = "Niklas Bettgen",email = "niklas@bettgen.de"},
{name = "Niklas Bettgen", email = "niklas@bettgen.de"},
]
keywords = ["api", "documentation", "testing"]
keywords = ["api", "http", "aggregator", "jq"]
classifiers = [
"Development Status :: 3 - Alpha",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Libraries",
]

dependencies = [
"fastapi>=0.100.0",
"uvicorn[standard]>=0.23.0",
"httpx>=0.24.0",
"pyyaml>=6.0",
]
version = "0.1.0"

[project.optional-dependencies]
[dependency-groups]
dev = [
"ruff>=0.5.0",
"isort>=5.13.0",
"pytest>=7.4.0",
"pytest-cov>=4.1.0",
"pyright>=1.1.350",
"ruff>=0.16.1",
"isort>=8.0.1",
"pytest>=9.1.1",
"pytest-cov>=7.1.0",
"pyright>=1.1.411",
]

[build-system]
Expand Down
2 changes: 1 addition & 1 deletion src/apigator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""APIgator - Lightweight API Aggregator with jq filtering."""

from main import app
from .main import app

__all__ = ["app"]
13 changes: 7 additions & 6 deletions src/apigator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
from fastapi import FastAPI, HTTPException

CONFIG_FILE = "/config/config.yaml"
VERSION = os.getenv("APIGATOR_VERSION", "unknown")
config = None
VERSION = os.getenv("APIGATOR_VERSION", "(unknown)")
config = {}
app = FastAPI(title="APIgator")


class ResponseStatus(str, Enum):
class ResponseStatus(Enum):
SUCCESS = "success"
ERROR = "error"
OK = "ok"


def load_config():
Expand All @@ -31,7 +30,9 @@ def load_config():
config = yaml.safe_load(config_raw)


def create_response(status: ResponseStatus, data: dict = None, error: str = "", message: str = ""):
def create_response(
status: ResponseStatus, data: dict | None = None, error: str = "", message: str = ""
):
"""Standard response format of consistent structure"""
return {
"version": VERSION,
Expand Down Expand Up @@ -121,7 +122,7 @@ async def execute_query(query_def):

@app.get("/health")
async def health():
return create_response(status=ResponseStatus.OK, message="APIgator is running")
return create_response(status=ResponseStatus.SUCCESS, message="APIgator is running")


@app.get("/query/{query_name}")
Expand Down
Loading