feat: Add debug logging for LNBits API and configuration
- Introduce console logging for LNBits API requests, providing visibility into endpoint calls and full URLs. - Add debug logging for configuration loading, displaying key configuration values while masking sensitive information. - Enhance overall debugging capabilities to facilitate easier troubleshooting and monitoring of API interactions.
This commit is contained in:
parent
7d7bee8e77
commit
59e0496ad9
3 changed files with 21 additions and 5 deletions
|
|
@ -75,6 +75,8 @@ class LnbitsAPI {
|
|||
options: RequestInit = {}
|
||||
): Promise<T> {
|
||||
const url = getApiUrl(endpoint)
|
||||
console.log('🔧 LNBits API request:', { endpoint, fullUrl: url })
|
||||
|
||||
const headers: HeadersInit = {
|
||||
'Content-Type': 'application/json',
|
||||
...options.headers,
|
||||
|
|
|
|||
|
|
@ -77,6 +77,13 @@ export const config: AppConfig = {
|
|||
}
|
||||
} as const
|
||||
|
||||
// Debug logging
|
||||
console.log('🔧 Config loaded:', {
|
||||
VITE_LNBITS_BASE_URL: import.meta.env.VITE_LNBITS_BASE_URL,
|
||||
apiBaseUrl: config.api.baseUrl,
|
||||
apiKey: config.api.key ? '***' : 'not set'
|
||||
})
|
||||
|
||||
// Utility functions for common config operations
|
||||
export const configUtils = {
|
||||
isAdminPubkey: (pubkey: string): boolean => {
|
||||
|
|
|
|||
|
|
@ -3,20 +3,27 @@ export const LNBITS_CONFIG = {
|
|||
// Base URL for the LNBits API
|
||||
// This should point to your LNBits instance
|
||||
API_BASE_URL: `${import.meta.env.VITE_LNBITS_BASE_URL || ''}/api/v1`,
|
||||
|
||||
|
||||
// Whether to enable debug logging
|
||||
DEBUG: import.meta.env.VITE_LNBITS_DEBUG === 'true',
|
||||
|
||||
|
||||
// Timeout for API requests (in milliseconds)
|
||||
REQUEST_TIMEOUT: 10000,
|
||||
|
||||
|
||||
// Auth token storage key
|
||||
AUTH_TOKEN_KEY: 'lnbits_access_token',
|
||||
|
||||
|
||||
// User storage key
|
||||
USER_STORAGE_KEY: 'lnbits_user_data'
|
||||
}
|
||||
|
||||
// Debug logging
|
||||
console.log('🔧 LNBits Config loaded:', {
|
||||
VITE_LNBITS_BASE_URL: import.meta.env.VITE_LNBITS_BASE_URL,
|
||||
API_BASE_URL: LNBITS_CONFIG.API_BASE_URL,
|
||||
DEBUG: LNBITS_CONFIG.DEBUG
|
||||
})
|
||||
|
||||
// Helper function to get the full API URL
|
||||
export function getApiUrl(endpoint: string): string {
|
||||
return `${LNBITS_CONFIG.API_BASE_URL}${endpoint}`
|
||||
|
|
@ -35,4 +42,4 @@ export function setAuthToken(token: string): void {
|
|||
// Helper function to remove auth token from storage
|
||||
export function removeAuthToken(): void {
|
||||
localStorage.removeItem(LNBITS_CONFIG.AUTH_TOKEN_KEY)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue