///
This section provides a detailed reference for the core service modules within the TRMNL Salah Prayer Times Plugin backend. These services encapsulate business logic, interact with external APIs (Alad
88 views
~88 views from guests
Guest views are estimated from total page views. These include anonymous visitors and users who weren't logged in when they viewed the page.
This section provides a detailed reference for the core service modules within the TRMNL Salah Prayer Times Plugin backend. These services encapsulate business logic, interact with external APIs (Aladhan, TRMNL OAuth), and manage database operations (Supabase), providing reusable functionalities for various handlers.
This module is responsible for fetching and calculating Islamic prayer times, including handling timezones and deriving related information like the next prayer and Hijri date.
calculatePrayerTimes(params: PrayerTimesCalculationParams): Promise<{ rawData: PrayerTimesByCityResponse['data']; prayerTimes: Record<string, string>; prayerTimesObjects: PrayerTimes; nextPrayer: string; nextPrayerTime: Date; timeUntilNextPrayer: { hours: number; minutes: number; total_minutes: number; }; hijriDateFormatted: string; currentTime: string; isTomorrow: boolean; }>
// Calculates prayer times and related information, including next prayer and Hijri date.getPrayerTimesByCity({ city, country, method = 2, asr_method = 'standard', maghrib_offset = 0 }: GetPrayerTimesByCityRequest): Promise<PrayerTimesByCityResponse>
// Fetches prayer times from the Aladhan API for a specified city and country.This module manages the persistence and retrieval of user-specific prayer time preferences and configurations in the Supabase database.
deleteUserSettings(uuid: string): Promise<any>
// Deletes user settings from the database based on a given UUID.getUserSettings(uuid: string): Promise<{ data: Tables<'user_settings'> | null; error: PostgrestError | null }>
// Retrieves user settings from the database for a given UUID.saveUserSettings(settings: UserSettingsInsert): Promise<any>
// Saves new or updates existing user settings in the database.This module handles interactions with the TRMNL OAuth API, specifically for exchanging authorization codes for access tokens during the plugin installation process.
exchangeCodeForToken(code: string): Promise<TrmnlOAuthTokenResponse>
// Exchanges an authorization code obtained from TRMNL for an access token.