Due to the failure in the last few days, I have reintegrated the old API, which can be activated via the follwoing environment variable:
NEXT_PUBLIC_LEGACY_MODE=true
@M4GNV5 has already expressed very justified concerns about the legal situation and the bundle size. Nevertheless, we should check this option, especially since we have relied on the old API in the last few days and this option should only be an alternative for emergencies.
Regarding the library, only a simple error message is shown, as this is not accessible via the old API.
π€ Generated by Copilot at 952aa47
Summary
ππ οΈπ
This pull request adds a fallback mode to the app that uses the old THI API when the new one is unavailable. It modifies several modules in the backend-utils, backend, and pages folders to switch between the APIs depending on a LEGACY_MODE constant. It also creates new modules in the backend-legacy-utils folder to handle the old THI API data. Additionally, it adds a new dependency postgres-array and a new translation key legacyWarning for the library page.
When the new API fails, we don't give upWe switch to the LegacyAPI and load the dataWe use the backend-legacy-utils to parse and format
_We rock the fallback mode with the LEGACY_MODE flag_
Define utility functions for fetching and parsing data from the old THI API in calendar-legacy-utils.js, grades-legacy-utils.js, rooms-legacy-utils.js, and timetable-legacy-utils.js (link, link, link)
Import the LegacyAPI module from the backend-legacy-utils folder to access the old THI API endpoint (link, link, link, link)
Import the utility functions from the backend-legacy-utils folder to use them in the backend-utils folder (link, link, link, link)
Add conditional statements to the backend-utils functions that switch between the new and old THI API depending on the LEGACY_MODE constant (link, link, link, link, link)
Export some constants and functions from the anonymous-api.js and authenticated-api.js modules that are used by the anonymous-legacy-api.js and authenticated-legacy-api.js modules (link, link, link)
Define classes LegacyAnonymousAPIClient and LegacyAuthenticatedAPIClient that extend the AnonymousAPIClient and AuthenticatedAPIClient classes and override the request method to use the old THI API endpoint (link, link)
Import the LegacyAPI module from the anonymous-legacy-api folder and define a LEGACY_MODE constant in the thi-session-handler.js module (link, link)
Replace the API client with the api variable in the thi-session-handler.js module that switches between the new and old THI API depending on the LEGACY_MODE constant (link, link, link, link)
Define a LEGACY_MODE constant in the lecturers.jsx, library.jsx, personal.jsx, and rooms/list.jsx pages that indicates whether the fallback mode is enabled or not (link, link, link, link)
Add conditional statements to the load functions in the lecturers.jsx, library.jsx, personal.jsx, and rooms/list.jsx pages that switch between the new and old THI API depending on the LEGACY_MODE constant (link, link, link, link, link)
Extract the main content of the library.jsx page into a separate component LibraryAppBody and add another component LegacyWarning that displays a warning message when the fallback mode is enabled (link, link)
Add a new translation key legacyWarning to the German locale file for the library page that provides a localized message for the warning (link)
Add the postgres-array dependency to the package.json and package-lock.json files that is used by the calendar-legacy-utils.js module to parse the postgres array syntax returned by the old THI API (link, link, link)
Export some functions from the rooms-utils.js module that are used by the rooms-legacy-utils.js module to avoid code duplication and improve modularity (link, link, link)
Closes #335
Due to the failure in the last few days, I have reintegrated the old API, which can be activated via the follwoing environment variable:
@M4GNV5 has already expressed very justified concerns about the legal situation and the bundle size. Nevertheless, we should check this option, especially since we have relied on the old API in the last few days and this option should only be an alternative for emergencies.
Regarding the library, only a simple error message is shown, as this is not accessible via the old API.
π€ Generated by Copilot at 952aa47
Summary
ππ οΈπ
This pull request adds a fallback mode to the app that uses the old THI API when the new one is unavailable. It modifies several modules in the
backend-utils
,backend
, andpages
folders to switch between the APIs depending on aLEGACY_MODE
constant. It also creates new modules in thebackend-legacy-utils
folder to handle the old THI API data. Additionally, it adds a new dependencypostgres-array
and a new translation keylegacyWarning
for the library page.Walkthrough
calendar-legacy-utils.js
,grades-legacy-utils.js
,rooms-legacy-utils.js
, andtimetable-legacy-utils.js
(link, link, link)LegacyAPI
module from thebackend-legacy-utils
folder to access the old THI API endpoint (link, link, link, link)backend-legacy-utils
folder to use them in thebackend-utils
folder (link, link, link, link)backend-utils
functions that switch between the new and old THI API depending on theLEGACY_MODE
constant (link, link, link, link, link)anonymous-api.js
andauthenticated-api.js
modules that are used by theanonymous-legacy-api.js
andauthenticated-legacy-api.js
modules (link, link, link)LegacyAnonymousAPIClient
andLegacyAuthenticatedAPIClient
that extend theAnonymousAPIClient
andAuthenticatedAPIClient
classes and override therequest
method to use the old THI API endpoint (link, link)LegacyAPI
module from theanonymous-legacy-api
folder and define aLEGACY_MODE
constant in thethi-session-handler.js
module (link, link)API
client with theapi
variable in thethi-session-handler.js
module that switches between the new and old THI API depending on theLEGACY_MODE
constant (link, link, link, link)LEGACY_MODE
constant in thelecturers.jsx
,library.jsx
,personal.jsx
, androoms/list.jsx
pages that indicates whether the fallback mode is enabled or not (link, link, link, link)load
functions in thelecturers.jsx
,library.jsx
,personal.jsx
, androoms/list.jsx
pages that switch between the new and old THI API depending on theLEGACY_MODE
constant (link, link, link, link, link)library.jsx
page into a separate componentLibraryAppBody
and add another componentLegacyWarning
that displays a warning message when the fallback mode is enabled (link, link)legacyWarning
to the German locale file for the library page that provides a localized message for the warning (link)postgres-array
dependency to thepackage.json
andpackage-lock.json
files that is used by thecalendar-legacy-utils.js
module to parse the postgres array syntax returned by the old THI API (link, link, link)rooms-utils.js
module that are used by therooms-legacy-utils.js
module to avoid code duplication and improve modularity (link, link, link)