Update readme's, branches and actions
Build and Push Docker Images / detect-changes (push) Successful in 9s
Build and Push Docker Images / build-auth-api (push) Successful in 1m5s
Build and Push Docker Images / build-employee-api (push) Successful in 1m1s
Build and Push Docker Images / build-transit-api (push) Successful in 57s
Build and Push Docker Images / build-error-log-api (push) Successful in 1m5s
Build and Push Docker Images / build-admin-ui (push) Successful in 1m16s
Build and Push Docker Images / build-monitoring-ui (push) Successful in 1m13s
Build and Push Docker Images / deploy-test-node (push) Successful in 5s

This commit is contained in:
Sven laptop
2026-09-21 00:15:05 +02:00
parent 635a130f0b
commit 217dfd3abc
161 changed files with 644 additions and 21618 deletions
+36 -36
View File
@@ -1,41 +1,41 @@
# Transit API
Transit API voor het beheren van busroutes, navigatie en GPS tracking voor busbestuurders.
Transit API for managing bus routes, navigation, and GPS tracking for bus drivers.
## Project Structuur
## Project Structure
```
transit_api/
├── index.js # Main API endpoints
├── middleware.js # JWT authentication middleware
├── db.js # PostgreSQL connection
├── schema.sql # Database schema setup
├── package.json # Dependencies
└── .env # Environment variables
├── db.js # PostgreSQL connection
├── schema.sql # Database schema setup
├── package.json # Dependencies
└── .env # Environment variables
```
## Setup
### 1. Dependencies installeren
### 1. Install Dependencies
```bash
npm install
```
### 2. Database Schema opzetten
### 2. Set Up Database Schema
Voer het volgende uit in PostgreSQL:
Execute the following in PostgreSQL:
```bash
# Via psql command line
psql -U your_user -d your_database -f schema.sql
```
Of kopieer-plak de SQL queries rechtstreeks in pgAdmin.
Or copy-paste the SQL queries directly into pgAdmin.
### 3. Environment variabelen (.env)
### 3. Environment Variables (.env)
```
```env
PG_HOST=localhost
PG_PORT=5432
PG_USER=your_user
@@ -47,28 +47,28 @@ PORT=5001
Note: `ADMIN_USER_CODES` has been moved to the `auth_api` service. Configure admin user codes in `auth_api/.env` as a comma-separated list.
### 4. API starten
### 4. Start API
```bash
npm start
```
API draait op `https://transit.xtransit.testinstance.nl`
The API runs at `https://transit.xtransit.testinstance.nl`
The service group also includes the Employee API at
`https://employees.xtransit.testinstance.nl` and the central monitoring
dashboard. See [`../docs/MONITORING_UI.md`](../docs/MONITORING_UI.md) for health
dashboard. See [`../MONITORING_UI.md`](../MONITORING_UI.md) for health
checks, error inspection, and the controlled request tester.
## API Endpoints
Alle endpoints vereisen een `Authorization: Bearer {token}` header.
All endpoints require an `Authorization: Bearer {token}` header.
**GET** `/health`
- Controleert of de gedeployde transit API draait en de database bereikbaar is.
- Geeft `200` met `{"status":"ok","database":"ok"}` bij succes.
- Geeft `503` als de API wel draait maar de database niet bereikbaar is.
- Checks whether the deployed transit API is running and the database is reachable.
- Returns `200` with `{"status":"ok","database":"ok"}` on success.
- Returns `503` if the API is running but the database is unreachable.
### Schedule
@@ -119,7 +119,7 @@ clients, but new clients must use the weekly schedule endpoints above.
**GET** `/schedule/daily?date=2024-05-05`
- Ophalen van dagplanning voor chauffeur
- Retrieve daily schedule for driver
- Response:
```json
@@ -147,22 +147,22 @@ clients, but new clients must use the weekly schedule endpoints above.
**GET** `/routes/:routeId`
- Details van een specifieke route
- Details of a specific route
- Response: `{ "route": {...} }`
### Public Schedule Overview
**GET** `/schedules/overview?date=2026-05-06&lineId=1`
- Haalt een datum-gebonden overzicht op van geplande diensten
- Fetches a date-based overview of scheduled services
- Weekly templates are selected by `day_of_week` and driver assignments by `shifts`
- Incidentele diensten worden alleen meegenomen op hun exacte datum
- One-off / incidental services are only included on their exact date
- Filters: `driverId`/`chauffeurId`, `stopId`/`busStopId`, `lineId`, `status`
- Response: `{ "date": "2026-05-06", "summary": {...}, "schedules": [...] }`
De legacy endpoint **GET** `/schedules` blijft beschikbaar voor bestaande clients.
The legacy endpoint **GET** `/schedules` remains available for existing clients.
Voorbeeld:
Example:
```bash
curl "https://transit.xtransit.testinstance.nl/schedules/overview?date=2026-05-06&chauffeurId=12&busStopId=3"
@@ -172,7 +172,7 @@ curl "https://transit.xtransit.testinstance.nl/schedules/overview?date=2026-05-0
**POST** `/navigation/route`
- Opslaan van berekende route van OSRM
- Save calculated route from OSRM
- Body:
```json
@@ -193,7 +193,7 @@ curl "https://transit.xtransit.testinstance.nl/schedules/overview?date=2026-05-0
**GET** `/bus-lines/:busLineId/stops`
- Alle stops van een buslijn (voor navigatie waypoints)
- All stops of a bus line (for navigation waypoints)
- Response:
```json
@@ -214,7 +214,7 @@ curl "https://transit.xtransit.testinstance.nl/schedules/overview?date=2026-05-0
**POST** `/gps/track`
- Real-time positie opslaan
- Save real-time position
- Body:
```json
@@ -230,7 +230,7 @@ curl "https://transit.xtransit.testinstance.nl/schedules/overview?date=2026-05-0
**GET** `/gps/route/:routeId`
- Alle opgeslagen positie punten van een route
- All recorded position points of a route
- Response:
```json
@@ -258,11 +258,11 @@ curl "https://transit.xtransit.testinstance.nl/schedules/overview?date=2026-05-0
### Admin
Alle admin-endpoints vereisen naast een geldig JWT-token ook dat je `userCode` voorkomt in `ADMIN_USER_CODES`.
All admin endpoints require, in addition to a valid JWT token, that your `userCode` is present in `ADMIN_USER_CODES`.
**POST** `/admin/stops`
- Maak een herbruikbare stop aan
- Create a reusable stop
- Body:
```json
@@ -275,7 +275,7 @@ Alle admin-endpoints vereisen naast een geldig JWT-token ook dat je `userCode` v
**POST** `/admin/bus-lines/:busLineId/stops`
- Koppel een bestaande stop aan een buslijn
- Link an existing stop to a bus line
- Body:
```json
@@ -320,7 +320,7 @@ Alle admin-endpoints vereisen naast een geldig JWT-token ook dat je `userCode` v
### routes
- `id` - Primary key
- `user_id` - Chauffeur (references workers.users)
- `user_id` - Driver (references workers.users)
- `bus_line_id` - Which line (references bus_lines)
- `bus_type_id` - Which bus (references bus_types)
- `start_time` - Scheduled start
@@ -330,7 +330,7 @@ Alle admin-endpoints vereisen naast een geldig JWT-token ook dat je `userCode` v
- `id` - Primary key
- `route_id` - Link to route (unique)
- `polyline_geojson` - GeoJSON LineString van de route
- `polyline_geojson` - GeoJSON LineString of the route
- `total_distance_meters` - Route distance
- `total_duration_seconds` - Estimated duration
@@ -342,7 +342,7 @@ Alle admin-endpoints vereisen naast een geldig JWT-token ook dat je `userCode` v
- `speed_kmh` - Current speed
- `recorded_at` - Timestamp
## Integration met Flutter App
## Integration with Flutter App
```dart
// In schedule_service.dart
@@ -367,7 +367,7 @@ await scheduleService.updateRouteStatus(1, 'in_progress');
## Error Handling
Alle endpoints retourneren error responses:
All endpoints return error responses:
```json
{