All files / apps/host/src/services mainHttpClient.ts

100% Statements 7/7
100% Branches 8/8
100% Functions 1/1
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32            5x 4x 4x         5x         5x         5x       5x        
import { getAuth, getIdToken } from '@react-native-firebase/auth';
 
import { HttpClientLive, HttpService } from '@repo/services/httpClients';
 
import { BASE_URL_API, E2E_SERVER_URL, SPACE_URL_API } from '@/constants/apis';
 
export const getAccessToken = async () => {
  const user = getAuth().currentUser;
  return user ? await getIdToken(user) : null;
};
 
// --- Legacy Promise-based instances ---
 
export const https = new HttpService(BASE_URL_API || '', {
  getToken: getAccessToken,
  auth: { type: 'bearer' },
});
 
export const spaceHttps = new HttpService(SPACE_URL_API || '', {
  getToken: getAccessToken,
  auth: { type: 'bearer' },
});
 
export const e2eHttps = new HttpService(E2E_SERVER_URL);
 
// --- Effect Layers ---
 
export const MainHttpClient = HttpClientLive(BASE_URL_API || '', {
  getToken: getAccessToken,
  auth: { type: 'bearer' },
});