js-api 0.2.83__tar.gz → 0.2.85__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. {js_api-0.2.83/src/js_api.egg-info → js_api-0.2.85}/PKG-INFO +2 -2
  2. {js_api-0.2.83 → js_api-0.2.85}/pyproject.toml +2 -2
  3. {js_api-0.2.83 → js_api-0.2.85}/src/api.py +1 -1
  4. {js_api-0.2.83 → js_api-0.2.85}/src/controllers/health_check.py +1 -1
  5. {js_api-0.2.83 → js_api-0.2.85}/src/controllers/ip.py +6 -8
  6. {js_api-0.2.83 → js_api-0.2.85/src/js_api.egg-info}/PKG-INFO +2 -2
  7. {js_api-0.2.83 → js_api-0.2.85}/src/js_api.egg-info/requires.txt +1 -1
  8. {js_api-0.2.83 → js_api-0.2.85}/src/util/docker.py +3 -4
  9. {js_api-0.2.83 → js_api-0.2.85}/src/util/healthcheck.py +5 -3
  10. {js_api-0.2.83 → js_api-0.2.85}/tests/test_docker.py +0 -2
  11. {js_api-0.2.83 → js_api-0.2.85}/tests/test_health_check.py +1 -2
  12. {js_api-0.2.83 → js_api-0.2.85}/tests/test_ip.py +14 -14
  13. {js_api-0.2.83 → js_api-0.2.85}/LICENSE +0 -0
  14. {js_api-0.2.83 → js_api-0.2.85}/README.md +0 -0
  15. {js_api-0.2.83 → js_api-0.2.85}/setup.cfg +0 -0
  16. {js_api-0.2.83 → js_api-0.2.85}/src/__init__.py +0 -0
  17. {js_api-0.2.83 → js_api-0.2.85}/src/controllers/__init__.py +0 -0
  18. {js_api-0.2.83 → js_api-0.2.85}/src/controllers/docker.py +0 -0
  19. {js_api-0.2.83 → js_api-0.2.85}/src/controllers/valentines_day.py +0 -0
  20. {js_api-0.2.83 → js_api-0.2.85}/src/database.py +0 -0
  21. {js_api-0.2.83 → js_api-0.2.85}/src/js_api.egg-info/SOURCES.txt +0 -0
  22. {js_api-0.2.83 → js_api-0.2.85}/src/js_api.egg-info/dependency_links.txt +0 -0
  23. {js_api-0.2.83 → js_api-0.2.85}/src/js_api.egg-info/top_level.txt +0 -0
  24. {js_api-0.2.83 → js_api-0.2.85}/src/models.py +0 -0
  25. {js_api-0.2.83 → js_api-0.2.85}/src/util/__init__.py +0 -0
  26. {js_api-0.2.83 → js_api-0.2.85}/src/util/auth.py +0 -0
  27. {js_api-0.2.83 → js_api-0.2.85}/src/util/logging.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: js-api
3
- Version: 0.2.83
3
+ Version: 0.2.85
4
4
  Summary: Custom API written in Python using FastAPI
5
5
  Author-email: Jack Stockley <jack@jstockley.com>
6
6
  Project-URL: Homepage, https://github.com/jnstockley/api
@@ -11,7 +11,7 @@ Classifier: Programming Language :: Python :: 3
11
11
  Requires-Python: <4.0,>=3.14
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
- Requires-Dist: fastapi[standard]==0.139.1
14
+ Requires-Dist: fastapi[standard]==0.140.0
15
15
  Requires-Dist: sqlalchemy==2.0.51
16
16
  Requires-Dist: sqlmodel==0.0.39
17
17
  Requires-Dist: python-dotenv==1.2.2
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "js-api"
3
- version = "0.2.83"
3
+ version = "0.2.85"
4
4
  description = "Custom API written in Python using FastAPI"
