Refactored all api endpoints to /bus/xxxxx
Build and Push Docker Images / detect-changes (push) Successful in 20s
Build and Push Docker Images / build-auth-api (push) Successful in 2m2s
Build and Push Docker Images / build-employee-api (push) Successful in 2m2s
Build and Push Docker Images / build-transit-api (push) Successful in 2m8s
Build and Push Docker Images / build-error-log-api (push) Successful in 1m58s
Build and Push Docker Images / build-monitoring-ui (push) Has been cancelled
Build and Push Docker Images / build-admin-ui (push) Has been cancelled
Build and Push Docker Images / deploy-test-node (push) Has been cancelled

This commit is contained in:
Sven laptop
2026-09-24 20:20:43 +02:00
parent 7d55580d87
commit e169e37b5e
17 changed files with 270 additions and 50 deletions
+7 -7
View File
@@ -3,15 +3,15 @@
The schedule manager uses the weekly template model. Administrators create a
departure for a bus line in one of three categories: weekdays, Saturday, or
Sunday. The UI creates the corresponding `day_of_week` rows and assigns drivers
through `transit.shifts`, rather than storing a driver on `transit.schedules`.
through `"transit.bus".shifts`, rather than storing a driver on `"transit.bus".schedules`.
The active UI uses these transit API endpoints:
- `GET /admin/weekly-schedules`
- `GET /admin/shift-drivers`
- `POST /admin/weekly-schedules`
- `PUT /admin/weekly-schedules/:scheduleId/shift`
- `DELETE /admin/weekly-schedules/:scheduleId`
- `GET /bus/admin/weekly-schedules`
- `GET /bus/admin/shift-drivers`
- `POST /bus/admin/weekly-schedules`
- `PUT /bus/admin/weekly-schedules/:scheduleId/shift`
- `DELETE /bus/admin/weekly-schedules/:scheduleId`
# Transit Admin Control Center
@@ -142,7 +142,7 @@ When running in Docker, environment variables are injected at runtime via `docke
The app communicates with:
- **Auth API** (/login, /me)
- **Transit API** (/admin/stops, /admin/bus-lines, /admin/fleet/buses)
- **Transit API** (/bus/admin/stops, /bus/admin/bus-lines, /bus/admin/fleet/buses)
- **Error Log API** (/error_log)
All requests include JWT Bearer token for authentication.
+19 -19
View File
@@ -8,20 +8,20 @@ The Transit API now includes a comprehensive schedule management system with bot
The active admin UI uses weekly schedule templates. `dayOfWeek` follows the
JavaScript/PostgreSQL convention: `0` Sunday, `1` through `5` weekdays, and `6`
Saturday. Driver assignment is stored in `transit.shifts` and references
Saturday. Driver assignment is stored in `"transit.bus".shifts` and references
`workers.users(id)`.
#### Get weekly schedules
```
GET /admin/weekly-schedules
GET /bus/admin/weekly-schedules
Response: { schedules: [...] }
```
#### Get shift drivers
```
GET /admin/shift-drivers
GET /bus/admin/shift-drivers
Response: { drivers: [{ id, name }] }
```
@@ -32,7 +32,7 @@ Response: { drivers: [{ id, name }] }
#### Create multiple departures
```text
POST /admin/weekly-schedules/bulk
POST /bus/admin/weekly-schedules/bulk
Body: {
busLineId: 1,
dayOfWeeks: [1, 2, 3, 4, 5],
@@ -43,7 +43,7 @@ Body: {
The API creates one schedule row for every day/time combination and derives the
end time from the bus line's configured duration.
POST /admin/weekly-schedules
POST /bus/admin/weekly-schedules
Body: {
busLineId: 1,
dayOfWeek: 1,
@@ -58,7 +58,7 @@ driverId: 12
```
PUT /admin/weekly-schedules/:scheduleId/shift
PUT /bus/admin/weekly-schedules/:scheduleId/shift
Body: { driverId: 12 }
```
@@ -73,7 +73,7 @@ historical per-week assignment. Add `week_start` to support that later.
```
GET /admin/schedules
GET /bus/admin/schedules
Response: { schedules: [...] }
```
@@ -82,7 +82,7 @@ Response: { schedules: [...] }
```
POST /admin/schedules
POST /bus/admin/schedules
Body: {
busLineId: number,
busId: number,
@@ -98,7 +98,7 @@ Response: { schedule: {...} }
```
DELETE /admin/schedules/:scheduleId
DELETE /bus/admin/schedules/:scheduleId
Response: { success: true, schedule: {...} }
```
@@ -109,7 +109,7 @@ Response: { success: true, schedule: {...} }
```
GET /schedules?date=2026-05-06&lineId=1
GET /bus/schedules?date=2026-05-06&lineId=1
Query params:
- date: YYYY-MM-DD (optional)
@@ -122,7 +122,7 @@ Query params:
```
GET /schedules/:scheduleId
GET /bus/schedules/:scheduleId
Response: { schedule: {...} }
```
@@ -131,7 +131,7 @@ Response: { schedule: {...} }
```
GET /schedules/:scheduleId/stops
GET /bus/schedules/:scheduleId/stops
Response: { stops: [...] }
Shows all stops on the bus line with order, location, and ETA.
@@ -196,9 +196,9 @@ ADMIN_USER_CODES=42 DEV_MOCK=1 JWT_SECRET=devsecret npm --prefix ./transit_api s
## Database Schema (Production)
```sql
CREATE TABLE transit.schedules (
CREATE TABLE "transit.bus".schedules (
id BIGINT PRIMARY KEY,
bus_line_id BIGINT REFERENCES transit.bus_lines(id),
bus_line_id BIGINT REFERENCES "transit.bus".bus_lines(id),
start_time TIME,
end_time TIME,
status VARCHAR(20) DEFAULT 'planned',
@@ -207,9 +207,9 @@ CREATE TABLE transit.schedules (
updated_at TIMESTAMP DEFAULT NOW()
);
CREATE TABLE transit.shifts (
CREATE TABLE "transit.bus".shifts (
id BIGINT PRIMARY KEY,
schedule_id BIGINT REFERENCES transit.schedules(id) ON DELETE CASCADE,
schedule_id BIGINT REFERENCES "transit.bus".schedules(id) ON DELETE CASCADE,
driver_id BIGINT REFERENCES workers.users(id)
);
```
@@ -246,7 +246,7 @@ The schedule manager uses:
### Create a schedule (Admin)
```bash
curl -X POST https://transit.xtransit.testinstance.nl/admin/schedules \
curl -X POST https://transit.xtransit.testinstance.nl/bus/admin/schedules \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
@@ -261,13 +261,13 @@ curl -X POST https://transit.xtransit.testinstance.nl/admin/schedules \
### Get today's schedules (Public)
```bash
curl https://transit.xtransit.testinstance.nl/schedules?date=$(date +%Y-%m-%d)
curl https://transit.xtransit.testinstance.nl/bus/schedules?date=$(date +%Y-%m-%d)
```
### Get schedules for specific line (Public)
```bash
curl https://transit.xtransit.testinstance.nl/schedules?lineId=3
curl https://transit.xtransit.testinstance.nl/bus/schedules?lineId=3
```
## Future Enhancements
@@ -383,15 +383,15 @@ if (DEV_MOCK) {
## Production Database Support
Voor productie (niet DEV_MOCK) moeten deze kolommen bestaan in `transit.schedules`:
Voor productie (niet DEV_MOCK) moeten deze kolommen bestaan in `"transit.bus".schedules`:
```sql
ALTER TABLE transit.schedules ADD COLUMN IF NOT EXISTS weekdays JSONB;
ALTER TABLE "transit.bus".schedules ADD COLUMN IF NOT EXISTS weekdays JSONB;
```
Queries gebruiken:
```sql
SELECT ... FROM transit.schedules WHERE weekdays::text LIKE '1' -- for Maandag
SELECT ... FROM "transit.bus".schedules WHERE weekdays::text LIKE '1' -- for Maandag
```
---
@@ -443,7 +443,7 @@ SELECT ... FROM transit.schedules WHERE weekdays::text LIKE '1' -- for Maandag
2. **Tijdzones**: Alles in UTC
- Toekomst: Voeg timezone support toe voor meerdere regio's
3. **Database Migrations**: `transit.schedules` moet `weekdays` kolom hebben
3. **Database Migrations**: `"transit.bus".schedules` moet `weekdays` kolom hebben
- Status: Handmatig SQL nodig voor productie
4. **Bestuurders Toewijzing**: Geen conflict detectie