Skip to content

Commit

Permalink
Fixes, change to composite API for Vue 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Centurix committed Apr 17, 2024
1 parent 844227d commit 8f8a40e
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
![licence](https://img.shields.io/github/license/huh-sters/traffcap.svg)
![pdm-managed](https://img.shields.io/badge/pdm-managed-blueviolet)

![Logo](https://github.com/huh-sters/traffcap/blob/master/src/traffcap/spa/src/assets/images/traffcap_logo.png?raw=true)
![Logo](https://github.com/huh-sters/traffcap/blob/master/src/traffcap/spa/src/assets/traffcap_logo.png?raw=true)

# What Is Currently Working?

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ dependencies = [
"pydanja>=0.1.0",
"dpath>=2.1.6",
]
# TODO: Open this to >=3.8 once released
requires-python = ">=3.8,<3.9"
# readme = "README.md"
license = {file = "LICENSE"}
Expand Down
134 changes: 134 additions & 0 deletions src/doc/diagrams/critical_path_inbound_request.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1d2hcmz" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.20.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.20.0">
<bpmn:collaboration id="Collaboration_0gnffgf">
<bpmn:participant id="Participant_0wm1rk6" name="Inbound Message Processing" processRef="Process_0gjrx3e" />
</bpmn:collaboration>
<bpmn:process id="Process_0gjrx3e" isExecutable="true" camunda:historyTimeToLive="180">
<bpmn:laneSet id="LaneSet_1w88yov">
<bpmn:lane id="Lane_1i59qon" name="Client">
<bpmn:flowNodeRef>StartEvent_1</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Event_16mpbtt</bpmn:flowNodeRef>
</bpmn:lane>
<bpmn:lane id="Lane_0nfagd4" name="Storage" />
<bpmn:lane id="Lane_0kc5gy5" name="Traffcap">
<bpmn:flowNodeRef>Activity_06qxa63</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_18boe6z</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_1qubg2d</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_0ks8fif</bpmn:flowNodeRef>
</bpmn:lane>
</bpmn:laneSet>
<bpmn:sequenceFlow id="Flow_065f8uq" sourceRef="StartEvent_1" targetRef="Activity_06qxa63" />
<bpmn:task id="Activity_06qxa63" name="Receive Webhook Payload">
<bpmn:incoming>Flow_065f8uq</bpmn:incoming>
<bpmn:outgoing>Flow_09mi9kc</bpmn:outgoing>
</bpmn:task>
<bpmn:task id="Activity_18boe6z" name="Store Requst Data">
<bpmn:incoming>Flow_09mi9kc</bpmn:incoming>
<bpmn:outgoing>Flow_145g0g8</bpmn:outgoing>
<bpmn:dataOutputAssociation id="DataOutputAssociation_0638zlf">
<bpmn:targetRef>DataStoreReference_1nhymxe</bpmn:targetRef>
</bpmn:dataOutputAssociation>
</bpmn:task>
<bpmn:sequenceFlow id="Flow_09mi9kc" sourceRef="Activity_06qxa63" targetRef="Activity_18boe6z" />
<bpmn:dataStoreReference id="DataStoreReference_1nhymxe" />
<bpmn:task id="Activity_1qubg2d" name="Match Payload to find a reply">
<bpmn:incoming>Flow_145g0g8</bpmn:incoming>
<bpmn:outgoing>Flow_12x3m4a</bpmn:outgoing>
<bpmn:dataOutputAssociation id="DataOutputAssociation_02ggkso">
<bpmn:targetRef>DataStoreReference_107xu96</bpmn:targetRef>
</bpmn:dataOutputAssociation>
</bpmn:task>
<bpmn:sequenceFlow id="Flow_145g0g8" sourceRef="Activity_18boe6z" targetRef="Activity_1qubg2d" />
<bpmn:sequenceFlow id="Flow_12x3m4a" sourceRef="Activity_1qubg2d" targetRef="Activity_0ks8fif" />
<bpmn:dataStoreReference id="DataStoreReference_107xu96" />
<bpmn:task id="Activity_0ks8fif" name="Send Reply">
<bpmn:incoming>Flow_12x3m4a</bpmn:incoming>
<bpmn:outgoing>Flow_1pdsw7h</bpmn:outgoing>
</bpmn:task>
<bpmn:sequenceFlow id="Flow_1pdsw7h" sourceRef="Activity_0ks8fif" targetRef="Event_16mpbtt" />
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_065f8uq</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:endEvent id="Event_16mpbtt">
<bpmn:incoming>Flow_1pdsw7h</bpmn:incoming>
</bpmn:endEvent>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0gnffgf">
<bpmndi:BPMNShape id="Participant_0wm1rk6_di" bpmnElement="Participant_0wm1rk6" isHorizontal="true">
<dc:Bounds x="230" y="139" width="1190" height="381" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_0kc5gy5_di" bpmnElement="Lane_0kc5gy5" isHorizontal="true">
<dc:Bounds x="260" y="260" width="1160" height="140" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_0nfagd4_di" bpmnElement="Lane_0nfagd4" isHorizontal="true">
<dc:Bounds x="260" y="400" width="1160" height="120" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_1i59qon_di" bpmnElement="Lane_1i59qon" isHorizontal="true">
<dc:Bounds x="260" y="139" width="1160" height="121" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_06qxa63_di" bpmnElement="Activity_06qxa63">
<dc:Bounds x="490" y="290" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_18boe6z_di" bpmnElement="Activity_18boe6z">
<dc:Bounds x="670" y="290" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="DataStoreReference_1nhymxe_di" bpmnElement="DataStoreReference_1nhymxe">
<dc:Bounds x="695" y="435" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1qubg2d_di" bpmnElement="Activity_1qubg2d">
<dc:Bounds x="850" y="290" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="DataStoreReference_107xu96_di" bpmnElement="DataStoreReference_107xu96">
<dc:Bounds x="875" y="435" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0ks8fif_di" bpmnElement="Activity_0ks8fif">
<dc:Bounds x="1030" y="290" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="352" y="182" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_16mpbtt_di" bpmnElement="Event_16mpbtt">
<dc:Bounds x="1218" y="182" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_065f8uq_di" bpmnElement="Flow_065f8uq">
<di:waypoint x="370" y="218" />
<di:waypoint x="370" y="330" />
<di:waypoint x="490" y="330" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_09mi9kc_di" bpmnElement="Flow_09mi9kc">
<di:waypoint x="590" y="330" />
<di:waypoint x="670" y="330" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_145g0g8_di" bpmnElement="Flow_145g0g8">
<di:waypoint x="770" y="330" />
<di:waypoint x="850" y="330" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_12x3m4a_di" bpmnElement="Flow_12x3m4a">
<di:waypoint x="950" y="330" />
<di:waypoint x="1030" y="330" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1pdsw7h_di" bpmnElement="Flow_1pdsw7h">
<di:waypoint x="1130" y="330" />
<di:waypoint x="1236" y="330" />
<di:waypoint x="1236" y="218" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="DataOutputAssociation_0638zlf_di" bpmnElement="DataOutputAssociation_0638zlf">
<di:waypoint x="720" y="370" />
<di:waypoint x="720" y="435" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="DataOutputAssociation_02ggkso_di" bpmnElement="DataOutputAssociation_02ggkso">
<di:waypoint x="900" y="370" />
<di:waypoint x="900" y="435" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
12 changes: 6 additions & 6 deletions src/migrations/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ def generate_db_url(migration: bool = False) -> str:
aio_handlers = {
"sqlite": "sqlite+aiosqlite", # Tested
"mysql": "mysql+aiomysql", # Tested
"mssql": "mssql+pyodbc", # TODO: Untested (might not work!)
"postgresql": "postgresql+asyncpg", # TODO: Untested, alt is aiopg
"oracle": "oracle+cx_oracle_async" # TODO: Untested
"mssql": "mssql+pyodbc", # TODO: AIO Test MS SQL+pyodbc
"postgresql": "postgresql+asyncpg", # TODO: AIO Test PostgreSQL + asyncpg
"oracle": "oracle+cx_oracle_async" # TODO: AIO Test Oracle + CX Oracle async
}

non_aio_handlers = {
"sqlite": "sqlite", # Tested
"mysql": "mysql+pymysql", # Tested
"mssql": "mssql+pyodbc", # TODO: Untested
"postgresql": "postgresql+psycopg2", # TODO: Untested
"oracle": "oracle+cx_oracle" # TODO: Untested
"mssql": "mssql+pyodbc", # TODO: Non-AIO Test MS SQL + pyodbc
"postgresql": "postgresql+psycopg2", # TODO: Non-AIO Test PostgreSQL + psycopg2
"oracle": "oracle+cx_oracle" # TODO: Non-AIO Test Oracle + CX Oracle
}

if migration:
Expand Down
3 changes: 2 additions & 1 deletion src/traffcap/repositories/inbound_request_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ async def store_request(
@classmethod
async def get_all_inbound_requests(cls) -> List[InboundRequest]:
"""
TODO: Can we reduce the double handling of models between sqlalchemy and
TODO: Reduce the double handling of models
Can we reduce the double handling of models between sqlalchemy and
pydantic? It would be nice to pass the select statement to the scalars()
method along with some kind of builder that generates pydantic models directly
"""
Expand Down
11 changes: 7 additions & 4 deletions src/traffcap/routes/inbound_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
from traffcap.dto import HTTPVerbs
import json
"""
Files in the root directory
Inbound Requests
================
Deal with all inbound traffic from webhooks. This has a single route which works with all HTTP verbs.
"""

inbound_requests_router = APIRouter(
Expand Down Expand Up @@ -48,8 +52,8 @@ async def requests_route(endpoint_code: str, request: Request) -> Response:
Found a match
* run the actions
* send the response
TODO: Actions go here
TODO: Response goes here. It should reflect the requested content type
TODO: Create Actions
TODO: Make the content type match the requested type
1. If there's an accept header, use that
2. If there's a content-type, use that to match what was sent
3. Default to application/json
Expand All @@ -64,7 +68,6 @@ async def requests_route(endpoint_code: str, request: Request) -> Response:
# Notify all listening web sockets
new_traffic_notification()

# TODO: Default response
return Response(json.dumps({
"status": f"{request.method} OK for {endpoint_code}"
}))
3 changes: 3 additions & 0 deletions src/traffcap/routes/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
from traffcap.core import Metric
"""
Prometheus exporter endpoint
============================
TODO: Make the Prometheus exporter work
"""


Expand Down
2 changes: 1 addition & 1 deletion src/traffcap/routes/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def friendly_validation_error(ve: ValidationError) -> List[str]:
async def rule_get() -> DANJAResourceList[Rule]:
"""
Return a list of rules
TODO: Support paging
TODO: Support rule list paging
"""
rules = await RuleRepository.get_all_rules()

Expand Down
2 changes: 1 addition & 1 deletion src/traffcap/routes/traffic.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def traffic_get() -> DANJAResourceList[InboundRequest]:

@traffic_router.websocket("/ws")
async def traffic_firehose(websocket: WebSocket):
# TODO: Only send the newer requests instead of everything
# TODO: Only send the newer requests instead of everything in the WebSocket
try:
await websocket.accept()
while True:
Expand Down
3 changes: 2 additions & 1 deletion src/traffcap/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def custom_openapi() -> Dict[str, Any]:

# Enable CORS from anywhere with anything
# TODO: Upgrade to Python 3.8 for current EOL support
# TODO: Add UI to restrict these
# TODO: Upgrade to Python 3.9 for October 2024
# TODO: Add UI to restrict CORS
# TODO: Fix CORS for new Chrome addition where non-secure localhosts clash
app.add_middleware(
CORSMiddleware,
Expand Down

0 comments on commit 8f8a40e

Please sign in to comment.