This commit is contained in:
MuslemRahimi 2024-09-11 20:11:19 +02:00
parent 4435e702c5
commit cc1794501e
9 changed files with 102 additions and 108 deletions

View File

@ -20,7 +20,7 @@ function latestInfoDate(inputDate) {
const differenceInDays = Math?.floor(differenceInMs / (1000 * 60 * 60 * 24)); const differenceInDays = Math?.floor(differenceInMs / (1000 * 60 * 60 * 24));
// Return the difference in days // Return the difference in days
return differenceInDays <=3; return differenceInDays <=2;
} }
@ -68,7 +68,7 @@ $: {
</li> </li>
</div> </div>
{:else} {:else}
<div class="shadow-lg shadow-bg-[#000] bg-[#111112] sm:bg-opacity-[0.5] text-sm sm:text-[1rem] rounded-md w-full p-4 min-h-24 mt-4 text-white m-auto flex justify-center rawDatas-center text-center font-semibold"> <div class="shadow-lg shadow-bg-[#000] bg-[#111112] sm:bg-opacity-[0.5] text-sm sm:text-[1rem] rounded-md w-full p-4 min-h-24 mt-4 text-white m-auto flex justify-center items-center text-center font-semibold">
<svg class="mr-1.5 w-5 h-5 inline-block"xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="#A3A3A3" d="M17 9V7c0-2.8-2.2-5-5-5S7 4.2 7 7v2c-1.7 0-3 1.3-3 3v7c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3v-7c0-1.7-1.3-3-3-3M9 7c0-1.7 1.3-3 3-3s3 1.3 3 3v2H9z"/></svg> <svg class="mr-1.5 w-5 h-5 inline-block"xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="#A3A3A3" d="M17 9V7c0-2.8-2.2-5-5-5S7 4.2 7 7v2c-1.7 0-3 1.3-3 3v7c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3v-7c0-1.7-1.3-3-3-3M9 7c0-1.7 1.3-3 3-3s3 1.3 3 3v2H9z"/></svg>
Unlock content with <a class="inline-block ml-2 text-blue-400 hover:sm:text-white" href="/pricing">Pro Subscription</a> Unlock content with <a class="inline-block ml-2 text-blue-400 hover:sm:text-white" href="/pricing">Pro Subscription</a>
</div> </div>

View File

@ -350,22 +350,22 @@ $: {
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0"> <div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
<div class="w-full flex justify-between items-center p-3 mt-3"> <div class="w-full flex justify-between items-center p-3 mt-3">
<h2 class="text-start text-xl font-semibold text-white ml-3"> <h2 class="text-start text-xl font-semibold text-white ml-3">
Pro Subscription Pro Subscription 🔥
</h2> </h2>
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/> <ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
</div> </div>
<span class="text-white p-3 ml-3 mr-3"> <span class="text-white p-3 ml-3 mr-3">
Upgrade now for unlimited access to all data and tools. Upgrade now for unlimited access to all data and tools
</span> </span>
</div> </div>
</div> </div>
{/if} {/if}
<div on:click={() => goto('/analysts')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer"> <div on:click={() => goto('/analysts/top-stocks')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer">
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0"> <div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
<div class="w-full flex justify-between items-center p-3 mt-3"> <div class="w-full flex justify-between items-center p-3 mt-3">
<h2 class="text-start text-xl font-semibold text-white ml-3"> <h2 class="text-start text-xl font-semibold text-white ml-3">
Wallstreet Analyst Top Stocks Picks ⭐
</h2> </h2>
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/> <ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
</div> </div>
@ -375,16 +375,16 @@ $: {
</div> </div>
</div> </div>
<div on:click={() => goto('/politicians')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer"> <div on:click={() => goto('/most-shorted-stocks')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer">
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0"> <div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
<div class="w-full flex justify-between items-center p-3 mt-3"> <div class="w-full flex justify-between items-center p-3 mt-3">
<h2 class="text-start text-xl font-semibold text-white ml-3"> <h2 class="text-start text-xl font-semibold text-white ml-3">
Congress Trading Top Shorted Stocks 🍋
</h2> </h2>
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/> <ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
</div> </div>
<span class="text-white p-3 ml-3 mr-3"> <span class="text-white p-3 ml-3 mr-3">
Get the latest top Congress trading insights. Never miss out another short squeeze
</span> </span>
</div> </div>
</div> </div>

View File

@ -319,12 +319,12 @@ $: {
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0"> <div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
<div class="w-full flex justify-between items-center p-3 mt-3"> <div class="w-full flex justify-between items-center p-3 mt-3">
<h2 class="text-start text-xl font-semibold text-white ml-3"> <h2 class="text-start text-xl font-semibold text-white ml-3">
Pro Subscription Pro Subscription 🔥
</h2> </h2>
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/> <ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
</div> </div>
<span class="text-white p-3 ml-3 mr-3"> <span class="text-white p-3 ml-3 mr-3">
Upgrade now for unlimited access to all data and tools. Upgrade now for unlimited access to all data and tools
</span> </span>
</div> </div>
</div> </div>
@ -334,26 +334,26 @@ $: {
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0"> <div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
<div class="w-full flex justify-between items-center p-3 mt-3"> <div class="w-full flex justify-between items-center p-3 mt-3">
<h2 class="text-start text-xl font-semibold text-white ml-3"> <h2 class="text-start text-xl font-semibold text-white ml-3">
Wallstreet Analyst Top Analyst 📊
</h2> </h2>
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/> <ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
</div> </div>
<span class="text-white p-3 ml-3 mr-3"> <span class="text-white p-3 ml-3 mr-3">
Get the latest top Wall Street analyst ratings. Get the latest top Wall Street analyst ratings
</span> </span>
</div> </div>
</div> </div>
<div on:click={() => goto('/politicians')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer"> <div on:click={() => goto('/most-shorted-stocks')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer">
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0"> <div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
<div class="w-full flex justify-between items-center p-3 mt-3"> <div class="w-full flex justify-between items-center p-3 mt-3">
<h2 class="text-start text-xl font-semibold text-white ml-3"> <h2 class="text-start text-xl font-semibold text-white ml-3">
Congress Trading Top Shorted Stocks 🍋
</h2> </h2>
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/> <ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
</div> </div>
<span class="text-white p-3 ml-3 mr-3"> <span class="text-white p-3 ml-3 mr-3">
Get the latest top Congress trading insights. Never miss out another short squeeze
</span> </span>
</div> </div>
</div> </div>

View File

@ -4,6 +4,7 @@
import InfiniteLoading from '$lib/components/InfiniteLoading.svelte'; import InfiniteLoading from '$lib/components/InfiniteLoading.svelte';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import ArrowLogo from "lucide-svelte/icons/move-up-right"; import ArrowLogo from "lucide-svelte/icons/move-up-right";
import UpgradeToPro from '$lib/components/UpgradeToPro.svelte';
//import UpgradeToPro from '$lib/components/UpgradeToPro.svelte'; //import UpgradeToPro from '$lib/components/UpgradeToPro.svelte';
@ -203,7 +204,7 @@
</table> </table>
</div> </div>
<InfiniteLoading on:infinite={infiniteHandler} /> <InfiniteLoading on:infinite={infiniteHandler} />
<!--<UpgradeToPro data={data} title="Get the latest dark pool trades in realtime from Hedge Funds & Major Institutional Traders"/>--> <UpgradeToPro data={data} title="Get the latest dark pool trades in realtime from Hedge Funds & Major Institutional Traders"/>
</div> </div>
@ -227,7 +228,7 @@
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0"> <div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
<div class="w-full flex justify-between items-center p-3 mt-3"> <div class="w-full flex justify-between items-center p-3 mt-3">
<h2 class="text-start text-xl font-semibold text-white ml-3"> <h2 class="text-start text-xl font-semibold text-white ml-3">
Pro Subscription Pro Subscription 🔥
</h2> </h2>
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/> <ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
</div> </div>
@ -238,30 +239,30 @@
</div> </div>
{/if} {/if}
<div on:click={() => goto('/analysts')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer"> <div on:click={() => goto('/reddit-tracker')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer">
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0"> <div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
<div class="w-full flex justify-between items-center p-3 mt-3"> <div class="w-full flex justify-between items-center p-3 mt-3">
<h2 class="text-start text-xl font-semibold text-white ml-3"> <h2 class="text-start text-xl font-semibold text-white ml-3">
Wallstreet Analyst Reddit Tracker 🚀
</h2> </h2>
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/> <ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
</div> </div>
<span class="text-white p-3 ml-3 mr-3"> <span class="text-white p-3 ml-3 mr-3">
Get the latest top Wall Street analyst ratings. Get the latest trends of r/Wallstreetbets
</span> </span>
</div> </div>
</div> </div>
<div on:click={() => goto('/politicians')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer"> <div on:click={() => goto('/most-retail-volume')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer">
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0"> <div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
<div class="w-full flex justify-between items-center p-3 mt-3"> <div class="w-full flex justify-between items-center p-3 mt-3">
<h2 class="text-start text-xl font-semibold text-white ml-3"> <h2 class="text-start text-xl font-semibold text-white ml-3">
Congress Trading Retail Trader Tracker 💳
</h2> </h2>
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/> <ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
</div> </div>
<span class="text-white p-3 ml-3 mr-3"> <span class="text-white p-3 ml-3 mr-3">
Get the latest top Congress trading insights. Follow the daily trends of retail investors
</span> </span>
</div> </div>
</div> </div>

View File

@ -1,32 +1,29 @@
import {getCache, setCache } from '$lib/store'; import { getCache, setCache } from "$lib/store";
export const load = async ({parent}) => {
export const load = async ({ parent }) => {
const getCramerTracker = async () => { const getCramerTracker = async () => {
let output; let output;
const { apiKey, apiURL, user } = await parent();
const cachedData = getCache('', 'getCramerTracker'); const cachedData = getCache("", "getCramerTracker");
if (cachedData) { if (cachedData) {
output = cachedData; output = cachedData;
} else { } else {
const response = await fetch(apiURL + "/cramer-tracker", {
const { apiKey, apiURL } = await parent(); method: "GET",
headers: {
"Content-Type": "application/json",
"X-API-KEY": apiKey,
},
});
const response = await fetch(apiURL + '/cramer-tracker', { output = await response.json();
method: 'GET',
headers: {
"Content-Type": "application/json", "X-API-KEY": apiKey
},
});
output = await response.json();
setCache('', output, 'getCramerTracker');
setCache("", output, "getCramerTracker");
} }
output = user?.tier !== "Pro" ? output?.slice(0, 5) : output;
//output = data?.user?.tier !== 'Pro' ? output?.slice(0,6) : output; //output = data?.user?.tier !== 'Pro' ? output?.slice(0,6) : output;
return output; return output;
@ -34,6 +31,6 @@ export const load = async ({parent}) => {
// Make sure to return a promise // Make sure to return a promise
return { return {
getCramerTracker: await getCramerTracker() getCramerTracker: await getCramerTracker(),
}; };
}; };

View File

@ -234,7 +234,7 @@
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0"> <div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
<div class="w-full flex justify-between items-center p-3 mt-3"> <div class="w-full flex justify-between items-center p-3 mt-3">
<h2 class="text-start text-xl font-semibold text-white ml-3"> <h2 class="text-start text-xl font-semibold text-white ml-3">
Pro Subscription Pro Subscription 🔥
</h2> </h2>
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/> <ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
</div> </div>
@ -245,30 +245,31 @@
</div> </div>
{/if} {/if}
<div on:click={() => goto('/analysts')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer"> <div on:click={() => goto('/cramer-tracker')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer">
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0"> <div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
<div class="w-full flex justify-between items-center p-3 mt-3"> <div class="w-full flex justify-between items-center p-3 mt-3">
<h2 class="text-start text-xl font-semibold text-white ml-3"> <h2 class="text-start text-xl font-semibold text-white ml-3">
Wallstreet Analyst Cramer Tracker 📉
</h2> </h2>
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/> <ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
</div> </div>
<span class="text-white p-3 ml-3 mr-3"> <span class="text-white p-3 ml-3 mr-3">
Get the latest top Wall Street analyst ratings. Follow Jim Cramer latest stock picks
</span> </span>
</div> </div>
</div> </div>
<div on:click={() => goto('/politicians')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer"> <div on:click={() => goto('/reddit-tracker')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer">
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0"> <div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
<div class="w-full flex justify-between items-center p-3 mt-3"> <div class="w-full flex justify-between items-center p-3 mt-3">
<h2 class="text-start text-xl font-semibold text-white ml-3"> <h2 class="text-start text-xl font-semibold text-white ml-3">
Congress Trading Reddit Tracker 🚀
</h2> </h2>
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/> <ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
</div> </div>
<span class="text-white p-3 ml-3 mr-3"> <span class="text-white p-3 ml-3 mr-3">
Get the latest top Congress trading insights. Get the latest trends of r/Wallstreetbets
</span> </span>
</div> </div>
</div> </div>

View File

@ -1,38 +1,35 @@
import { getCache, setCache } from '$lib/store'; import { getCache, setCache } from "$lib/store";
export const load = async ({ parent }) => {
export const load = async ({parent}) => {
const getMostRetailVolume = async () => { const getMostRetailVolume = async () => {
let output; let output;
const {apiKey, apiURL, user} = await parent(); const { apiKey, apiURL, user } = await parent();
const cachedData = getCache("", "getMostRetailVolume");
const cachedData = getCache('', 'getMostRetailVolume');
if (cachedData) { if (cachedData) {
output = cachedData; output = cachedData;
} else { } else {
// make the POST request to the endpoint // make the POST request to the endpoint
const response = await fetch(apiURL + '/most-retail-volume', { const response = await fetch(apiURL + "/most-retail-volume", {
method: 'GET', method: "GET",
headers: { headers: {
"Content-Type": "application/json", "X-API-KEY": apiKey "Content-Type": "application/json",
}, "X-API-KEY": apiKey,
}); },
});
output = await response.json(); output = await response.json();
output = user?.tier !== 'Pro' ? output?.slice(0,6) : output;
setCache('', output, 'getMostRetailVolume');
setCache("", output, "getMostRetailVolume");
} }
output = user?.tier !== "Pro" ? output?.slice(0, 6) : output;
return output; return output;
}; };
// Make sure to return a promise // Make sure to return a promise
return { return {
getMostRetailVolume: await getMostRetailVolume() getMostRetailVolume: await getMostRetailVolume(),
}; };
}; };

View File

@ -228,12 +228,12 @@
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0"> <div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
<div class="w-full flex justify-between items-center p-3 mt-3"> <div class="w-full flex justify-between items-center p-3 mt-3">
<h2 class="text-start text-xl font-semibold text-white ml-3"> <h2 class="text-start text-xl font-semibold text-white ml-3">
Pro Subscription Pro Subscription 🔥
</h2> </h2>
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/> <ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
</div> </div>
<span class="text-white p-3 ml-3 mr-3"> <span class="text-white p-3 ml-3 mr-3">
Upgrade now for unlimited access to all data and tools. Upgrade now for unlimited access to all data and tools
</span> </span>
</div> </div>
</div> </div>
@ -243,7 +243,21 @@
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0"> <div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
<div class="w-full flex justify-between items-center p-3 mt-3"> <div class="w-full flex justify-between items-center p-3 mt-3">
<h2 class="text-start text-xl font-semibold text-white ml-3"> <h2 class="text-start text-xl font-semibold text-white ml-3">
Wallstreet Analyst Top Analyst 📊
</h2>
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
</div>
<span class="text-white p-3 ml-3 mr-3">
Get the latest top Wall Street analyst ratings
</span>
</div>
</div>
<div on:click={() => goto('/analysts/top-stocks')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer">
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
<div class="w-full flex justify-between items-center p-3 mt-3">
<h2 class="text-start text-xl font-semibold text-white ml-3">
Top Stocks Picks ⭐
</h2> </h2>
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/> <ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
</div> </div>
@ -253,20 +267,6 @@
</div> </div>
</div> </div>
<div on:click={() => goto('/politicians')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer">
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
<div class="w-full flex justify-between items-center p-3 mt-3">
<h2 class="text-start text-xl font-semibold text-white ml-3">
Congress Trading
</h2>
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
</div>
<span class="text-white p-3 ml-3 mr-3">
Get the latest top Congress trading insights.
</span>
</div>
</div>
</aside> </aside>
</div> </div>

View File

@ -1,36 +1,34 @@
import { getCache, setCache } from '$lib/store'; import { getCache, setCache } from "$lib/store";
export const load = async ({ parent }) => {
export const load = async ({parent}) => {
const getMostShortedStocks = async () => { const getMostShortedStocks = async () => {
let output; let output;
const {apiKey, apiURL, user} = await parent(); const { apiKey, apiURL, user } = await parent();
const cachedData = getCache('', 'getMostShortedStocks'); const cachedData = getCache("", "getMostShortedStocks");
if (cachedData) { if (cachedData) {
output = cachedData; output = cachedData;
} else { } else {
const response = await fetch(apiURL + '/most-shorted-stocks', { const response = await fetch(apiURL + "/most-shorted-stocks", {
method: 'GET', method: "GET",
headers: { headers: {
"Content-Type": "application/json", "X-API-KEY": apiKey "Content-Type": "application/json",
}, "X-API-KEY": apiKey,
}); },
});
output = await response.json(); output = await response.json();
output = user?.tier !== 'Pro' ? output?.slice(0,6) : output;
setCache('', output, 'getMostShortedStocks');
setCache("", output, "getMostShortedStocks");
} }
output = user?.tier !== "Pro" ? output?.slice(0, 6) : output;
return output; return output;
}; };
// Make sure to return a promise // Make sure to return a promise
return { return {
getMostShortedStocks: await getMostShortedStocks() getMostShortedStocks: await getMostShortedStocks(),
}; };
}; };