mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-15 22:51:37 -07:00
Address Coderabbit items.
This commit is contained in:
@@ -16,7 +16,8 @@ Network monitoring & alerting. Provides inventory, awareness, insight, categoriz
|
|||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
- **Backend (Python):** `server/__main__.py`, `server/plugin.py`, `server/api_server/api_server_start.py`
|
- **Backend (Python):** `server/__main__.py`, `server/plugin.py`, `server/api_server/api_server_start.py`
|
||||||
- **Data (SQLite):** `db/app.db`; helpers in `server/db/*`
|
- **Backend Config:** `/data/config/app.conf`
|
||||||
|
- **Data (SQLite):** `/data/db/app.db`; helpers in `server/db/*`
|
||||||
- **Frontend (Nginx + PHP + JS):** `front/`
|
- **Frontend (Nginx + PHP + JS):** `front/`
|
||||||
- **Plugins (Python):** `front/plugins/*` with `config.json` manifests
|
- **Plugins (Python):** `front/plugins/*` with `config.json` manifests
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ Procedural knowledge lives in `.github/skills/`. Load the appropriate skill when
|
|||||||
| Load sample devices | `sample-data` |
|
| Load sample devices | `sample-data` |
|
||||||
| Build Docker images | `docker-build` |
|
| Build Docker images | `docker-build` |
|
||||||
| Reprovision devcontainer | `devcontainer-setup` |
|
| Reprovision devcontainer | `devcontainer-setup` |
|
||||||
| Create or run plugins | `plugin-development` |
|
| Create or run plugins | `plugin-run-development` |
|
||||||
| Analyze PR comments | `pr-analysis` |
|
| Analyze PR comments | `pr-analysis` |
|
||||||
| Clean Docker resources | `docker-prune` |
|
| Clean Docker resources | `docker-prune` |
|
||||||
| Generate devcontainer configs | `devcontainer-configs` |
|
| Generate devcontainer configs | `devcontainer-configs` |
|
||||||
|
|||||||
@@ -38,7 +38,15 @@ Retrieve token via `get_setting_value('API_TOKEN')`.
|
|||||||
|
|
||||||
**MANDATORY:** All responses must include `"success": true|false`
|
**MANDATORY:** All responses must include `"success": true|false`
|
||||||
|
|
||||||
On failure, include error message:
|
```python
|
||||||
|
return {"success": False, "error": "Description of what went wrong"}
|
||||||
|
```
|
||||||
|
|
||||||
|
On success:
|
||||||
|
|
||||||
|
```python
|
||||||
|
return {"success": True, "data": result}
|
||||||
|
```
|
||||||
|
|
||||||
```python
|
```python
|
||||||
return {"success": False, "error": "Description of what went wrong"}
|
return {"success": False, "error": "Description of what went wrong"}
|
||||||
@@ -50,6 +58,9 @@ On success:
|
|||||||
return {"success": True, "data": result}
|
return {"success": True, "data": result}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
**Exception:** The legacy `/device/<mac>` GET endpoint does not follow this contract to maintain backward compatibility with the UI.
|
||||||
|
|
||||||
## Adding New Endpoints
|
## Adding New Endpoints
|
||||||
|
|
||||||
1. Add route in `server/api_server/` directory
|
1. Add route in `server/api_server/` directory
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
name: netalertx-idempotent—setup
|
name: netalertx-idempotent-setup
|
||||||
description: Reprovision and reset the devcontainer environment. Use this when asked to re-run startup, reprovision, setup devcontainer, fix permissions, or reset runtime state.
|
description: Reprovision and reset the devcontainer environment. Use this when asked to re-run startup, reprovision, setup devcontainer, fix permissions, or reset runtime state.
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ Ensure `sys.path` includes `/app/front/plugins` and `/app/server` (as in the tem
|
|||||||
|
|
||||||
## Plugin Structure
|
## Plugin Structure
|
||||||
|
|
||||||
```
|
```text
|
||||||
front/plugins/<code_name>/
|
front/plugins/<code_name>/
|
||||||
├── config.json # Manifest with settings
|
├── config.json # Manifest with settings
|
||||||
├── script.py # Main script
|
├── script.py # Main script
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ NetAlertX uses a frontend–backend architecture: the frontend runs on **PHP + N
|
|||||||
|
|
||||||
## Environment Variables
|
## Environment Variables
|
||||||
|
|
||||||
Use these instead of hardcoding paths:
|
Use these NETALERTX_* instead of hardcoding paths. Examples:
|
||||||
|
|
||||||
- `NETALERTX_DB`
|
- `NETALERTX_DB`
|
||||||
- `NETALERTX_LOG`
|
- `NETALERTX_LOG`
|
||||||
|
|||||||
@@ -25,9 +25,15 @@ Use VS Code's testing interface or the `runTests` tool with appropriate paramete
|
|||||||
|
|
||||||
Tests live in `test/` directory. App code is under `server/`.
|
Tests live in `test/` directory. App code is under `server/`.
|
||||||
|
|
||||||
PYTHONPATH is preconfigured to include:
|
PYTHONPATH is preconfigured to include the following which should meet all needs:
|
||||||
|
- `/app` # the primary location where python runs in the production system
|
||||||
|
- `/app/server` # symbolic link to /wprkspaces/NetAlertX/server
|
||||||
|
- `/app/front/plugins` # symbolic link to /workspaces/NetAlertX/front/plugins
|
||||||
|
- `/opt/venv/lib/pythonX.Y/site-packages`
|
||||||
|
- `/workspaces/NetAlertX/test`
|
||||||
|
- `/workspaces/NetAlertX/server`
|
||||||
- `/workspaces/NetAlertX`
|
- `/workspaces/NetAlertX`
|
||||||
- `/opt/venv/lib/python3.12/site-packages`
|
- `/usr/lib/pythonX.Y/site-packages`
|
||||||
|
|
||||||
## Authentication in Tests
|
## Authentication in Tests
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user