forked from nexodus-io/nexodus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add feature flags for site and device apis
Signed-off-by: Hiram Chirino <[email protected]>
- Loading branch information
Showing
7 changed files
with
106 additions
and
57 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
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,40 @@ | ||
import { goOidcAgentAuthProvider } from "./providers/AuthProvider"; | ||
import simpleRestProvider from "ra-data-simple-rest"; | ||
import { fetchUtils } from "react-admin"; | ||
|
||
const fetchJson = (url: string, options: any = {}) => { | ||
// Includes the encrypted session cookie in requests to the API | ||
options.credentials = "include"; | ||
// some of the PUT api calls should be converted to PATCH | ||
if (options.method === "PUT") { | ||
if ( | ||
url.startsWith(`${backend}/api/reg-keys/`) || | ||
url.startsWith(`${backend}/api/devices/`) || | ||
url.startsWith(`${backend}/api/security-groups/`) || | ||
url.startsWith(`${backend}/api/vpcs/`) | ||
) { | ||
options.method = "PATCH"; | ||
} | ||
} | ||
return fetchUtils.fetchJson(url, options); | ||
}; | ||
const backend = `${window.location.protocol}//api.${window.location.host}`; | ||
export const authProvider = goOidcAgentAuthProvider(backend); | ||
const baseDataProvider = simpleRestProvider( | ||
`${backend}/api`, | ||
fetchJson, | ||
"X-Total-Count", | ||
); | ||
export const dataProvider = { | ||
...baseDataProvider, | ||
getFlag: (name: string) => { | ||
return fetchJson(`${backend}/api/fflags/${name}`).then( | ||
(response) => response, | ||
); | ||
}, | ||
getFlags: async () => { | ||
return (await fetchJson(`${backend}/api/fflags`)).json as { | ||
[index: string]: boolean; | ||
}; | ||
}, | ||
}; |
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