-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d57f499
commit a025b71
Showing
7 changed files
with
54 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,3 @@ | ||
import type { EndpointTypes } from "../../shared/routes"; | ||
import type { ErrorShape } from "../../shared/errors"; | ||
import type { AxiosError, AxiosResponse } from "axios"; | ||
import axios from "axios"; | ||
import type { Routes } from "../../shared/routes"; | ||
|
||
export type { | ||
RelationFilter, | ||
RelationFilterType, | ||
Pagination, | ||
UtxoPointer, | ||
} from "../../shared/models/common"; | ||
export * from "../../shared/routes"; | ||
export * from "../../shared/errors"; | ||
export type { EndpointTypes } from "../../shared/routes"; | ||
export type { ErrorShape } from "../../shared/errors"; | ||
|
||
export async function query<T extends Routes>( | ||
urlBase: string, | ||
route: T, | ||
data: EndpointTypes[T]["input"] | ||
): Promise<EndpointTypes[T]["response"]> { | ||
const result = await axios.post< | ||
EndpointTypes[T]["response"], | ||
AxiosResponse<EndpointTypes[T]["response"]>, | ||
EndpointTypes[T]["input"] | ||
>(`${urlBase}/${route}`, data); | ||
return result.data; | ||
} | ||
|
||
export function getErrorResponse( | ||
err: AxiosError<ErrorShape, unknown> | ||
): AxiosResponse<ErrorShape, unknown> { | ||
if (err.response == null) throw new Error(`Unexpected null response`); | ||
return err.response; | ||
} | ||
export * from './template'; | ||
export * from './paginated'; | ||
export * from "../../shared"; |
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,25 @@ | ||
import type { EndpointTypes } from "../../shared/routes"; | ||
import type { ErrorShape } from "../../shared/errors"; | ||
import type { AxiosError, AxiosResponse } from "axios"; | ||
import axios from "axios"; | ||
import type { Routes } from "../../shared/routes"; | ||
|
||
export async function query<T extends Routes>( | ||
urlBase: string, | ||
route: T, | ||
data: EndpointTypes[T]["input"] | ||
): Promise<EndpointTypes[T]["response"]> { | ||
const result = await axios.post< | ||
EndpointTypes[T]["response"], | ||
AxiosResponse<EndpointTypes[T]["response"]>, | ||
EndpointTypes[T]["input"] | ||
>(`${urlBase}/${route}`, data); | ||
return result.data; | ||
} | ||
|
||
export function getErrorResponse( | ||
err: AxiosError<ErrorShape, unknown> | ||
): AxiosResponse<ErrorShape, unknown> { | ||
if (err.response == null) throw new Error(`Unexpected null response`); | ||
return err.response; | ||
} |
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,4 @@ | ||
export * from './constants'; | ||
export * from './errors'; | ||
export * from './routes'; | ||
export * from './models'; |
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,17 @@ | ||
export * from './Address'; | ||
export * from './AddressUsed'; | ||
export * from './AssetUtxos'; | ||
export * from './BlockLatest'; | ||
export * from './common'; | ||
export * from './CredentialAddress'; | ||
export * from './DelegationForAddress'; | ||
export * from './DelegationForPool'; | ||
export * from './DexLastPrice'; | ||
export * from './DexMeanPrice'; | ||
export * from './DexSwap'; | ||
export * from './MintBurn'; | ||
export * from './PolicyIdAssetMap'; | ||
export * from './Pool'; | ||
export * from './ProjectedNftRange'; | ||
export * from './TransactionHistory'; | ||
export * from './TransactionOutput'; |