updated transit api
Build and Push Docker Images / detect-changes (push) Successful in 10s
Build and Push Docker Images / build-auth-api (push) Successful in 1m0s
Build and Push Docker Images / build-employee-api (push) Successful in 1m3s
Build and Push Docker Images / build-transit-api (push) Successful in 59s
Build and Push Docker Images / build-error-log-api (push) Successful in 1m9s
Build and Push Docker Images / build-admin-ui (push) Successful in 1m20s
Build and Push Docker Images / deploy-test-node (push) Successful in 4s

This commit is contained in:
Sven laptop
2026-09-18 20:08:10 +02:00
parent 1154d1d658
commit f935bbeb8c
9 changed files with 144 additions and 13 deletions
+30 -6
View File
@@ -25,7 +25,7 @@
#define ID_ROUTES_LABEL 116
#define MAX_BUF 65535
#define API_HOST "auth.xtransit.testinstance.nl"
#define API_HOST "192.168.68.66"
#define AUTH_PORT 5000
#define TRANSIT_PORT 5001
@@ -52,6 +52,30 @@ static void SetOutputText(HWND hwnd, const char *text)
SetWindowTextA(GetDlgItem(hwnd, ID_OUTPUT), text);
}
static void LogDiagnostic(const char *stage, DWORD code)
{
char path[MAX_PATH];
char *separator;
FILE *file;
GetModuleFileNameA(NULL, path, sizeof(path));
separator = strrchr(path, '\\');
if (separator) {
*(separator + 1) = '\0';
} else {
snprintf(path, sizeof(path), ".\\");
}
strncat(path, "driver_xp.log", sizeof(path) - strlen(path) - 1);
file = fopen(path, "a");
if (!file) {
return;
}
fprintf(file, "%s: %lu\r\n", stage, (unsigned long)code);
fclose(file);
}
static void ShowControl(HWND hwnd, int id, int visible)
{
ShowWindow(GetDlgItem(hwnd, id), visible ? SW_SHOW : SW_HIDE);
@@ -516,8 +540,7 @@ static void ExtractTokenFromJson(const char *json, char *outToken, size_t outSiz
static void HttpErrorMessage(const char *context, DWORD error)
{
(void)context;
(void)error;
LogDiagnostic(context, error);
}
static int HttpRequestText(const char *method,
@@ -690,6 +713,7 @@ static int HttpRequestText(const char *method,
}
if (status >= 400) {
LogDiagnostic("HTTP response status", status);
snprintf(response, responseSize, "HTTP error %lu", status);
ok = 0;
goto cleanup;
@@ -749,7 +773,7 @@ static void PerformLogin(HWND hwnd, APPSTATE *state)
userCode, password);
SetStatusText(hwnd, "Logging in...");
if (!HttpRequestText("POST", "https://auth.xtransit.testinstance.nl/login", payload, NULL, response, sizeof(response))) {
if (!HttpRequestText("POST", "http://192.168.68.66:5000/login", payload, NULL, response, sizeof(response))) {
SetOutputText(hwnd, "Driver service unreachable. Please try again.");
SetStatusText(hwnd, "Login failed");
return;
@@ -786,7 +810,7 @@ static void PerformRefresh(HWND hwnd, APPSTATE *state)
if (date[0] == '\0') {
snprintf(date, sizeof(date), "2026-09-17");
}
snprintf(scheduleUrl, sizeof(scheduleUrl), "https://transit.xtransit.testinstance.nl/driver/schedules/daily?date=%s", date);
snprintf(scheduleUrl, sizeof(scheduleUrl), "http://192.168.68.66:5001/driver/schedules/daily?date=%s", date);
SetStatusText(hwnd, "Loading schedule...");
if (!HttpRequestText("GET", scheduleUrl, NULL, authHeader, response, sizeof(response))) {
@@ -827,7 +851,7 @@ static void PerformLoadStops(HWND hwnd, APPSTATE *state)
}
snprintf(authHeader, sizeof(authHeader), "Authorization: Bearer %s\r\n", state->token);
snprintf(stopsUrl, sizeof(stopsUrl), "https://transit.xtransit.testinstance.nl/bus-lines/%d/stops", lineId);
snprintf(stopsUrl, sizeof(stopsUrl), "http://192.168.68.66:5001/bus-lines/%d/stops", lineId);
SetStatusText(hwnd, "Loading stop details...");
if (!HttpRequestText("GET", stopsUrl, NULL, authHeader, response, sizeof(response))) {