5
5
  authors = [
6
6
  {name = "Jack Stockley", email = "jack@jstockley.com"}
@@ -8,7 +8,7 @@ authors = [
8
8
  readme = "README.md"
9
9
  requires-python = ">=3.14, <4.0"
10
10
  dependencies = [
11
- "fastapi[standard]==0.139.1",
11
+ "fastapi[standard]==0.140.0",
12
12
  "sqlalchemy==2.0.51",
13
13
  "sqlmodel==0.0.39",
14
14
  "python-dotenv==1.2.2",
@@ -16,7 +16,7 @@ try:
16
16
  pyproject_path = Path(__file__).parent.parent / "pyproject.toml"
17
17
  with open(pyproject_path, "rb") as f:
18
18
  version = tomllib.load(f)["project"]["version"]
19
- except Exception:
19
+ except Exception: # noqa: BLE001
20
20
  version = "0.1.0"
21
21
 
22
22
 
@@ -13,6 +13,6 @@ async def health_check(db: db_dependency):
13
13
  # Execute a simple query to check the database connection
14
14
  db.exec(select(1))
15
15
  return {"status": "ok"}
16
- except Exception as e:
16
+ except Exception as e: # noqa: BLE001
17
17
  logger.error(e)
18
18
  raise HTTPException(status_code=500, detail="Database connection failed")
@@ -1,6 +1,5 @@
1
1
  import datetime
2
2
  import re
3
- from typing import Optional
4
3
 
5
4
  from fastapi import APIRouter, HTTPException, Request, Security
6
5
  from sqlalchemy import select
@@ -35,8 +34,8 @@ ipv6_pattern = re.compile(
35
34
  async def add_ip(
36
35
  identifier: str,
37
36
  request: Request,
38
- ipv4_address: Optional[str] = None,
39
- ipv6_address: Optional[str] = None,
37
+ ipv4_address: str | None = None,
38
+ ipv6_address: str | None = None,
40
39
  ):
41
40
  if identifier.strip() == "":
42
41
  raise HTTPException(
@@ -74,24 +73,23 @@ async def get_ip(identifier: str):
74
73
  return row
75
74
 
76
75
 
77
- def __update_ip(
78
- identifier: str, ipv4_address: Optional[str], ipv6_address: Optional[str]
79
- ):
76
+ def __update_ip(identifier: str, ipv4_address: str | None, ipv6_address: str | None):
80
77
  with Session(engine) as s:
81
78
  stmt = select(IpAddress).where(IpAddress.id == identifier)
82
79
  row: IpAddress = s.execute(stmt).scalar_one_or_none()
80
+ tz_info = datetime.datetime.now(datetime.UTC).astimezone().tzinfo
83
81
  if row is None:
84
82
  row = IpAddress(
85
83
  id=identifier,
86
84
  ipv4_address=ipv4_address,
87
85
  ipv6_address=ipv6_address,
88
- updated_at=datetime.datetime.now(),
86
+ updated_at=datetime.datetime.now(tz=tz_info),
89
87
  )
90
88
  s.add(row)
91
89
  else:
92
90
  row.ipv4_address = ipv4_address
93
91
  row.ipv6_address = ipv6_address
94
- row.updated_at = datetime.datetime.now()
92
+ row.updated_at = datetime.datetime.now(tz=tz_info)
95
93
  s.flush()
96
94
  s.commit()
97
95
  s.refresh(row)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: js-api
3
- Version: 0.2.83
3
+ Version: 0.2.85
4
4
  Summary: Custom API written in Python using FastAPI
5
5
  Author-email: Jack Stockley <jack@jstockley.com>
6
6
  Project-URL: Homepage, https://github.com/jnstockley/api
@@ -11,7 +11,7 @@ Classifier: Programming Language :: Python :: 3
11
11
  Requires-Python: <4.0,>=3.14
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
- Requires-Dist: fastapi[standard]==0.139.1
14
+ Requires-Dist: fastapi[standard]==0.140.0
15
15
  Requires-Dist: sqlalchemy==2.0.51
16
16
  Requires-Dist: sqlmodel==0.0.39
17
17
  Requires-Dist: python-dotenv==1.2.2
@@ -1,4 +1,4 @@
1
- fastapi[standard]==0.139.1
1
+ fastapi[standard]==0.140.0
2
2
  sqlalchemy==2.0.51
3
3
  sqlmodel==0.0.39
4
4
  python-dotenv==1.2.2
@@ -33,9 +33,8 @@ def get_latest_docker_image(image: str) -> str | None:
33
33
  "digest" in docker_image
34
34
  and "name" in docker_image
35
35
  and docker_image["digest"] == digest
36
+ and docker_image["name"] != "latest"
37
+ and re.fullmatch(version_regex, docker_image["name"])
36
38
  ):
37
- if docker_image["name"] != "latest" and re.fullmatch(
38
- version_regex, docker_image["name"]
39
- ):
40
- return docker_image["name"]
39
+ return docker_image["name"]
41
40
  return None
@@ -1,3 +1,5 @@
1
+ import sys
2
+
1
3
  from sqlalchemy import select
2
4
 
3
5
  from database import get_db
@@ -10,7 +12,7 @@ def healthcheck() -> bool:
10
12
  db = next(get_db())
11
13
  # Execute a simple query to check the database connection
12
14
  db.exec(select(1))
13
- exit(0)
14
- except Exception as e:
15
+ sys.exit(0)
16
+ except Exception as e: # noqa: BLE001
15
17
  logger.error(e)
16
- exit(1)
18
+ sys.exit(1)
@@ -7,10 +7,8 @@ from sqlalchemy.orm import sessionmaker
7
7
  from testcontainers.postgres import PostgresContainer
8
8
 
9
9
  from database import Base, get_db
10
-
11
10
  from src.api import app
12
11
 
13
-
14
12
  postgres = PostgresContainer("postgres:17-alpine").start()
15
13
 
16
14
  # Set up the test database URL before importing the app
@@ -1,7 +1,6 @@
1
1
  import os
2
2
  from unittest import TestCase, skip
3
3
 
4
- from src.api import app
5
4
  from fastapi.testclient import TestClient
6
5
  from sqlalchemy import create_engine
7
6
  from sqlalchemy.orm import sessionmaker
@@ -9,7 +8,7 @@ from testcontainers.postgres import PostgresContainer
9
8
 
10
9
  import models
11
10
  from database import get_db
12
-
11
+ from src.api import app
13
12
 
14
13
  postgres = PostgresContainer("postgres:17-alpine").start()
15
14
 
@@ -1,13 +1,13 @@
1
1
  import os
2
2
  from unittest import TestCase
3
3
 
4
- from database import engine, get_db
5
- from src.api import app
6
4
  from fastapi.testclient import TestClient
7
5
  from sqlalchemy.orm import sessionmaker
8
6
  from testcontainers.postgres import PostgresContainer
9
7
 
10
8
  import models
9
+ from database import engine, get_db
10
+ from src.api import app
11
11
 
12
12
  postgres = PostgresContainer("postgres:17-alpine").start()
13
13
 
@@ -68,9 +68,9 @@ class TestIp(TestCase):
68
68
 
69
69
  assert response.status_code == 200
70
70
  res_json: dict = response.json()
71
- assert "id" in res_json.keys()
72
- assert "ipv4_address" in res_json.keys()
73
- assert "updated_at" in res_json.keys()
71
+ assert "id" in res_json
72
+ assert "ipv4_address" in res_json
73
+ assert "updated_at" in res_json
74
74
  assert res_json["id"] == identifier
75
75
  assert res_json["ipv4_address"] == ip
76
76
 
@@ -86,9 +86,9 @@ class TestIp(TestCase):
86
86
 
87
87
  assert response.status_code == 200
88
88
  res_json: dict = response.json()
89
- assert "id" in res_json.keys()
90
- assert "ipv4_address" in res_json.keys()
91
- assert "updated_at" in res_json.keys()
89
+ assert "id" in res_json
90
+ assert "ipv4_address" in res_json
91
+ assert "updated_at" in res_json
92
92
  assert res_json["id"] == identifier
93
93
  assert res_json["ipv4_address"] == ip
94
94
 
@@ -101,9 +101,9 @@ class TestIp(TestCase):
101
101
  res_json: list[dict] = response.json()
102
102
  assert len(res_json) == 1
103
103
  res_json: dict = res_json[0]
104
- assert "id" in res_json.keys()
105
- assert "ipv4_address" in res_json.keys()
106
- assert "updated_at" in res_json.keys()
104
+ assert "id" in res_json
105
+ assert "ipv4_address" in res_json
106
+ assert "updated_at" in res_json
107
107
  assert res_json["id"] == "test"
108
108
  assert res_json["ipv4_address"] == "1.1.1.1"
109
109
 
@@ -120,8 +120,8 @@ class TestIp(TestCase):
120
120
  response = client.get("/ip/test", headers=header)
121
121
  assert response.status_code == 200
122
122
  res_json: dict = response.json()
123
- assert "id" in res_json.keys()
124
- assert "ipv4_address" in res_json.keys()
125
- assert "updated_at" in res_json.keys()
123
+ assert "id" in res_json
124
+ assert "ipv4_address" in res_json
125
+ assert "updated_at" in res_json
126
126
  assert res_json["id"] == "test"
127
127
  assert res_json["ipv4_address"] == "1.1.1.1"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes