From 07d24a27bdf130206a17046a2a1ec27478d105dc Mon Sep 17 00:00:00 2001 From: bush1D3v Date: Sun, 3 Nov 2024 12:18:23 -0300 Subject: [PATCH] bomb commit --- api/src/app.ts | 2 + api/src/proxy/BrapiDev.ts | 44 +- api/src/proxy/CoinMarketCap.ts | 4 +- api/src/proxy/CurrencyQuotes.ts | 30 ++ api/src/routes/BrapiDev.ts | 2 +- api/src/routes/CurrencyQuotes.ts | 8 + api/src/types/BrapiDev/Stock.ts | 18 +- .../types/CurrencyQuotes/CurrencyQuotes.ts | 7 + api/src/types/CurrencyQuotes/Rates.ts | 193 +++++++++ app/components/Dto/CurrencyQuotes.ts | 384 +++++++++--------- app/components/Dto/DropdownDto.ts | 112 ++--- app/components/EntityCard.vue | 16 +- ...LineCryptoChat.vue => LineCryptoChart.vue} | 0 app/locales/translator.ts | 156 +++---- app/router/index.ts | 368 ++++++++--------- app/services/BrapiDev.ts | 30 +- app/services/CoinMarketCap.ts | 15 + app/services/CurrencyQuotes.ts | 23 ++ app/stores/useCurrencyQuotesStore.ts | 22 + app/stores/useStocksCurrencyStore.ts | 49 +-- app/tags/Image.vue | 2 - app/types/BrapiDev/Stock.ts | 18 +- app/types/CurrencyQuotes/CurrencyQuotes.ts | 7 + app/types/CurrencyQuotes/Rates.ts | 193 +++++++++ app/utils/numberFormatter.ts | 38 +- app/views/BrapiDev/Stocks.vue | 10 +- app/views/CoinMarketCap/CryptoDetail.vue | 42 +- app/views/CoinMarketCap/Cryptos.vue | 11 +- app/views/CurrencyQuotes.vue | 5 +- app/views/Home.vue | 2 +- e2e/about-us.spec.ts | 10 - 31 files changed, 1144 insertions(+), 677 deletions(-) create mode 100644 api/src/proxy/CurrencyQuotes.ts create mode 100644 api/src/routes/CurrencyQuotes.ts create mode 100644 api/src/types/CurrencyQuotes/CurrencyQuotes.ts create mode 100644 api/src/types/CurrencyQuotes/Rates.ts rename app/components/{LineCryptoChat.vue => LineCryptoChart.vue} (100%) create mode 100644 app/services/CurrencyQuotes.ts create mode 100644 app/stores/useCurrencyQuotesStore.ts create mode 100644 app/types/CurrencyQuotes/CurrencyQuotes.ts create mode 100644 app/types/CurrencyQuotes/Rates.ts diff --git a/api/src/app.ts b/api/src/app.ts index cda1335..d9ad0a9 100644 --- a/api/src/app.ts +++ b/api/src/app.ts @@ -2,6 +2,7 @@ import corsConfig from "./config/cors.ts"; import express from "express"; import coinMarketCapRoutes from "./routes/CoinMarketCap.ts"; import brapiDevRoutes from "./routes/BrapiDev.ts"; +import currencyQuotesRoutes from "./routes/CurrencyQuotes.ts"; const app = express(); @@ -9,5 +10,6 @@ app.use(corsConfig); app.use(express.json()); app.use(coinMarketCapRoutes); app.use(brapiDevRoutes); +app.use(currencyQuotesRoutes); export default app; diff --git a/api/src/proxy/BrapiDev.ts b/api/src/proxy/BrapiDev.ts index 3f88b2a..ee75e8e 100644 --- a/api/src/proxy/BrapiDev.ts +++ b/api/src/proxy/BrapiDev.ts @@ -1,29 +1,29 @@ -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 { Stock } from "../types/BrapiDev/Stock.ts"; +import type {Stock} from "../types/BrapiDev/Stock.ts"; dotenv.config(); const BASE_API_URL = process.env.BRAPI_HOST as string; const API_KEY = process.env.BRAPI_KEY as string; const defaultHeaders = { - "Accept-Encoding": "deflate, gzip", - "referrer-policy": "origin-when-cross-origin", - "X-Api-Key": API_KEY, + "Accept-Encoding": "deflate, gzip", + "referrer-policy": "origin-when-cross-origin", + "X-Api-Key": API_KEY, }; interface QueryParams { - limit?: number; - page?: number; + limit?: number; + page?: number; } -interface ResponseData { - stocks: Stock[]; +interface ResponseListStocks { + stocks: Stock[]; } /** - * Handles the request to get the stocks listing. + * @description Handles the request to get the stocks listing. * * @param {Request} req - The request object * @param {Response} res - The response object @@ -31,19 +31,19 @@ interface ResponseData { * @throws {Error} If the request to the external API fails */ export async function listStocks(req: Request, res: Response): Promise { - const { limit = 12, page = 1 }: QueryParams = req.query; - const url = `${BASE_API_URL}/api/quote/list?limit=${limit}&page=${page}`; + const {limit = 12, page = 1}: QueryParams = req.query; + const url = `${BASE_API_URL}/api/quote/list?limit=${limit}&page=${page}`; - try { - const response = await get(url, defaultHeaders); + try { + const response = await get(url, defaultHeaders); - if (!response.ok) throw new Error(await response.json()); + if (!response.ok) throw new Error(await response.json()); - const jsonData: ResponseData = await response.json(); + const jsonData: ResponseListStocks = await response.json(); - res.status(200).json(jsonData.stocks); - } catch (error) { - console.error(error); - res.status(500).json({ error: error }); - } + res.status(200).json(jsonData.stocks); + } catch (error) { + console.error(error); + res.status(500).json({error: error}); + } } diff --git a/api/src/proxy/CoinMarketCap.ts b/api/src/proxy/CoinMarketCap.ts index d16dbdc..2ff07a5 100644 --- a/api/src/proxy/CoinMarketCap.ts +++ b/api/src/proxy/CoinMarketCap.ts @@ -23,7 +23,7 @@ interface ResponseListingLatestData { } /** - * Handles the request to get the latest cryptocurrency listings. + * @description Handles the request to get the latest cryptocurrency listings. * * @param {Request} req - The request object * @param {Response} res - The response object @@ -57,7 +57,7 @@ interface ResponseDetailData { } /** - * Handles the request to get the latest cryptocurrency listings. + * @description Handles the request to get the latest cryptocurrency listings. * * @param {Request} req - The request object * @param {Response} res - The response object diff --git a/api/src/proxy/CurrencyQuotes.ts b/api/src/proxy/CurrencyQuotes.ts new file mode 100644 index 0000000..53f351c --- /dev/null +++ b/api/src/proxy/CurrencyQuotes.ts @@ -0,0 +1,30 @@ +import type {Request, Response} from "express"; +import {get} from "../helpers/HttpClient.ts"; +import type {CurrencyQuotes} from "../types/CurrencyQuotes/CurrencyQuotes.ts"; + +const BASE_API_URL = process.env.CURRENCYQUOTES_HOST as string; + +/** + * @description Handles the request to get the list of currency quotes. + * + * @param {Request} req - The request object + * @param {Response} res - The response object + * @returns {void} + * @throws {Error} If the request to the external API fails + */ +export async function listCurrencyQuotes(req: Request, res: Response): Promise { + const url = `${BASE_API_URL}/api/latest.json`; + + try { + const response = await get(url); + + if (!response.ok) throw new Error(await response.json()); + + const jsonData: CurrencyQuotes = await response.json(); + + res.json(jsonData); + } catch (error) { + console.error(error); + res.status(500).json({error: error}); + } +} diff --git a/api/src/routes/BrapiDev.ts b/api/src/routes/BrapiDev.ts index fb9c0a6..6c305c7 100644 --- a/api/src/routes/BrapiDev.ts +++ b/api/src/routes/BrapiDev.ts @@ -1,5 +1,5 @@ import express from "express"; -import { listStocks } from "../proxy/BrapiDev.ts"; +import {listStocks} from "../proxy/BrapiDev.ts"; const brapiDevRoutes = express(); diff --git a/api/src/routes/CurrencyQuotes.ts b/api/src/routes/CurrencyQuotes.ts new file mode 100644 index 0000000..4effcb6 --- /dev/null +++ b/api/src/routes/CurrencyQuotes.ts @@ -0,0 +1,8 @@ +import express from "express"; +import {listCurrencyQuotes} from "../proxy/CurrencyQuotes.ts"; + +const currencyQuotesRoutes = express(); + +currencyQuotesRoutes.get("/api/latest.json", listCurrencyQuotes); + +export default currencyQuotesRoutes; diff --git a/api/src/types/BrapiDev/Stock.ts b/api/src/types/BrapiDev/Stock.ts index cd56d37..a9d78d5 100644 --- a/api/src/types/BrapiDev/Stock.ts +++ b/api/src/types/BrapiDev/Stock.ts @@ -1,11 +1,11 @@ export interface Stock { - stock: string; - name: string; - close: number; - change: number; - volume: number; - market_cap: number; - logo: string; - sector: string; - type: string; + stock: string; + name: string; + close: number; + change: number; + volume: number; + market_cap: number; + logo: string; + sector: string; + type: string; } diff --git a/api/src/types/CurrencyQuotes/CurrencyQuotes.ts b/api/src/types/CurrencyQuotes/CurrencyQuotes.ts new file mode 100644 index 0000000..245158d --- /dev/null +++ b/api/src/types/CurrencyQuotes/CurrencyQuotes.ts @@ -0,0 +1,7 @@ +import type {Rates} from "./Rates"; + +export interface CurrencyQuotes { + table: string; + rates: Rates; + lastupdate: string; // ISO 8601 date string +} diff --git a/api/src/types/CurrencyQuotes/Rates.ts b/api/src/types/CurrencyQuotes/Rates.ts new file mode 100644 index 0000000..9ff498d --- /dev/null +++ b/api/src/types/CurrencyQuotes/Rates.ts @@ -0,0 +1,193 @@ +export interface Rates { + AED: number; + AFN: number; + ALL: number; + AMD: number; + ANG: number; + AOA: number; + ARS: number; + AUD: number; + AWG: number; + AZN: number; + BAM: number; + BBD: number; + BDT: number; + BGN: number; + BHD: number; + BIF: number; + BMD: number; + BND: number; + BOB: number; + BRL: number; + BSD: number; + BTC: number; + BTN: number; + BTS: number; + BWP: number; + BYN: number; + BZD: number; + CAD: number; + CDF: number; + CHF: number; + CLF: number; + CLP: number; + CNH: number; + CNY: number; + COP: number; + CRC: number; + CUC: number; + CUP: number; + CVE: number; + CZK: number; + DASH: number; + DJF: number; + DKK: number; + DOGE: number; + DOP: number; + DZD: number; + EGP: number; + ERN: number; + ETB: number; + ETH: number; + EUR: number; + FJD: number; + FKP: number; + GBP: number; + GEL: number; + GGP: number; + GHS: number; + GIP: number; + GMD: number; + GNF: number; + GTQ: number; + GYD: number; + HKD: number; + HNL: number; + HRK: number; + HTG: number; + HUF: number; + IDR: number; + ILS: number; + IMP: number; + INR: number; + IQD: number; + IRR: number; + ISK: number; + JEP: number; + JMD: number; + JOD: number; + JPY: number; + KES: number; + KGS: number; + KHR: number; + KMF: number; + KPW: number; + KRW: number; + KWD: number; + KYD: number; + KZT: number; + LAK: number; + LBP: number; + LD: number; + LKR: number; + LRD: number; + LSL: number; + LTC: number; + LYD: number; + MAD: number; + MDL: number; + MGA: number; + MKD: number; + MMK: number; + MNT: number; + MOP: number; + MRO: number; + MRU: number; + MUR: number; + MVR: number; + MWK: number; + MXN: number; + MYR: number; + MZN: number; + NAD: number; + NGN: number; + NIO: number; + NOK: number; + NPR: number; + NXT: number; + NZD: number; + OMR: number; + PAB: number; + PEN: number; + PGK: number; + PHP: number; + PKR: number; + PLN: number; + PYG: number; + QAR: number; + RON: number; + RSD: number; + RUB: number; + RWF: number; + SAR: number; + SBD: number; + SCR: number; + SDG: number; + SEK: number; + SGD: number; + SHP: number; + SLL: number; + SOS: number; + SRD: number; + SSP: number; + STD: number; + STN: number; + STR: number; + SVC: number; + SYP: number; + SZL: number; + THB: number; + TJS: number; + TMT: number; + TND: number; + TOP: number; + TRY: number; + TTD: number; + TWD: number; + TZS: number; + UAH: number; + UGX: number; + USD: number; + UYU: number; + UZS: number; + VEF_BLKMKT: number; + VEF_DICOM: number; + VEF_DIPRO: number; + VES: number; + VND: number; + VUV: number; + WST: number; + XAF: number; + XAG: number; + XAU: number; + XCD: number; + XDR: number; + XMR: number; + XOF: number; + XPD: number; + XPF: number; + XPT: number; + XRP: number; + YER: number; + ZAR: number; + ZMW: number; + ZWL: number; + NMC: number; + PPC: number; + NVC: number; + XPM: number; + EAC: number; + VTC: number; + EMC: number; + FCT: number; +} diff --git a/app/components/Dto/CurrencyQuotes.ts b/app/components/Dto/CurrencyQuotes.ts index b499d0c..6f83059 100644 --- a/app/components/Dto/CurrencyQuotes.ts +++ b/app/components/Dto/CurrencyQuotes.ts @@ -1,193 +1,193 @@ export const CurrencyQuotes = { - "AED": "Dirham dos Emirados Árabes Unidos (AED)", - "AFN": "Afegane Afegão (AFN)", - "ALL": "Lek Albanês (ALL)", - "AMD": "Dram Armênio (AMD)", - "ANG": "Florim das Antilhas Holandesas (ANG)", - "AOA": "Kwanza Angolano (AOA)", - "ARS": "Peso Argentino (ARS)", - "AUD": "Dólar Australiano (AUD)", - "AWG": "Florim Arubano (AWG)", - "AZN": "Manat Azeri (AZN)", - "BAM": "Marco Conversível da Bósnia-Herzegovina (BAM)", - "BBD": "Dólar de Barbados (BBD)", - "BDT": "Taka de Bangladesh (BDT)", - "BGN": "Lev Búlgaro (BGN)", - "BHD": "Dinar do Bahrein (BHD)", - "BIF": "Franco Burundiano (BIF)", - "BMD": "Dólar das Bermudas (BMD)", - "BND": "Dólar de Brunei (BND)", - "BOB": "Boliviano Boliviano (BOB)", - "BRL": "Real Brasileiro (BRL)", - "BSD": "Dólar das Bahamas (BSD)", - "BTC": "Bitcoin (BTC)", - "BTN": "Ngultrum do Butão (BTN)", - "BTS": "BitShares (BTS)", - "BWP": "Pula de Botswana (BWP)", - "BYN": "Rublo Bielorrusso (BYN)", - "BZD": "Dólar de Belize (BZD)", - "CAD": "Dólar Canadense (CAD)", - "CDF": "Franco Congolês (CDF)", - "CHF": "Franco Suíço (CHF)", - "CLF": "Unidade de Conta Chilena (UF) (CLF)", - "CLP": "Peso Chileno (CLP)", - "CNH": "Yuan Chinês (Offshore) (CNH)", - "CNY": "Yuan Chinês (CNY)", - "COP": "Peso Colombiano (COP)", - "CRC": "Colón Costarriquenho (CRC)", - "CUC": "Peso Cubano Conversível (CUC)", - "CUP": "Peso Cubano (CUP)", - "CVE": "Escudo Cabo-Verdiano (CVE)", - "CZK": "Coroa Checa (CZK)", - "DASH": "Dash (DASH)", - "DJF": "Franco Djiboutiano (DJF)", - "DKK": "Coroa Dinamarquesa (DKK)", - "DOGE": "Dogecoin (DOGE)", - "DOP": "Peso Dominicano (DOP)", - "DZD": "Dinar Argelino (DZD)", - "EGP": "Libra Egípcia (EGP)", - "ERN": "Nakfa da Eritreia (ERN)", - "ETB": "Birr Etíope (ETB)", - "ETH": "Ethereum (ETH)", - "EUR": "Euro (EUR)", - "FJD": "Dólar Fijiano (FJD)", - "FKP": "Libra das Ilhas Falkland (FKP)", - "GBP": "Libra Esterlina (GBP)", - "GEL": "Lari Georgiano (GEL)", - "GGP": "Libra de Guernsey (GGP)", - "GHS": "Cedi Ganês (GHS)", - "GIP": "Libra de Gibraltar (GIP)", - "GMD": "Dalasi da Gâmbia (GMD)", - "GNF": "Franco Guineano (GNF)", - "GTQ": "Quetzal Guatemalteco (GTQ)", - "GYD": "Dólar da Guiana (GYD)", - "HKD": "Dólar de Hong Kong (HKD)", - "HNL": "Lempira Hondurenha (HNL)", - "HRK": "Kuna Croata (HRK)", - "HTG": "Gourde Haitiano (HTG)", - "HUF": "Florim Húngaro (HUF)", - "IDR": "Rupia Indonésia (IDR)", - "ILS": "Novo Shekel Israelense (ILS)", - "IMP": "Libra da Ilha de Man (IMP)", - "INR": "Rupia Indiana (INR)", - "IQD": "Dinar Iraquiano (IQD)", - "IRR": "Rial Iraniano (IRR)", - "ISK": "Coroa Islandesa (ISK)", - "JEP": "Libra de Jersey (JEP)", - "JMD": "Dólar Jamaicano (JMD)", - "JOD": "Dinar Jordaniano (JOD)", - "JPY": "Iene Japonês (JPY)", - "KES": "Xelim Queniano (KES)", - "KGS": "Som Quirguiz (KGS)", - "KHR": "Riel Cambojano (KHR)", - "KMF": "Franco Comorense (KMF)", - "KPW": "Won Norte-Coreano (KPW)", - "KRW": "Won Sul-Coreano (KRW)", - "KWD": "Dinar Kuwaitiano (KWD)", - "KYD": "Dólar das Ilhas Cayman (KYD)", - "KZT": "Tenge Cazaque (KZT)", - "LAK": "Kip Laosiano (LAK)", - "LBP": "Libra Libanesa (LBP)", - "LD": "Dólar Linden (LD)", - "LKR": "Rupia do Sri Lanka (LKR)", - "LRD": "Dólar Liberiano (LRD)", - "LSL": "Loti do Lesoto (LSL)", - "LTC": "Litecoin (LTC)", - "LYD": "Dinar Líbio (LYD)", - "MAD": "Dirham Marroquino (MAD)", - "MDL": "Leu Moldavo (MDL)", - "MGA": "Ariary Malgaxe (MGA)", - "MKD": "Dinar Macedônio (MKD)", - "MMK": "Kyat de Mianmar (MMK)", - "MNT": "Tugrik Mongol (MNT)", - "MOP": "Pataca de Macau (MOP)", - "MRO": "Ouguiya Mauritana (MRO)", - "MRU": "Ouguiya Mauritana (MRU)", - "MUR": "Rupia Mauriciana (MUR)", - "MVR": "Rufiyaa Maldiva (MVR)", - "MWK": "Kwacha Malauiana (MWK)", - "MXN": "Peso Mexicano (MXN)", - "MYR": "Ringgit Malaio (MYR)", - "MZN": "Metical Moçambicano (MZN)", - "NAD": "Dólar Namibiano (NAD)", - "NGN": "Naira Nigeriana (NGN)", - "NIO": "Córdoba Nicaraguense (NIO)", - "NOK": "Coroa Norueguesa (NOK)", - "NPR": "Rupia Nepalesa (NPR)", - "NXT": "Nxt (NXT)", - "NZD": "Dólar Neozelandês (NZD)", - "OMR": "Rial Omanense (OMR)", - "PAB": "Balboa Panamenho (PAB)", - "PEN": "Novo Sol Peruano (PEN)", - "PGK": "Kina Papua-Nova Guiné (PGK)", - "PHP": "Peso Filipino (PHP)", - "PKR": "Rupia Paquistanesa (PKR)", - "PLN": "Zloty Polonês (PLN)", - "PYG": "Guarani Paraguaio (PYG)", - "QAR": "Rial Catarense (QAR)", - "RON": "Leu Romeno (RON)", - "RSD": "Dinar Sérvio (RSD)", - "RUB": "Rublo Russo (RUB)", - "RWF": "Franco Ruandês (RWF)", - "SAR": "Riyal Saudita (SAR)", - "SBD": "Dólar das Ilhas Salomão (SBD)", - "SCR": "Rupia de Seicheles (SCR)", - "SDG": "Libra Sudanesa (SDG)", - "SEK": "Coroa Sueca (SEK)", - "SGD": "Dólar de Singapura (SGD)", - "SHP": "Libra de Santa Helena (SHP)", - "SLL": "Leone de Serra Leoa (SLL)", - "SOS": "Xelim Somali (SOS)", - "SRD": "Dólar do Suriname (SRD)", - "SSP": "Libra do Sudão do Sul (SSP)", - "STD": "Dobra de São Tomé e Príncipe (STD)", - "STN": "Dobra de São Tomé e Príncipe (STN)", - "STR": "Stellar (STR)", - "SVC": "Colón Salvadorenho (SVC)", - "SYP": "Libra Síria (SYP)", - "SZL": "Lilangeni Suazi (SZL)", - "THB": "Baht Tailandês (THB)", - "TJS": "Somoni do Tajiquistão (TJS)", - "TMT": "Manat Turcomeno (TMT)", - "TND": "Dinar Tunisiano (TND)", - "TOP": "Paʻanga de Tonga (TOP)", - "TRY": "Lira Turca (TRY)", - "TTD": "Dólar de Trinidad e Tobago (TTD)", - "TWD": "Novo Dólar Taiwanês (TWD)", - "TZS": "Xelim Tanzaniano (TZS)", - "UAH": "Hryvnia Ucraniana (UAH)", - "UGX": "Xelim Ugandense (UGX)", - "USD": "Dólar dos Estados Unidos (USD)", - "UYU": "Peso Uruguaio (UYU)", - "UZS": "Som Uzbeque (UZS)", - "VEF_BLKMKT": "Bolívar Venezuelano (Mercado Negro) (VEF_BLKMKT)", - "VEF_DICOM": "Bolívar Venezuelano (DICOM) (VEF_DICOM)", - "VEF_DIPRO": "Bolívar Venezuelano (DIPRO) (VEF_DIPRO)", - "VES": "Bolívar Venezuelano Soberano (VES)", - "VND": "Dong Vietnamita (VND)", - "VUV": "Vatu de Vanuatu (VUV)", - "WST": "Tala Samoano (WST)", - "XAF": "Franco CFA BEAC (XAF)", - "XAG": "Onça de Prata (XAG)", - "XAU": "Onça de Ouro (XAU)", - "XCD": "Dólar do Caribe Oriental (XCD)", - "XDR": "Direitos Especiais de Saque (XDR)", - "XMR": "Monero (XMR)", - "XOF": "Franco CFA BCEAO (XOF)", - "XPD": "Onça de Paládio (XPD)", - "XPF": "Franco CFP (XPF)", - "XPT": "Onça de Platina (XPT)", - "XRP": "XRP (XRP)", - "YER": "Rial Iemenita (YER)", - "ZAR": "Rand Sul-Africano (ZAR)", - "ZMW": "Kwacha Zambiano (ZMW)", - "ZWL": "Dólar Zimbabuano (ZWL)", - "NMC": "Namecoin (NMC)", - "PPC": "Peercoin (PPC)", - "NVC": "Novacoin (NVC)", - "XPM": "Primecoin (XPM)", - "EAC": "EarthCoin (EAC)", - "VTC": "Vertcoin (VTC)", - "EMC": "Emercoin (EMC)", - "FCT": "Factom (FCT)" -} + AED: "Dirham dos Emirados Árabes Unidos (AED)", + AFN: "Afegane Afegão (AFN)", + ALL: "Lek Albanês (ALL)", + AMD: "Dram Armênio (AMD)", + ANG: "Florim das Antilhas Holandesas (ANG)", + AOA: "Kwanza Angolano (AOA)", + ARS: "Peso Argentino (ARS)", + AUD: "Dólar Australiano (AUD)", + AWG: "Florim Arubano (AWG)", + AZN: "Manat Azeri (AZN)", + BAM: "Marco Conversível da Bósnia-Herzegovina (BAM)", + BBD: "Dólar de Barbados (BBD)", + BDT: "Taka de Bangladesh (BDT)", + BGN: "Lev Búlgaro (BGN)", + BHD: "Dinar do Bahrein (BHD)", + BIF: "Franco Burundiano (BIF)", + BMD: "Dólar das Bermudas (BMD)", + BND: "Dólar de Brunei (BND)", + BOB: "Boliviano Boliviano (BOB)", + BRL: "Real Brasileiro (BRL)", + BSD: "Dólar das Bahamas (BSD)", + BTC: "Bitcoin (BTC)", + BTN: "Ngultrum do Butão (BTN)", + BTS: "BitShares (BTS)", + BWP: "Pula de Botswana (BWP)", + BYN: "Rublo Bielorrusso (BYN)", + BZD: "Dólar de Belize (BZD)", + CAD: "Dólar Canadense (CAD)", + CDF: "Franco Congolês (CDF)", + CHF: "Franco Suíço (CHF)", + CLF: "Unidade de Conta Chilena (UF) (CLF)", + CLP: "Peso Chileno (CLP)", + CNH: "Yuan Chinês (Offshore) (CNH)", + CNY: "Yuan Chinês (CNY)", + COP: "Peso Colombiano (COP)", + CRC: "Colón Costarriquenho (CRC)", + CUC: "Peso Cubano Conversível (CUC)", + CUP: "Peso Cubano (CUP)", + CVE: "Escudo Cabo-Verdiano (CVE)", + CZK: "Coroa Checa (CZK)", + DASH: "Dash (DASH)", + DJF: "Franco Djiboutiano (DJF)", + DKK: "Coroa Dinamarquesa (DKK)", + DOGE: "Dogecoin (DOGE)", + DOP: "Peso Dominicano (DOP)", + DZD: "Dinar Argelino (DZD)", + EGP: "Libra Egípcia (EGP)", + ERN: "Nakfa da Eritreia (ERN)", + ETB: "Birr Etíope (ETB)", + ETH: "Ethereum (ETH)", + EUR: "Euro (EUR)", + FJD: "Dólar Fijiano (FJD)", + FKP: "Libra das Ilhas Falkland (FKP)", + GBP: "Libra Esterlina (GBP)", + GEL: "Lari Georgiano (GEL)", + GGP: "Libra de Guernsey (GGP)", + GHS: "Cedi Ganês (GHS)", + GIP: "Libra de Gibraltar (GIP)", + GMD: "Dalasi da Gâmbia (GMD)", + GNF: "Franco Guineano (GNF)", + GTQ: "Quetzal Guatemalteco (GTQ)", + GYD: "Dólar da Guiana (GYD)", + HKD: "Dólar de Hong Kong (HKD)", + HNL: "Lempira Hondurenha (HNL)", + HRK: "Kuna Croata (HRK)", + HTG: "Gourde Haitiano (HTG)", + HUF: "Florim Húngaro (HUF)", + IDR: "Rupia Indonésia (IDR)", + ILS: "Novo Shekel Israelense (ILS)", + IMP: "Libra da Ilha de Man (IMP)", + INR: "Rupia Indiana (INR)", + IQD: "Dinar Iraquiano (IQD)", + IRR: "Rial Iraniano (IRR)", + ISK: "Coroa Islandesa (ISK)", + JEP: "Libra de Jersey (JEP)", + JMD: "Dólar Jamaicano (JMD)", + JOD: "Dinar Jordaniano (JOD)", + JPY: "Iene Japonês (JPY)", + KES: "Xelim Queniano (KES)", + KGS: "Som Quirguiz (KGS)", + KHR: "Riel Cambojano (KHR)", + KMF: "Franco Comorense (KMF)", + KPW: "Won Norte-Coreano (KPW)", + KRW: "Won Sul-Coreano (KRW)", + KWD: "Dinar Kuwaitiano (KWD)", + KYD: "Dólar das Ilhas Cayman (KYD)", + KZT: "Tenge Cazaque (KZT)", + LAK: "Kip Laosiano (LAK)", + LBP: "Libra Libanesa (LBP)", + LD: "Dólar Linden (LD)", + LKR: "Rupia do Sri Lanka (LKR)", + LRD: "Dólar Liberiano (LRD)", + LSL: "Loti do Lesoto (LSL)", + LTC: "Litecoin (LTC)", + LYD: "Dinar Líbio (LYD)", + MAD: "Dirham Marroquino (MAD)", + MDL: "Leu Moldavo (MDL)", + MGA: "Ariary Malgaxe (MGA)", + MKD: "Dinar Macedônio (MKD)", + MMK: "Kyat de Mianmar (MMK)", + MNT: "Tugrik Mongol (MNT)", + MOP: "Pataca de Macau (MOP)", + MRO: "Ouguiya Mauritana (MRO)", + MRU: "Ouguiya Mauritana (MRU)", + MUR: "Rupia Mauriciana (MUR)", + MVR: "Rufiyaa Maldiva (MVR)", + MWK: "Kwacha Malauiana (MWK)", + MXN: "Peso Mexicano (MXN)", + MYR: "Ringgit Malaio (MYR)", + MZN: "Metical Moçambicano (MZN)", + NAD: "Dólar Namibiano (NAD)", + NGN: "Naira Nigeriana (NGN)", + NIO: "Córdoba Nicaraguense (NIO)", + NOK: "Coroa Norueguesa (NOK)", + NPR: "Rupia Nepalesa (NPR)", + NXT: "Nxt (NXT)", + NZD: "Dólar Neozelandês (NZD)", + OMR: "Rial Omanense (OMR)", + PAB: "Balboa Panamenho (PAB)", + PEN: "Novo Sol Peruano (PEN)", + PGK: "Kina Papua-Nova Guiné (PGK)", + PHP: "Peso Filipino (PHP)", + PKR: "Rupia Paquistanesa (PKR)", + PLN: "Zloty Polonês (PLN)", + PYG: "Guarani Paraguaio (PYG)", + QAR: "Rial Catarense (QAR)", + RON: "Leu Romeno (RON)", + RSD: "Dinar Sérvio (RSD)", + RUB: "Rublo Russo (RUB)", + RWF: "Franco Ruandês (RWF)", + SAR: "Riyal Saudita (SAR)", + SBD: "Dólar das Ilhas Salomão (SBD)", + SCR: "Rupia de Seicheles (SCR)", + SDG: "Libra Sudanesa (SDG)", + SEK: "Coroa Sueca (SEK)", + SGD: "Dólar de Singapura (SGD)", + SHP: "Libra de Santa Helena (SHP)", + SLL: "Leone de Serra Leoa (SLL)", + SOS: "Xelim Somali (SOS)", + SRD: "Dólar do Suriname (SRD)", + SSP: "Libra do Sudão do Sul (SSP)", + STD: "Dobra de São Tomé e Príncipe (STD)", + STN: "Dobra de São Tomé e Príncipe (STN)", + STR: "Stellar (STR)", + SVC: "Colón Salvadorenho (SVC)", + SYP: "Libra Síria (SYP)", + SZL: "Lilangeni Suazi (SZL)", + THB: "Baht Tailandês (THB)", + TJS: "Somoni do Tajiquistão (TJS)", + TMT: "Manat Turcomeno (TMT)", + TND: "Dinar Tunisiano (TND)", + TOP: "Paʻanga de Tonga (TOP)", + TRY: "Lira Turca (TRY)", + TTD: "Dólar de Trinidad e Tobago (TTD)", + TWD: "Novo Dólar Taiwanês (TWD)", + TZS: "Xelim Tanzaniano (TZS)", + UAH: "Hryvnia Ucraniana (UAH)", + UGX: "Xelim Ugandense (UGX)", + USD: "Dólar dos Estados Unidos (USD)", + UYU: "Peso Uruguaio (UYU)", + UZS: "Som Uzbeque (UZS)", + VEF_BLKMKT: "Bolívar Venezuelano (Mercado Negro) (VEF_BLKMKT)", + VEF_DICOM: "Bolívar Venezuelano (DICOM) (VEF_DICOM)", + VEF_DIPRO: "Bolívar Venezuelano (DIPRO) (VEF_DIPRO)", + VES: "Bolívar Venezuelano Soberano (VES)", + VND: "Dong Vietnamita (VND)", + VUV: "Vatu de Vanuatu (VUV)", + WST: "Tala Samoano (WST)", + XAF: "Franco CFA BEAC (XAF)", + XAG: "Onça de Prata (XAG)", + XAU: "Onça de Ouro (XAU)", + XCD: "Dólar do Caribe Oriental (XCD)", + XDR: "Direitos Especiais de Saque (XDR)", + XMR: "Monero (XMR)", + XOF: "Franco CFA BCEAO (XOF)", + XPD: "Onça de Paládio (XPD)", + XPF: "Franco CFP (XPF)", + XPT: "Onça de Platina (XPT)", + XRP: "XRP (XRP)", + YER: "Rial Iemenita (YER)", + ZAR: "Rand Sul-Africano (ZAR)", + ZMW: "Kwacha Zambiano (ZMW)", + ZWL: "Dólar Zimbabuano (ZWL)", + NMC: "Namecoin (NMC)", + PPC: "Peercoin (PPC)", + NVC: "Novacoin (NVC)", + XPM: "Primecoin (XPM)", + EAC: "EarthCoin (EAC)", + VTC: "Vertcoin (VTC)", + EMC: "Emercoin (EMC)", + FCT: "Factom (FCT)", +}; diff --git a/app/components/Dto/DropdownDto.ts b/app/components/Dto/DropdownDto.ts index 3b2cd66..fe832e0 100644 --- a/app/components/Dto/DropdownDto.ts +++ b/app/components/Dto/DropdownDto.ts @@ -1,4 +1,4 @@ -import type { Menu } from "../Dropdown.vue"; +import type {Menu} from "../Dropdown.vue"; import Ethereum from "@/assets/images/ethereum.png"; import Bitcoin from "@/assets/images/bitcoin.png"; import Dogecoin from "@/assets/images/dogecoin.png"; @@ -10,70 +10,48 @@ import Vale from "@/assets/images/logo-vale.jpg"; import Wege from "@/assets/images/logo-wege.png"; import Petrobras from "@/assets/images/logo-petra.jpg"; export const DropdownDto: Menu[] = [ - { - emoji: "🪙", - title: "Cripto moedas", - link: "/cryptos", - subContent: [ - { - title: "Bitcoin", - link: "/cryptos/bitcoin", - logo: Bitcoin, - }, - { - title: "Ethereum", - link: "/cryptos/ethereum", - logo: Ethereum, - }, - { - title: "Dogecoin", - link: "/cryptos/dogecoin", - logo: Dogecoin, - }, - ], - }, - // { - // emoji: "💵", - // title: "Moedas globais", - // link: "/coins", - // subContent: [ - // { - // title: "Dollar", - // link: "/coins/dollar", - // logo: Dollar, - // }, - // { - // title: "Real", - // link: "/coins/real", - // logo: Real, - // }, - // { - // title: "Euro", - // link: "/coins/euro", - // logo: Euro, - // }, - // ], - // }, - { - emoji: "📋", - title: "Bolsa de Valores", - link: "/stocks", - subContent: [ - { - title: "Petrobras", - link: "/stocks/petrobras", - logo: Petrobras, - }, - { - title: "Vale", - link: "/stocks/vale", - logo: Vale, - }, - { - title: "Weg", - link: "/stocks/weg", - logo: Wege, - }, - ], - }, + { + emoji: "🪙", + title: "Cripto moedas", + link: "/cryptos", + subContent: [ + { + title: "Bitcoin", + link: "/cryptos/bitcoin", + logo: Bitcoin, + }, + { + title: "Ethereum", + link: "/cryptos/ethereum", + logo: Ethereum, + }, + { + title: "Dogecoin", + link: "/cryptos/dogecoin", + logo: Dogecoin, + }, + ], + }, + { + emoji: "📋", + title: "Bolsa de Valores", + link: "/stocks", + subContent: [ + { + title: "Petrobras", + link: "/stocks/petrobras", + logo: Petrobras, + }, + { + title: "Vale", + link: "/stocks/vale", + logo: Vale, + }, + { + title: "Weg", + link: "/stocks/weg", + logo: Wege, + }, + ], + }, ]; diff --git a/app/components/EntityCard.vue b/app/components/EntityCard.vue index 5e60ad1..0fc11a9 100644 --- a/app/components/EntityCard.vue +++ b/app/components/EntityCard.vue @@ -4,14 +4,14 @@ import Button from "@/components/ui/button/Button.vue"; import numberFormatter from "@/utils/numberFormatter"; export interface EntityCardProps { - id: string | number; - name: string; - symbol: string; - image: string; - routerLinkTo: string; - price: number; - market_cap: number; - circulating_supply: number; + id: string | number; + name: string; + symbol: string; + image: string; + routerLinkTo: string; + price: number; + market_cap: number; + circulating_supply: number; } const props = defineProps(); diff --git a/app/components/LineCryptoChat.vue b/app/components/LineCryptoChart.vue similarity index 100% rename from app/components/LineCryptoChat.vue rename to app/components/LineCryptoChart.vue diff --git a/app/locales/translator.ts b/app/locales/translator.ts index 9023039..1dc2972 100644 --- a/app/locales/translator.ts +++ b/app/locales/translator.ts @@ -1,4 +1,4 @@ -import type { App } from "vue"; +import type {App} from "vue"; import i18next from "i18next"; import I18NextVue from "i18next-vue"; import LanguageDetector from "i18next-browser-languagedetector"; @@ -10,83 +10,83 @@ import ptTranslates from "./pt/translate.json"; export const DEFAULT_LNG = "pt-BR"; i18next - .use(Backend) - .use(LanguageDetector) - .init({ - supportedLngs: [ - "pt-BR", - "pt", - "es", - "en", - "en-US", - "en-GB", - "en-CA", - "en-AU", - "en-NZ", - "en-IN", - "en-ZA", - "en-IE", - "en-SG", - ], - debug: true, - load: "all", - fallbackLng: DEFAULT_LNG, - resources: { - es: { - translation: esTranslates, - }, - pt: { - translation: ptTranslates, - }, - en: { - translation: enTranslates, - }, - "en-US": { - translation: enTranslates, - }, - "en-GB": { - translation: enTranslates, - }, - "en-CA": { - translation: enTranslates, - }, - "en-AU": { - translation: enTranslates, - }, - "en-NZ": { - translation: enTranslates, - }, - "en-IN": { - translation: enTranslates, - }, - "en-ZA": { - translation: enTranslates, - }, - "en-IE": { - translation: enTranslates, - }, - "en-SG": { - translation: enTranslates, - }, - }, - backend: { - loadPath: "/app/locales/{{lng}}/translate.json", - }, - detection: { - order: [ - "navigator", - "querystring", - "cookie", - "localStorage", - "htmlTag", - "path", - "subdomain", - ], - caches: [ "localStorage", "cookie" ], - }, - }); + .use(Backend) + .use(LanguageDetector) + .init({ + supportedLngs: [ + "pt-BR", + "pt", + "es", + "en", + "en-US", + "en-GB", + "en-CA", + "en-AU", + "en-NZ", + "en-IN", + "en-ZA", + "en-IE", + "en-SG", + ], + debug: true, + load: "all", + fallbackLng: DEFAULT_LNG, + resources: { + es: { + translation: esTranslates, + }, + pt: { + translation: ptTranslates, + }, + en: { + translation: enTranslates, + }, + "en-US": { + translation: enTranslates, + }, + "en-GB": { + translation: enTranslates, + }, + "en-CA": { + translation: enTranslates, + }, + "en-AU": { + translation: enTranslates, + }, + "en-NZ": { + translation: enTranslates, + }, + "en-IN": { + translation: enTranslates, + }, + "en-ZA": { + translation: enTranslates, + }, + "en-IE": { + translation: enTranslates, + }, + "en-SG": { + translation: enTranslates, + }, + }, + backend: { + loadPath: "/app/locales/{{lng}}/translate.json", + }, + detection: { + order: [ + "navigator", + "querystring", + "cookie", + "localStorage", + "htmlTag", + "path", + "subdomain", + ], + caches: ["localStorage", "cookie"], + }, + }); export default function (app: App) { - app.use(I18NextVue, { i18next }); - return app; + app.use(I18NextVue, {i18next}); + return app; } diff --git a/app/router/index.ts b/app/router/index.ts index cb41230..a0140c8 100644 --- a/app/router/index.ts +++ b/app/router/index.ts @@ -1,4 +1,4 @@ -import { createRouter, createWebHistory } from "vue-router"; +import {createRouter, createWebHistory} from "vue-router"; import Home from "@/views/Home.vue"; import AboutUs from "@/views/AboutUs.vue"; import NotFound from "@/views/Exceptions/NotFound.vue"; @@ -11,196 +11,196 @@ import PrivacyPolicy from "@/views/Policies/PrivacyPolicy.vue"; import CurrencyQuotes from "@/views/CurrencyQuotes.vue"; const router = createRouter({ - history: createWebHistory(import.meta.env.BASE_URL), - routes: [ - { - path: "/", - name: "Home", - component: Home, - meta: { - title: "Home | NEI Market Analytics", - description: - "Welcome to NEI Market Analytics, your source for comprehensive market analysis.", - keywords: "market analysis, business insights, NEI Market Analytics", - robots: "index, follow", - ogTitle: "Home | NEI Market Analytics", - ogDescription: - "Welcome to NEI Market Analytics, your source for comprehensive market analysis.", - ogImage: "/logo.svg", - ogUrl: "http://localhost:5173/", - }, - }, - { - path: "/about-us", - name: "About Us", - component: AboutUs, - meta: { - title: "About Us | NEI Market Analytics", - description: "Learn more about NEI Market Analytics and our mission.", - keywords: "about us, NEI Market Analytics, company information", - robots: "index, follow", - ogTitle: "About Us | NEI Market Analytics", - ogDescription: "Learn more about NEI Market Analytics and our mission.", - ogImage: "/logo.svg", - ogUrl: "http://localhost:5173/about-u", - }, - }, - { - path: "/privacy-policy", - name: "PrivacyPolicy", - component: PrivacyPolicy, - meta: { - title: "Privacy Policy | NEI Market Analytics", - description: "Learn more about our privacy policy.", - keywords: "privacy policy, NEI Market Analytics", - robots: "index, follow", - ogTitle: "Privacy Policy | NEI Market Analytics", - ogDescription: "Learn more about our privacy policy.", - ogImage: "/logo.svg", - ogUrl: "http://localhost:5173/privacy-policy", - }, - }, - { - path: "/cookie-policy", - name: "CookiePolicy", - component: CookiePolicy, - meta: { - title: "Cookie Policy | NEI Market Analytics", - description: "Learn more about our cookie policy.", - keywords: "cookie policy, NEI Market Analytics", - robots: "index, follow", - ogTitle: "Cookie Policy | NEI Market Analytics", - ogDescription: "Learn more about our cookie policy.", - ogImage: "/logo.svg", - ogUrl: "http://localhost:5173/cookie-policy", - }, - }, - { - path: "/cryptos", - name: "Cryptos", - component: Cryptos, - meta: { - title: "Crypto | NEI Market Analytics", - description: "Explore our comprehensive list of crypto assets.", - keywords: "crypto, crypto assets, NEI Market Analytics", - robots: "index, follow", - ogTitle: "Crypto | NEI Market Analytics", - ogDescription: "Explore our comprehensive list of crypto assets.", - ogImage: "/logo.svg", - ogUrl: "http://localhost:5173/cryptos", - }, - }, - { - path: "/stocks", - name: "Stocks", - component: Stocks, - meta: { - title: "Stocks | NEI Market Analytics", - description: "Explore our comprehensive list of stocks.", - keywords: "stocks, stock assets, NEI Market Analytics", - robots: "index, follow", - ogTitle: "Stocks | NEI Market Analytics", - ogDescription: "Explore our comprehensive list of stocks.", - ogImage: "/logo.svg", - ogUrl: "http://localhost:5173/stocks", - }, - }, - { - path: "/cryptos/:crypto", - name: "CryptoDetail", - component: CryptoDetail, - meta: { - description: "Explore our comprehensive crypto.", - keywords: "crypto, crypto assets, NEI Market Analytics", - robots: "index, follow", - ogTitle: "Crypto | NEI Market Analytics", - ogDescription: "Explore our comprehensive crypto.", - ogImage: "/logo.svg", - ogUrl: "http://localhost:5173/cryptos/:crypto", - }, - props: (route) => ({ key: route.params.crypto }), - }, - { - path: "/stocks/:stock", - name: "StockDetail", - component: StockDetail, - meta: { - description: "Explore our comprehensive list of stocks.", - keywords: "stocks, stock assets, NEI Market Analytics", - robots: "index, follow", - ogTitle: "Stocks | NEI Market Analytics", - ogDescription: "Explore our comprehensive list of stocks.", - ogImage: "/logo.svg", - ogUrl: "http://localhost:5173/stocks/:stock", - }, - props: (route) => ({ key: route.params.stock }), - }, - { - path: "/currency-quotes", - name: "CurrencyQuotes", - component: CurrencyQuotes, - meta: { - title: "Currency Quotes | NEI Market Analytics", - description: "Currency Quotes", - keywords: "currency quotes, NEI Market Analytics", - robots: "index, follow", - ogTitle: "Currency Quotes | NEI Market Analytics", - ogDescription: "Currency Quotes", - ogImage: "/logo.svg", - ogUrl: "http://localhost:5173/currency-quotes", - } - }, - { - path: "/:pathMatch(.*)*", - name: "Not Found", - component: NotFound, - meta: { - title: "404 | NEI Market Analytics", - description: "Page not found", - keywords: "404, page not found, NEI Market Analytics", - robots: "noindex, nofollow", - ogTitle: "404 | NEI Market Analytics", - ogDescription: "Page not found", - ogImage: "/logo.svg", - ogUrl: "http://localhost:5173/", - }, - } - ], + history: createWebHistory(import.meta.env.BASE_URL), + routes: [ + { + path: "/", + name: "Home", + component: Home, + meta: { + title: "Home | NEI Market Analytics", + description: + "Welcome to NEI Market Analytics, your source for comprehensive market analysis.", + keywords: "market analysis, business insights, NEI Market Analytics", + robots: "index, follow", + ogTitle: "Home | NEI Market Analytics", + ogDescription: + "Welcome to NEI Market Analytics, your source for comprehensive market analysis.", + ogImage: "/logo.svg", + ogUrl: "http://localhost:5173/", + }, + }, + { + path: "/about-us", + name: "About Us", + component: AboutUs, + meta: { + title: "About Us | NEI Market Analytics", + description: "Learn more about NEI Market Analytics and our mission.", + keywords: "about us, NEI Market Analytics, company information", + robots: "index, follow", + ogTitle: "About Us | NEI Market Analytics", + ogDescription: "Learn more about NEI Market Analytics and our mission.", + ogImage: "/logo.svg", + ogUrl: "http://localhost:5173/about-u", + }, + }, + { + path: "/privacy-policy", + name: "PrivacyPolicy", + component: PrivacyPolicy, + meta: { + title: "Privacy Policy | NEI Market Analytics", + description: "Learn more about our privacy policy.", + keywords: "privacy policy, NEI Market Analytics", + robots: "index, follow", + ogTitle: "Privacy Policy | NEI Market Analytics", + ogDescription: "Learn more about our privacy policy.", + ogImage: "/logo.svg", + ogUrl: "http://localhost:5173/privacy-policy", + }, + }, + { + path: "/cookie-policy", + name: "CookiePolicy", + component: CookiePolicy, + meta: { + title: "Cookie Policy | NEI Market Analytics", + description: "Learn more about our cookie policy.", + keywords: "cookie policy, NEI Market Analytics", + robots: "index, follow", + ogTitle: "Cookie Policy | NEI Market Analytics", + ogDescription: "Learn more about our cookie policy.", + ogImage: "/logo.svg", + ogUrl: "http://localhost:5173/cookie-policy", + }, + }, + { + path: "/cryptos", + name: "Cryptos", + component: Cryptos, + meta: { + title: "Crypto | NEI Market Analytics", + description: "Explore our comprehensive list of crypto assets.", + keywords: "crypto, crypto assets, NEI Market Analytics", + robots: "index, follow", + ogTitle: "Crypto | NEI Market Analytics", + ogDescription: "Explore our comprehensive list of crypto assets.", + ogImage: "/logo.svg", + ogUrl: "http://localhost:5173/cryptos", + }, + }, + { + path: "/stocks", + name: "Stocks", + component: Stocks, + meta: { + title: "Stocks | NEI Market Analytics", + description: "Explore our comprehensive list of stocks.", + keywords: "stocks, stock assets, NEI Market Analytics", + robots: "index, follow", + ogTitle: "Stocks | NEI Market Analytics", + ogDescription: "Explore our comprehensive list of stocks.", + ogImage: "/logo.svg", + ogUrl: "http://localhost:5173/stocks", + }, + }, + { + path: "/cryptos/:crypto", + name: "CryptoDetail", + component: CryptoDetail, + meta: { + description: "Explore our comprehensive crypto.", + keywords: "crypto, crypto assets, NEI Market Analytics", + robots: "index, follow", + ogTitle: "Crypto | NEI Market Analytics", + ogDescription: "Explore our comprehensive crypto.", + ogImage: "/logo.svg", + ogUrl: "http://localhost:5173/cryptos/:crypto", + }, + props: (route) => ({key: route.params.crypto}), + }, + { + path: "/stocks/:stock", + name: "StockDetail", + component: StockDetail, + meta: { + description: "Explore our comprehensive list of stocks.", + keywords: "stocks, stock assets, NEI Market Analytics", + robots: "index, follow", + ogTitle: "Stocks | NEI Market Analytics", + ogDescription: "Explore our comprehensive list of stocks.", + ogImage: "/logo.svg", + ogUrl: "http://localhost:5173/stocks/:stock", + }, + props: (route) => ({key: route.params.stock}), + }, + { + path: "/currency-quotes", + name: "CurrencyQuotes", + component: CurrencyQuotes, + meta: { + title: "Currency Quotes | NEI Market Analytics", + description: "Currency Quotes", + keywords: "currency quotes, NEI Market Analytics", + robots: "index, follow", + ogTitle: "Currency Quotes | NEI Market Analytics", + ogDescription: "Currency Quotes", + ogImage: "/logo.svg", + ogUrl: "http://localhost:5173/currency-quotes", + }, + }, + { + path: "/:pathMatch(.*)*", + name: "Not Found", + component: NotFound, + meta: { + title: "404 | NEI Market Analytics", + description: "Page not found", + keywords: "404, page not found, NEI Market Analytics", + robots: "noindex, nofollow", + ogTitle: "404 | NEI Market Analytics", + ogDescription: "Page not found", + ogImage: "/logo.svg", + ogUrl: "http://localhost:5173/", + }, + }, + ], }); router.beforeEach((to, _from, next) => { - document.title = (to.meta.title as string) || "NEI Market Analytics"; + document.title = (to.meta.title as string) || "NEI Market Analytics"; - const metaTags = [ - { name: "description", content: to.meta.description as string }, - { name: "keywords", content: to.meta.keywords as string }, - { name: "robots", content: to.meta.robots as string }, - { property: "og:title", content: to.meta.ogTitle as string }, - { - property: "og:description", - content: to.meta.ogDescription as string, - }, - { property: "og:image", content: to.meta.ogImage as string }, - { property: "og:url", content: to.meta.ogUrl as string }, - ]; + const metaTags = [ + {name: "description", content: to.meta.description as string}, + {name: "keywords", content: to.meta.keywords as string}, + {name: "robots", content: to.meta.robots as string}, + {property: "og:title", content: to.meta.ogTitle as string}, + { + property: "og:description", + content: to.meta.ogDescription as string, + }, + {property: "og:image", content: to.meta.ogImage as string}, + {property: "og:url", content: to.meta.ogUrl as string}, + ]; - for (const tag of metaTags) { - const key = tag.name ? "name" : "property"; - const value = tag.name || tag.property; - if (!value) continue; + for (const tag of metaTags) { + const key = tag.name ? "name" : "property"; + const value = tag.name || tag.property; + if (!value) continue; - let element = document.querySelector(`meta[${key}="${value}"]`); - if (element) { - element.setAttribute("content", tag.content); - } else { - element = document.createElement("meta"); - element.setAttribute(key, value); - element.setAttribute("content", tag.content); - document.head.appendChild(element); - } - } + let element = document.querySelector(`meta[${key}="${value}"]`); + if (element) { + element.setAttribute("content", tag.content); + } else { + element = document.createElement("meta"); + element.setAttribute(key, value); + element.setAttribute("content", tag.content); + document.head.appendChild(element); + } + } - next(); + next(); }); export default router; diff --git a/app/services/BrapiDev.ts b/app/services/BrapiDev.ts index d48fdd2..bb0fa55 100644 --- a/app/services/BrapiDev.ts +++ b/app/services/BrapiDev.ts @@ -1,18 +1,24 @@ -import { get } from "@/server/HttpClient"; -import type { Stock } from "@/types/BrapiDev/Stock"; +import {get} from "@/server/HttpClient"; +import type {Stock} from "@/types/BrapiDev/Stock"; +/** + * @description Handles the request to get the list of currency quotes. + * + * @param {number} limit - The limit number of cryptocurrencies to return + * @param {number} page - The page number of cryptocurrencies to return + * @returns Promise + * @throws {Error} If the request to the proxy fails + */ export async function listStocks(limit = 12, page = 1): Promise { - try { - const response = await get( - `/api/quote/list?limit=${limit}&page=${page}`, - ); + try { + const response = await get(`/api/quote/list?limit=${limit}&page=${page}`); - if (!response.ok) throw new Error(await response.json()); + if (!response.ok) throw new Error(await response.json()); - const jsonData: Stock[] = await response.json(); + const jsonData: Stock[] = await response.json(); - return jsonData; - } catch (error) { - console.error(error); - } + return jsonData; + } catch (error) { + console.error(error); + } } diff --git a/app/services/CoinMarketCap.ts b/app/services/CoinMarketCap.ts index 91cbc63..1504a7e 100644 --- a/app/services/CoinMarketCap.ts +++ b/app/services/CoinMarketCap.ts @@ -1,6 +1,14 @@ import {get} from "@/server/HttpClient"; import type {CryptoCurrency} from "@/types/CoinMarketCap/CryptoCurrency"; +/** + * @description Handles the request to get the latest cryptocurrency listings. + * + * @param {number} limit - The limit number of cryptocurrencies to return + * @param {number} start - The start number of cryptocurrencies to return + * @returns Promise + * @throws {Error} If the request to the proxy fails + */ export async function listBitcoin(limit = 12, start = 1): Promise { try { const response = await get( @@ -17,6 +25,13 @@ export async function listBitcoin(limit = 12, start = 1): Promise + * @throws {Error} If the request to the proxy fails + */ export async function detailBitcoin(slug: string): Promise { try { const response = await get(`/v2/cryptocurrency/info?slug=${slug}`); diff --git a/app/services/CurrencyQuotes.ts b/app/services/CurrencyQuotes.ts new file mode 100644 index 0000000..6f22496 --- /dev/null +++ b/app/services/CurrencyQuotes.ts @@ -0,0 +1,23 @@ +import {get} from "@/server/HttpClient"; + +import type {Stock} from "@/types/BrapiDev/Stock"; + +/** + * @description Handles the request to get the list of currency quotes. + * + * @returns Promise + * @throws {Error} If the request to the proxy fails + */ +export async function listCurrencyQuotes(): Promise { + try { + const response = await get("/api/latest.json"); + + if (!response.ok) throw new Error(await response.json()); + + const jsonData: Stock[] = await response.json(); + + return jsonData; + } catch (error) { + console.error(error); + } +} diff --git a/app/stores/useCurrencyQuotesStore.ts b/app/stores/useCurrencyQuotesStore.ts new file mode 100644 index 0000000..d601260 --- /dev/null +++ b/app/stores/useCurrencyQuotesStore.ts @@ -0,0 +1,22 @@ +import {ref} from "vue"; +import {defineStore} from "pinia"; + +import type {CurrencyQuotes} from "@/types/CurrencyQuotes/CurrencyQuotes"; + +export const useCurrencyQuotesStore = defineStore("currencyQuotes", () => { + const currencyQuotes = ref(); + const leftCurrency = ref(""); + const rightCurrency = ref(""); + + function invertCurrencies(): void { + leftCurrency.value = rightCurrency.value; + rightCurrency.value = leftCurrency.value; + } + + return { + currencyQuotes, + leftCurrency, + rightCurrency, + invertCurrencies, + }; +}); diff --git a/app/stores/useStocksCurrencyStore.ts b/app/stores/useStocksCurrencyStore.ts index 585e514..24ce744 100644 --- a/app/stores/useStocksCurrencyStore.ts +++ b/app/stores/useStocksCurrencyStore.ts @@ -1,35 +1,28 @@ -import { ref } from "vue"; -import { defineStore } from "pinia"; +import {ref} from "vue"; +import {defineStore} from "pinia"; -import type { Stock } from "@/types/BrapiDev/Stock"; +import type {Stock} from "@/types/BrapiDev/Stock"; export const useStocksCurrencyStore = defineStore("stocksCurrency", () => { - const stocksCurrencies = ref([]); + const stocksCurrencies = ref([]); - function addStocksCurrencies(stockCurrencyArray: Stock[]): void { - stocksCurrencies.value.push(...stockCurrencyArray); - } + function addStocksCurrencies(stockCurrencyArray: Stock[]): void { + stocksCurrencies.value.push(...stockCurrencyArray); + } - function removeStocksCurrency(id: string): void { - stocksCurrencies.value = stocksCurrencies.value.filter( - (stockCurrency) => stockCurrency.id.toString() !== id, - ); - } + function detailStocksCurrency(name: string): Stock | null { + const stocksCurrency = stocksCurrencies.value.find( + (stocksCurrency) => stocksCurrency.name === name, + ); + if (!stocksCurrency) { + return null; + } + return stocksCurrency; + } - function detailStocksCurrency(name: string): Stock | null { - const stocksCurrency = stocksCurrencies.value.find( - (stocksCurrency) => stocksCurrency.name === name, - ); - if (!stocksCurrency) { - return null; - } - return stocksCurrency; - } - - return { - stocksCurrencies, - addStocksCurrencies, - removeStocksCurrency, - detailStocksCurrency, - }; + return { + stocksCurrencies, + addStocksCurrencies, + detailStocksCurrency, + }; }); diff --git a/app/tags/Image.vue b/app/tags/Image.vue index a39b1b7..60a437b 100644 --- a/app/tags/Image.vue +++ b/app/tags/Image.vue @@ -14,10 +14,8 @@ export interface ImageProps extends /* @vue-ignore */ ImgHTMLAttributes { const props = defineProps(); -// Data const loading = ref(true); -// Methods function onImageLoad() { loading.value = false; } diff --git a/app/types/BrapiDev/Stock.ts b/app/types/BrapiDev/Stock.ts index cd56d37..a9d78d5 100644 --- a/app/types/BrapiDev/Stock.ts +++ b/app/types/BrapiDev/Stock.ts @@ -1,11 +1,11 @@ export interface Stock { - stock: string; - name: string; - close: number; - change: number; - volume: number; - market_cap: number; - logo: string; - sector: string; - type: string; + stock: string; + name: string; + close: number; + change: number; + volume: number; + market_cap: number; + logo: string; + sector: string; + type: string; } diff --git a/app/types/CurrencyQuotes/CurrencyQuotes.ts b/app/types/CurrencyQuotes/CurrencyQuotes.ts new file mode 100644 index 0000000..245158d --- /dev/null +++ b/app/types/CurrencyQuotes/CurrencyQuotes.ts @@ -0,0 +1,7 @@ +import type {Rates} from "./Rates"; + +export interface CurrencyQuotes { + table: string; + rates: Rates; + lastupdate: string; // ISO 8601 date string +} diff --git a/app/types/CurrencyQuotes/Rates.ts b/app/types/CurrencyQuotes/Rates.ts new file mode 100644 index 0000000..9ff498d --- /dev/null +++ b/app/types/CurrencyQuotes/Rates.ts @@ -0,0 +1,193 @@ +export interface Rates { + AED: number; + AFN: number; + ALL: number; + AMD: number; + ANG: number; + AOA: number; + ARS: number; + AUD: number; + AWG: number; + AZN: number; + BAM: number; + BBD: number; + BDT: number; + BGN: number; + BHD: number; + BIF: number; + BMD: number; + BND: number; + BOB: number; + BRL: number; + BSD: number; + BTC: number; + BTN: number; + BTS: number; + BWP: number; + BYN: number; + BZD: number; + CAD: number; + CDF: number; + CHF: number; + CLF: number; + CLP: number; + CNH: number; + CNY: number; + COP: number; + CRC: number; + CUC: number; + CUP: number; + CVE: number; + CZK: number; + DASH: number; + DJF: number; + DKK: number; + DOGE: number; + DOP: number; + DZD: number; + EGP: number; + ERN: number; + ETB: number; + ETH: number; + EUR: number; + FJD: number; + FKP: number; + GBP: number; + GEL: number; + GGP: number; + GHS: number; + GIP: number; + GMD: number; + GNF: number; + GTQ: number; + GYD: number; + HKD: number; + HNL: number; + HRK: number; + HTG: number; + HUF: number; + IDR: number; + ILS: number; + IMP: number; + INR: number; + IQD: number; + IRR: number; + ISK: number; + JEP: number; + JMD: number; + JOD: number; + JPY: number; + KES: number; + KGS: number; + KHR: number; + KMF: number; + KPW: number; + KRW: number; + KWD: number; + KYD: number; + KZT: number; + LAK: number; + LBP: number; + LD: number; + LKR: number; + LRD: number; + LSL: number; + LTC: number; + LYD: number; + MAD: number; + MDL: number; + MGA: number; + MKD: number; + MMK: number; + MNT: number; + MOP: number; + MRO: number; + MRU: number; + MUR: number; + MVR: number; + MWK: number; + MXN: number; + MYR: number; + MZN: number; + NAD: number; + NGN: number; + NIO: number; + NOK: number; + NPR: number; + NXT: number; + NZD: number; + OMR: number; + PAB: number; + PEN: number; + PGK: number; + PHP: number; + PKR: number; + PLN: number; + PYG: number; + QAR: number; + RON: number; + RSD: number; + RUB: number; + RWF: number; + SAR: number; + SBD: number; + SCR: number; + SDG: number; + SEK: number; + SGD: number; + SHP: number; + SLL: number; + SOS: number; + SRD: number; + SSP: number; + STD: number; + STN: number; + STR: number; + SVC: number; + SYP: number; + SZL: number; + THB: number; + TJS: number; + TMT: number; + TND: number; + TOP: number; + TRY: number; + TTD: number; + TWD: number; + TZS: number; + UAH: number; + UGX: number; + USD: number; + UYU: number; + UZS: number; + VEF_BLKMKT: number; + VEF_DICOM: number; + VEF_DIPRO: number; + VES: number; + VND: number; + VUV: number; + WST: number; + XAF: number; + XAG: number; + XAU: number; + XCD: number; + XDR: number; + XMR: number; + XOF: number; + XPD: number; + XPF: number; + XPT: number; + XRP: number; + YER: number; + ZAR: number; + ZMW: number; + ZWL: number; + NMC: number; + PPC: number; + NVC: number; + XPM: number; + EAC: number; + VTC: number; + EMC: number; + FCT: number; +} diff --git a/app/utils/numberFormatter.ts b/app/utils/numberFormatter.ts index 1c733b3..b8dbca8 100644 --- a/app/utils/numberFormatter.ts +++ b/app/utils/numberFormatter.ts @@ -1,23 +1,23 @@ export default function numberFormatter(num: number): string { - if (num >= 1e12) { - return `${(num / 1e12).toFixed(2)}T`; - } - if (num >= 1e9) { - return `${(num / 1e9).toFixed(2)}B`; - } - if (num >= 1e6) { - return `${(num / 1e6).toFixed(2)}M`; - } - if (num >= 1e3) { - return `${(num / 1e3).toFixed(2)}K`; - } - let fixed = 2; - let numStr = num.toFixed(fixed); + if (num >= 1e12) { + return `${(num / 1e12).toFixed(2)}T`; + } + if (num >= 1e9) { + return `${(num / 1e9).toFixed(2)}B`; + } + if (num >= 1e6) { + return `${(num / 1e6).toFixed(2)}M`; + } + if (num >= 1e3) { + return `${(num / 1e3).toFixed(2)}K`; + } + let fixed = 2; + let numStr = num.toFixed(fixed); - while (numStr.endsWith("0") && fixed < 2) { - fixed++; - numStr = num.toFixed(fixed); - } + while (numStr.endsWith("0") && fixed < 2) { + fixed++; + numStr = num.toFixed(fixed); + } - return numStr; + return numStr; } diff --git a/app/views/BrapiDev/Stocks.vue b/app/views/BrapiDev/Stocks.vue index 46e1165..4582a3c 100644 --- a/app/views/BrapiDev/Stocks.vue +++ b/app/views/BrapiDev/Stocks.vue @@ -10,7 +10,7 @@ import { useStocksCurrencyStore } from "@/stores/useStocksCurrencyStore"; useTranslation(); -const stockCurrencyStore = useStocksCurrencyStore(); +const { addStocksCurrencies, detailStocksCurrency, stocksCurrencies } = useStocksCurrencyStore(); const isLoading = ref(true); const isLoadingMore = ref(false); const start = ref(1); @@ -26,7 +26,7 @@ async function loadMore() { const newStocks = await loadStocks(); if (newStocks) { - stockCurrencyStore.addStocksCurrencies(newStocks); + addStocksCurrencies(newStocks); } else { error.value = true; } @@ -35,10 +35,10 @@ async function loadMore() { } onMounted(async () => { - if (!stockCurrencyStore.stocksCurrencies.length) { + if (!stocksCurrencies.length) { const data = await loadStocks(); if (!data) error.value = true; - else stockCurrencyStore.addStocksCurrencies(data); + else addStocksCurrencies(data); } isLoading.value = false; }); @@ -47,7 +47,7 @@ onMounted(async () => {