Skip to content

Commit

Permalink
Merge pull request #248 from dsgnr/app_info
Browse files Browse the repository at this point in the history
Deduplicate application info
  • Loading branch information
dsgnr authored Nov 8, 2024
2 parents 21621c6 + 6164188 commit b21353a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 13 deletions.
25 changes: 17 additions & 8 deletions backend/api/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
"""
The portchecker.io App
"""

import pathlib

import tomli
from litestar import Litestar
from litestar.exceptions import ValidationException
from litestar.openapi.config import OpenAPIConfig
Expand All @@ -16,17 +20,22 @@
from app.routes.v1 import v1_query_post
from app.routes.v2 import get_port_check, my_ip, query_post


def _get_project_meta():
"""Parse the pyproject.toml file to retrieve project information"""
with open(
f"{pathlib.Path(__file__).parent.resolve().parent}/pyproject.toml", mode="rb"
) as pyproject:
return tomli.load(pyproject)["tool"]["poetry"]


project_meta = _get_project_meta()
app = Litestar(
route_handlers=[my_ip, query_post, get_port_check, v1_query_post, health],
openapi_config=OpenAPIConfig(
title="portchecker.io",
description=(
"portchecker.io is an open-source API for checking port \
availability on specified hostnames or IP addresses. \
Ideal for developers and network admins, it helps troubleshoot network \
setups, validate firewall rules, and assess potential access points."
),
version="3.0.0",
title=project_meta["name"],
description=project_meta["description"],
version=project_meta["version"],
render_plugins=[ScalarRenderPlugin()],
path="/docs",
use_handler_docstrings=True,
Expand Down
15 changes: 13 additions & 2 deletions backend/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
[tool.poetry]
name = "api"
version = "2.0.0"
description = "A simple API to query ports for hostnames or IP addresses"
package-mode = false
name = "portchecker.io"
version = "3.0.0"
description = """portchecker.io is an open-source API for checking port \
availability on specified hostnames or IP addresses. \
Ideal for developers and network admins, it helps troubleshoot network \
setups, validate firewall rules, and assess potential access points."""
authors = ["dsgnr <[email protected]>"]
repository = "https://github.com/dsgnr/portchecker.io"
license = "GNU General Public License v3.0"
readme = "../README.md"

Expand All @@ -12,6 +17,7 @@ litestar = "2.12.1"
gunicorn = "23.0.0"
pydantic = "2.9.2"
uvicorn = {extras = ["standard"], version = "0.32.0"}
tomli = "^2.0.2"

[tool.poetry.group.dev.dependencies]
pylint = "^3.3.1"
Expand Down

0 comments on commit b21353a

Please sign in to comment.