-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(frontend): Integrate
axios
for client requests (#5255)
- Loading branch information
Showing
27 changed files
with
467 additions
and
516 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,21 @@ | ||
import axios from "axios"; | ||
|
||
const github = axios.create({ | ||
baseURL: "https://api.github.com", | ||
headers: { | ||
Accept: "application/vnd.github+json", | ||
"X-GitHub-Api-Version": "2022-11-28", | ||
}, | ||
}); | ||
|
||
const setAuthTokenHeader = (token: string) => { | ||
github.defaults.headers.common.Authorization = `Bearer ${token}`; | ||
}; | ||
|
||
const removeAuthTokenHeader = () => { | ||
if (github.defaults.headers.common.Authorization) { | ||
delete github.defaults.headers.common.Authorization; | ||
} | ||
}; | ||
|
||
export { github, setAuthTokenHeader, removeAuthTokenHeader }; |
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,30 @@ | ||
import { openHands } from "./open-hands-axios"; | ||
|
||
class InvariantService { | ||
static async getPolicy() { | ||
const { data } = await openHands.get("/api/security/policy"); | ||
return data.policy; | ||
} | ||
|
||
static async getRiskSeverity() { | ||
const { data } = await openHands.get("/api/security/settings"); | ||
return data.RISK_SEVERITY; | ||
} | ||
|
||
static async getTraces() { | ||
const { data } = await openHands.get("/api/security/export-trace"); | ||
return data; | ||
} | ||
|
||
static async updatePolicy(policy: string) { | ||
await openHands.post("/api/security/policy", { policy }); | ||
} | ||
|
||
static async updateRiskSeverity(riskSeverity: number) { | ||
await openHands.post("/api/security/settings", { | ||
RISK_SEVERITY: riskSeverity, | ||
}); | ||
} | ||
} | ||
|
||
export default InvariantService; |
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,23 @@ | ||
import axios from "axios"; | ||
|
||
export const openHands = axios.create(); | ||
|
||
export const setAuthTokenHeader = (token: string) => { | ||
openHands.defaults.headers.common.Authorization = `Bearer ${token}`; | ||
}; | ||
|
||
export const setGitHubTokenHeader = (token: string) => { | ||
openHands.defaults.headers.common["X-GitHub-Token"] = token; | ||
}; | ||
|
||
export const removeAuthTokenHeader = () => { | ||
if (openHands.defaults.headers.common.Authorization) { | ||
delete openHands.defaults.headers.common.Authorization; | ||
} | ||
}; | ||
|
||
export const removeGitHubTokenHeader = () => { | ||
if (openHands.defaults.headers.common["X-GitHub-Token"]) { | ||
delete openHands.defaults.headers.common["X-GitHub-Token"]; | ||
} | ||
}; |
Oops, something went wrong.