-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add command for calling /health/get_health, improve code readability * Fix get-health command typo causing full command cli input not to work * Rename makeSeamApiRequest fn
- Loading branch information
1 parent
71a208e
commit 11def2e
Showing
4 changed files
with
75 additions
and
53 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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import type { AxiosResponse } from "axios" | ||
import chalk from "chalk" | ||
import { getSeam } from "../get-seam" | ||
|
||
export const RequestSeamApi = async ({ | ||
path, | ||
params, | ||
}: { | ||
path: string | ||
params: Record<string, any> | ||
}) => { | ||
const seam = await getSeam() | ||
|
||
logRequest(path, params) | ||
|
||
const response = await seam.client.post(path, params, { | ||
validateStatus: () => true, | ||
}) | ||
|
||
logResponse(response) | ||
|
||
return response | ||
} | ||
|
||
const logResponse = (response: AxiosResponse) => { | ||
if (response.status >= 400) { | ||
console.log(chalk.red(`\n\n[${response.status}]\n`)) | ||
} else { | ||
console.log(chalk.green(`\n\n[${response.status}]`)) | ||
} | ||
console.dir(response.data, { depth: null }) | ||
console.log("\n") | ||
} | ||
|
||
const logRequest = (apiPath: string, params: Record<string, any>) => { | ||
console.log(`\n\n${chalk.green(apiPath)}`) | ||
console.log(`Request Params:`) | ||
console.log(params) | ||
} | ||
|
||
export default RequestSeamApi |