-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add mm portfolio api with env based feature flag
- Loading branch information
Devin Stewart
authored and
Devin Stewart
committed
Dec 13, 2024
1 parent
715476c
commit ae3680f
Showing
4 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import AppConstants from '../../core/AppConstants'; | ||
|
||
export function isMMPortfolioAPIEnabled() { | ||
return process.env.MM_PORTFOLIO_API_ENABLED === 'true'; | ||
} | ||
|
||
export async function getMMPortfolioHealthCheck(): Promise<any> { | ||
Check failure on line 7 in app/lib/ppom/mm-portfolio-api.ts GitHub Actions / scripts (lint)
|
||
return request(""); | ||
Check failure on line 8 in app/lib/ppom/mm-portfolio-api.ts GitHub Actions / scripts (lint)
|
||
} | ||
|
||
async function request(endpoint: string, options?: RequestInit) { | ||
const url = getUrl(endpoint); | ||
|
||
const response = await fetch(url, options); | ||
|
||
if (!response.ok) { | ||
throw new Error( | ||
`MM Portfolio API request failed with status: ${response.status}`, | ||
); | ||
} | ||
|
||
return response.json(); | ||
} | ||
|
||
function getUrl(endpoint: string) { | ||
const host = AppConstants.PORTFOLIO_API.URL; | ||
|
||
if (!host) { | ||
throw new Error('MM Portfolio API URL is not set'); | ||
} | ||
|
||
return `${host}/${endpoint}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters