From f38c0dc28075a6285eb4451606f8ebf414adf02d Mon Sep 17 00:00:00 2001 From: bush1D3v Date: Sun, 29 Sep 2024 15:28:28 -0300 Subject: [PATCH] bomb commit --- api/src/config/cors.ts | 24 +- api/src/helpers/HttpClient.ts | 32 +- api/src/proxy/CoinMarketCap.ts | 40 +- api/src/routes/CoinMarketCap.ts | 2 +- api/src/types/CoinMarketCap/CryptoCurrency.ts | 44 +- api/src/types/CoinMarketCap/Quote.ts | 28 +- app/components/EntityCard.vue | 54 ++ app/components/LineCryptoChat.vue | 524 +++++++++--------- app/components/ui/card/Card.vue | 8 +- app/components/ui/card/CardContent.vue | 8 +- app/components/ui/card/CardDescription.vue | 8 +- app/components/ui/card/CardFooter.vue | 8 +- app/components/ui/card/CardHeader.vue | 8 +- app/components/ui/card/CardTitle.vue | 8 +- app/components/ui/card/index.ts | 12 +- app/components/ui/chart-line/LineChart.vue | 89 +-- app/components/ui/chart-line/index.ts | 122 ++-- app/components/ui/chart/ChartCrosshair.vue | 62 ++- app/components/ui/chart/ChartLegend.vue | 67 ++- .../ui/chart/ChartSingleTooltip.vue | 103 ++-- app/components/ui/chart/ChartTooltip.vue | 16 +- app/components/ui/chart/index.ts | 30 +- app/components/ui/chart/interface.ts | 120 ++-- .../dropdown-menu/DropdownMenuRadioItem.vue | 22 +- app/server/HttpClient.ts | 32 +- app/services/CoinMarketCap.ts | 24 +- app/stores/useCryptoCurrencyStore.ts | 49 +- app/types/CoinMarketCap/CryptoCurrency.ts | 44 +- app/types/CoinMarketCap/Quote.ts | 28 +- app/utils/numberFormatter.ts | 38 +- app/views/CookiePolicy.vue | 2 +- app/views/CryptoDetail.vue | 12 +- app/views/Cryptos.vue | 46 +- app/views/PrivacyPolicy.vue | 2 +- package.json | 4 +- 35 files changed, 891 insertions(+), 829 deletions(-) create mode 100644 app/components/EntityCard.vue diff --git a/api/src/config/cors.ts b/api/src/config/cors.ts index b2d7110..d30ec92 100644 --- a/api/src/config/cors.ts +++ b/api/src/config/cors.ts @@ -1,18 +1,18 @@ import cors from "cors"; const corsOptions = { - origin: [ "http://localhost:5173" ], - methods: [ "GET", "POST", "PUT", "PATCH", "DELETE" ], - allowedHeaders: [ - "Content-Type", - "Authorization", - "X-CMC_PRO_API_KEY", - "Accept-Encoding", - "Accept", - "referrer-policy", - ], - credentials: true, - optionsSuccessStatus: 200, + origin: ["http://localhost:5173"], + methods: ["GET", "POST", "PUT", "PATCH", "DELETE"], + allowedHeaders: [ + "Content-Type", + "Authorization", + "X-CMC_PRO_API_KEY", + "Accept-Encoding", + "Accept", + "referrer-policy", + ], + credentials: true, + optionsSuccessStatus: 200, }; export default cors(corsOptions); diff --git a/api/src/helpers/HttpClient.ts b/api/src/helpers/HttpClient.ts index f1b7167..2b760e8 100644 --- a/api/src/helpers/HttpClient.ts +++ b/api/src/helpers/HttpClient.ts @@ -1,42 +1,42 @@ const DEFAULT_HEADERS = { - "Content-Type": "application/json; charset=utf-8", - "Accept": "application/json", + "Content-Type": "application/json; charset=utf-8", + Accept: "application/json", }; type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE"; interface HttpRequestOptions { - method: HttpMethod; - headers?: HeadersInit; - body?: undefined; + method: HttpMethod; + headers?: HeadersInit; + body?: undefined; } async function httpRequest(url: string, options: HttpRequestOptions): Promise { - const headers = { ...DEFAULT_HEADERS, ...options.headers }; + const headers = {...DEFAULT_HEADERS, ...options.headers}; - return await fetch(url, { - method: options.method, - headers: headers, - body: options.body ? JSON.stringify(options.body) : null, - }); + return await fetch(url, { + method: options.method, + headers: headers, + body: options.body ? JSON.stringify(options.body) : null, + }); } export async function get(endpoint: string, headers?: HeadersInit) { - return httpRequest(endpoint, { method: "GET", headers }); + return httpRequest(endpoint, {method: "GET", headers}); } export async function post(endpoint: string, body: undefined, headers?: HeadersInit) { - return httpRequest(endpoint, { method: "POST", headers, body }); + return httpRequest(endpoint, {method: "POST", headers, body}); } export async function put(endpoint: string, body: undefined, headers?: HeadersInit) { - return httpRequest(endpoint, { method: "PUT", headers, body }); + return httpRequest(endpoint, {method: "PUT", headers, body}); } export async function patch(endpoint: string, body: undefined, headers?: HeadersInit) { - return httpRequest(endpoint, { method: "PATCH", headers, body }); + return httpRequest(endpoint, {method: "PATCH", headers, body}); } export async function del(endpoint: string, headers?: HeadersInit) { - return httpRequest(endpoint, { method: "DELETE", headers }); + return httpRequest(endpoint, {method: "DELETE", headers}); } diff --git a/api/src/proxy/CoinMarketCap.ts b/api/src/proxy/CoinMarketCap.ts index cbb1397..db31c06 100644 --- a/api/src/proxy/CoinMarketCap.ts +++ b/api/src/proxy/CoinMarketCap.ts @@ -1,20 +1,20 @@ -import type { Request, Response } from "express"; -import { get } from "../helpers/HttpClient.ts"; +import type {Request, Response} from "express"; +import {get} from "../helpers/HttpClient.ts"; import dotenv from "dotenv"; -import type { CryptoCurrency } from "../types/CoinMarketCap/CryptoCurrency.ts"; +import type {CryptoCurrency} from "../types/CoinMarketCap/CryptoCurrency.ts"; dotenv.config(); const BASE_API_URL = process.env.COINMARKETCAP_HOST as string; const API_KEY = process.env.COINMARKETCAP_KEY as string; const defaultHeaders = { - "Accept-Encoding": "deflate, gzip", - "referrer-policy": "origin-when-cross-origin", - "X-CMC_PRO_API_KEY": API_KEY, + "Accept-Encoding": "deflate, gzip", + "referrer-policy": "origin-when-cross-origin", + "X-CMC_PRO_API_KEY": API_KEY, }; interface ResponseData { - data: CryptoCurrency[]; + data: CryptoCurrency[]; } /** @@ -26,20 +26,20 @@ interface ResponseData { * @throws {Error} If the request to the external API fails */ export async function listingsLatest(req: Request, res: Response): Promise { - const { limit = 12, start = 1 } = req.query; - try { - const response = await get( - `${BASE_API_URL}/v1/cryptocurrency/listings/latest?limit=${limit}&start=${start}`, - defaultHeaders, - ); + const {limit = 12, start = 1} = req.query; + try { + const response = await get( + `${BASE_API_URL}/v1/cryptocurrency/listings/latest?limit=${limit}&start=${start}`, + defaultHeaders, + ); - if (!response.ok) throw new Error(await response.json()); + if (!response.ok) throw new Error(await response.json()); - const data: ResponseData = await response.json(); + const data: ResponseData = await response.json(); - res.json(data.data); - } catch (error) { - console.error(error); - res.status(500).json({ error: error }); - } + res.json(data.data); + } catch (error) { + console.error(error); + res.status(500).json({error: error}); + } } diff --git a/api/src/routes/CoinMarketCap.ts b/api/src/routes/CoinMarketCap.ts index 932798d..86739eb 100644 --- a/api/src/routes/CoinMarketCap.ts +++ b/api/src/routes/CoinMarketCap.ts @@ -1,5 +1,5 @@ import express from "express"; -import { listingsLatest } from "../proxy/CoinMarketCap.ts"; +import {listingsLatest} from "../proxy/CoinMarketCap.ts"; const coinMarketCapRoutes = express(); diff --git a/api/src/types/CoinMarketCap/CryptoCurrency.ts b/api/src/types/CoinMarketCap/CryptoCurrency.ts index 569e475..cca7f10 100644 --- a/api/src/types/CoinMarketCap/CryptoCurrency.ts +++ b/api/src/types/CoinMarketCap/CryptoCurrency.ts @@ -1,28 +1,28 @@ -import type { Platform } from "./Platform"; -import type { Quote } from "./Quote"; +import type {Platform} from "./Platform"; +import type {Quote} from "./Quote"; interface USDQuote { - USD: Quote; + USD: Quote; } export interface CryptoCurrency { - id: number; - name: string; - symbol: string; - slug: string; - num_market_pairs: number; - date_added: Date; - tags: string[]; - max_supply: number; - circulating_supply: number; - total_supply: number; - infinity_supply: boolean; - platform: Platform | null; - cmc_rank: number; - self_reported_circulating_supply: number | null; - self_reported_market_cap: number | null; - tvl_ratio: number | null; - last_updated: Date; - quote: USDQuote; - image: string; + id: number; + name: string; + symbol: string; + slug: string; + num_market_pairs: number; + date_added: Date; + tags: string[]; + max_supply: number; + circulating_supply: number; + total_supply: number; + infinity_supply: boolean; + platform: Platform | null; + cmc_rank: number; + self_reported_circulating_supply: number | null; + self_reported_market_cap: number | null; + tvl_ratio: number | null; + last_updated: Date; + quote: USDQuote; + image: string; } diff --git a/api/src/types/CoinMarketCap/Quote.ts b/api/src/types/CoinMarketCap/Quote.ts index 6644291..96828bd 100644 --- a/api/src/types/CoinMarketCap/Quote.ts +++ b/api/src/types/CoinMarketCap/Quote.ts @@ -1,16 +1,16 @@ export interface Quote { - price: number; - volume_24h: number; - volume_change_24h: number; - percent_change_1h: number; - percent_change_24h: number; - percent_change_7d: number; - percent_change_30d: number; - percent_change_60d: number; - percent_change_90d: number; - market_cap: number; - market_cap_dominance: number; - fully_diluted_market_cap: number; - tvl: number | null; - last_updated: Date; + price: number; + volume_24h: number; + volume_change_24h: number; + percent_change_1h: number; + percent_change_24h: number; + percent_change_7d: number; + percent_change_30d: number; + percent_change_60d: number; + percent_change_90d: number; + market_cap: number; + market_cap_dominance: number; + fully_diluted_market_cap: number; + tvl: number | null; + last_updated: Date; } diff --git a/app/components/EntityCard.vue b/app/components/EntityCard.vue new file mode 100644 index 0000000..5e60ad1 --- /dev/null +++ b/app/components/EntityCard.vue @@ -0,0 +1,54 @@ + + + diff --git a/app/components/LineCryptoChat.vue b/app/components/LineCryptoChat.vue index 4644b68..6e99f83 100644 --- a/app/components/LineCryptoChat.vue +++ b/app/components/LineCryptoChat.vue @@ -1,268 +1,268 @@