-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
7 changed files
with
166 additions
and
106 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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import express from "express"; | ||
import {listingsLatest} from "../proxy/CoinMarketCap.ts"; | ||
import { listingsLatest, detail } from "../proxy/CoinMarketCap.ts"; | ||
|
||
const coinMarketCapRoutes = express(); | ||
|
||
coinMarketCapRoutes.get("/v1/cryptocurrency/listings/latest", listingsLatest); | ||
coinMarketCapRoutes.get("/v2/cryptocurrency/info", detail); | ||
|
||
export default coinMarketCapRoutes; |
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 |
---|---|---|
@@ -1,18 +1,34 @@ | ||
import {get} from "@/server/HttpClient"; | ||
import type {CryptoCurrency} from "@/types/CoinMarketCap/CryptoCurrency"; | ||
import { get } from "@/server/HttpClient"; | ||
import type { CryptoCurrency } from "@/types/CoinMarketCap/CryptoCurrency"; | ||
|
||
export async function listBitcoin(limit = 12, start = 1): Promise<CryptoCurrency[] | undefined> { | ||
try { | ||
const response = await get( | ||
`/v1/cryptocurrency/listings/latest?limit=${limit}&start=${start}`, | ||
); | ||
try { | ||
const response = await get( | ||
`/v1/cryptocurrency/listings/latest?limit=${limit}&start=${start}`, | ||
); | ||
|
||
if (!response.ok) throw new Error(await response.json()); | ||
if (!response.ok) throw new Error(await response.json()); | ||
|
||
const jsonData: CryptoCurrency[] = await response.json(); | ||
const jsonData: CryptoCurrency[] = await response.json(); | ||
|
||
return jsonData; | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
return jsonData; | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
|
||
export async function detailBitcoin(slug: string): Promise<CryptoCurrency | undefined> { | ||
try { | ||
const response = await get( | ||
`/v2/cryptocurrency/info?slug=${slug}`, | ||
); | ||
|
||
if (!response.ok) throw new Error(await response.json()); | ||
|
||
const jsonData: CryptoCurrency = await response.json(); | ||
|
||
return jsonData; | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} |
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