clean code
This commit is contained in:
parent
c205bd9c5a
commit
6781ea4ec0
@ -8,14 +8,14 @@ export const handle = async ({ event, resolve }) => {
|
||||
const userRegion = regionHeader.split('::')[0];
|
||||
|
||||
const isUsRegion = usRegion.has(userRegion);
|
||||
const pbUrl = import.meta.env[isUsRegion ? 'VITE_USEAST_POCKETBASE_URL' : 'VITE_EU_POCKETBASE_URL'];
|
||||
const pbURL = import.meta.env[isUsRegion ? 'VITE_USEAST_POCKETBASE_URL' : 'VITE_EU_POCKETBASE_URL'];
|
||||
const apiURL = import.meta.env[isUsRegion ? 'VITE_USEAST_API_URL' : 'VITE_EU_API_URL'];
|
||||
const fastifyURL = import.meta.env[isUsRegion ? 'VITE_USEAST_FASTIFY_URL' : 'VITE_EU_FASTIFY_URL'];
|
||||
const wsURL = import.meta.env[isUsRegion ? 'VITE_USEAST_WS_URL' : 'VITE_EU_WS_URL'];
|
||||
|
||||
event.locals = {
|
||||
region: decodeURIComponent(regionHeader),
|
||||
pb: new PocketBase(pbUrl),
|
||||
pb: new PocketBase(pbURL),
|
||||
apiURL,
|
||||
fastifyURL,
|
||||
wsURL,
|
||||
|
||||
@ -1,27 +1,12 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
import {getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
|
||||
export const load = async ( { parent } ) => {
|
||||
export const load = async ({parent}) => {
|
||||
|
||||
const getTopAnalyst = async () => {
|
||||
const data = await parent()
|
||||
const { apiURL, apiKey, user} = await parent();
|
||||
|
||||
let output;
|
||||
|
||||
const cachedData = getCache('', 'getTopAnalyst');
|
||||
@ -40,7 +25,7 @@ export const load = async ( { parent } ) => {
|
||||
setCache('', output, 'getTopAnalyst');
|
||||
}
|
||||
|
||||
output = data?.user?.tier !== 'Pro' ? output?.reverse()?.slice(0,6) : output;
|
||||
output = user?.tier !== 'Pro' ? output?.reverse()?.slice(0,6) : output;
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
@ -1,24 +1,7 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion?.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
export const load = async ({params}) => {
|
||||
export const load = async ({parent, params}) => {
|
||||
const getAnalystStats = async () => {
|
||||
let output;
|
||||
|
||||
@ -28,6 +11,8 @@ export const load = async ({params}) => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const { apiURL, apiKey} = await parent();
|
||||
|
||||
const postData = {'analystId': params.slug}
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(apiURL + '/analyst-stats', {
|
||||
|
||||
@ -1,33 +1,18 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
export const load = async ({parent}) => {
|
||||
const getTopAnalystStocks = async () => {
|
||||
let output;
|
||||
const data = await parent();
|
||||
const { apiURL, apiKey, user} = await parent();
|
||||
|
||||
const cachedData = getCache('', 'getTopAnalystStocks');
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
} else {
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(apiURL + '/top-analysts-stocks', {
|
||||
|
||||
const response = await fetch(apiURL + '/top-analysts-stocks', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
@ -40,7 +25,7 @@ export const load = async ({parent}) => {
|
||||
|
||||
}
|
||||
|
||||
output = data?.user?.tier !== 'Pro' ? output?.reverse()?.slice(0,6) : output;
|
||||
output = user?.tier !== 'Pro' ? output?.reverse()?.slice(0,6) : output;
|
||||
return output;
|
||||
};
|
||||
|
||||
|
||||
@ -2,10 +2,10 @@ import { pb } from "$lib/pocketbase";
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
export const load = async () => {
|
||||
export const load = async ({parent}) => {
|
||||
const getAllBlogPost = async () => {
|
||||
let output;
|
||||
|
||||
console.log(await parent())
|
||||
// Get cached data for the specific tickerID
|
||||
const cachedData = getCache('allBlogPost', 'getAllBlogPost');
|
||||
if (cachedData) {
|
||||
|
||||
@ -51,7 +51,6 @@ $: {
|
||||
<!-- Other meta tags -->
|
||||
<meta property="og:title" content={`List of All Crypto Ticker Symbols · stocknear`}/>
|
||||
<meta property="og:description" content={`An overview of all the Crypto symbols listed. Explore the Crypto pages to learn about the circulating supply and price changes.`} />
|
||||
<meta property="og:image" content="https://stocknear-pocketbase.s3.amazonaws.com/logo/meta_logo.jpg"/>
|
||||
<meta property="og:type" content="website"/>
|
||||
<!-- Add more Open Graph meta tags as needed -->
|
||||
|
||||
@ -59,7 +58,6 @@ $: {
|
||||
<meta name="twitter:card" content="summary_large_image"/>
|
||||
<meta name="twitter:title" content={`List of All Crypto Ticker Symbols · stocknear`}/>
|
||||
<meta name="twitter:description" content={`An overview of all the Crypto symbols listed. Explore the Crypto pages to learn about the circulating supply and price changes.`} />
|
||||
<meta name="twitter:image" content="https://stocknear-pocketbase.s3.amazonaws.com/logo/meta_logo.jpg"/>
|
||||
<!-- Add more Twitter meta tags as needed -->
|
||||
|
||||
</svelte:head>
|
||||
@ -74,7 +72,7 @@ $: {
|
||||
</div>
|
||||
-->
|
||||
|
||||
<div class="w-full max-w-4xl m-auto sm:bg-[#09090B] sm:rounded-xl h-auto pl-10 pr-10 pt-5 sm:pb-10 sm:pt-10 mt-3 mb-8">
|
||||
<div class="w-full max-w-4xl m-auto sm:bg-[#27272A] sm:rounded-xl h-auto pl-10 pr-10 pt-5 sm:pb-10 sm:pt-10 mt-3 mb-8">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-10">
|
||||
|
||||
<!-- Start Column -->
|
||||
|
||||
@ -1,24 +1,8 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
|
||||
export const load = async () => {
|
||||
export const load = async ({parent}) => {
|
||||
const getCryptoList = async () => {
|
||||
let output;
|
||||
|
||||
@ -27,9 +11,8 @@ export const load = async () => {
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const {apiKey, apiURL} = await parent();
|
||||
const response = await fetch(apiURL + '/all-crypto-tickers', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
|
||||
@ -1,24 +1,9 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
|
||||
|
||||
export const load = async ({ params }) => {
|
||||
export const load = async ({ parent, params }) => {
|
||||
const getSenateTrading = async () => {
|
||||
let output;
|
||||
|
||||
@ -27,6 +12,9 @@ export const load = async ({ params }) => {
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const {apiKey, apiURL} = await parent();
|
||||
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
@ -1,23 +1,7 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL = import.meta.env.VITE_EU_API_URL; // Set a default API URL
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
export const load = async ({ params }) => {
|
||||
export const load = async ({ parent, params }) => {
|
||||
const getStockNews = async () => {
|
||||
let output;
|
||||
|
||||
@ -26,6 +10,9 @@ export const load = async ({ params }) => {
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const {apiKey, apiURL} = await parent();
|
||||
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
@ -1,19 +1,8 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
if (usRegion.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
export const load = async ({ params }) => {
|
||||
|
||||
export const load = async ({ parent, params }) => {
|
||||
|
||||
|
||||
const getQuantStats = async () => {
|
||||
@ -24,6 +13,8 @@ export const load = async ({ params }) => {
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const {apiKey, apiURL} = await parent();
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { userRegion, getCache, setCache, isOpen } from '$lib/store';
|
||||
import { getCache, setCache, isOpen } from '$lib/store';
|
||||
|
||||
|
||||
const checkMarketHour = async () => {
|
||||
@ -19,35 +19,18 @@ const checkMarketHour = async () => {
|
||||
}
|
||||
|
||||
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
export const load = async ({parent}) => {
|
||||
|
||||
checkMarketHour()
|
||||
const getDarkPoolFlow = async () => {
|
||||
let output;
|
||||
const data = await parent();
|
||||
|
||||
const cachedData = getCache('', 'getDarkPoolFlow');
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
} else {
|
||||
// make the POST request to the endpoint
|
||||
|
||||
const {apiKey, apiURL} = await parent();
|
||||
const response = await fetch(apiURL + '/dark-pool-flow', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
|
||||
@ -11,12 +11,12 @@ export const load = async ({parent}) => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const data = await parent();
|
||||
const {apiKey, apiURL} = await parent();
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/dividends-calendar', {
|
||||
const response = await fetch(apiURL + '/dividends-calendar', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -11,12 +11,12 @@ export const load = async ({parent}) => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const data = await parent();
|
||||
const {apiKey, apiURL} = await parent();
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/earnings-calendar', {
|
||||
const response = await fetch(apiURL + '/earnings-calendar', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -3,7 +3,6 @@ import { goto } from '$app/navigation';
|
||||
import { numberOfUnreadNotification, screenWidth } from '$lib/store';
|
||||
import { abbreviateNumber } from '$lib/utils';
|
||||
import { page } from '$app/stores';
|
||||
import { fly } from 'svelte/transition';
|
||||
import logo from '$lib/images/box_logo.png';
|
||||
|
||||
import InfiniteLoading from '$lib/components/InfiniteLoading.svelte';
|
||||
@ -64,7 +63,6 @@ $: {
|
||||
<!-- Other meta tags -->
|
||||
<meta property="og:title" content={`List of All ETF Ticker Symbols · stocknear`}/>
|
||||
<meta property="og:description" content={`An overview of all the ETF symbols listed. Explore the ETF pages to learn about the fund’s price history, holdings, dividends and more.`} />
|
||||
<meta property="og:image" content="https://stocknear-pocketbase.s3.amazonaws.com/logo/meta_logo.jpg"/>
|
||||
<meta property="og:type" content="website"/>
|
||||
<!-- Add more Open Graph meta tags as needed -->
|
||||
|
||||
@ -72,12 +70,11 @@ $: {
|
||||
<meta name="twitter:card" content="summary_large_image"/>
|
||||
<meta name="twitter:title" content={`List of All ETF Ticker Symbols · stocknear`}/>
|
||||
<meta name="twitter:description" content={`An overview of all the ETF symbols listed. Explore the ETF pages to learn about the fund’s price history, holdings, dividends and more.`} />
|
||||
<meta name="twitter:image" content="https://stocknear-pocketbase.s3.amazonaws.com/logo/meta_logo.jpg"/>
|
||||
<!-- Add more Twitter meta tags as needed -->
|
||||
|
||||
</svelte:head>
|
||||
|
||||
<section in:fly={{ x: -10, duration: 150, delay: 150 }} out:fly={{ x: 5, duration: 150 }} class="w-full max-w-4xl overflow-hidden m-auto min-h-screen pt-5 pb-40">
|
||||
<section class="w-full max-w-4xl overflow-hidden m-auto min-h-screen pt-5 pb-40">
|
||||
<!--
|
||||
<div class="text-sm breadcrumbs ml-4">
|
||||
<ul>
|
||||
@ -87,7 +84,7 @@ $: {
|
||||
</div>
|
||||
-->
|
||||
|
||||
<div class="w-full max-w-4xl m-auto sm:bg-[#09090B] sm:rounded-xl h-auto pl-10 pr-10 pt-5 sm:pb-10 sm:pt-10 mt-3 mb-8">
|
||||
<div class="w-full max-w-4xl m-auto sm:bg-[#27272A] sm:rounded-xl h-auto pl-10 pr-10 pt-5 sm:pb-10 sm:pt-10 mt-3 mb-8">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-10">
|
||||
|
||||
<!-- Start Column -->
|
||||
|
||||
@ -1,24 +1,8 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
|
||||
export const load = async () => {
|
||||
export const load = async ({parent}) => {
|
||||
const getETFList = async () => {
|
||||
let output;
|
||||
|
||||
@ -28,7 +12,7 @@ export const load = async () => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
|
||||
const {apiKey, apiURL} = await parent();
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(apiURL + '/all-etf-tickers', {
|
||||
method: 'GET',
|
||||
|
||||
@ -10,16 +10,16 @@ export const load = async ({ parent, params }) => {
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
} else {
|
||||
const data = await parent();
|
||||
const {apiKey, apiURL} = await parent();
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/congress-trading-ticker', {
|
||||
const response = await fetch(apiURL + '/congress-trading-ticker', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -10,16 +10,16 @@ export const load = async ({ parent, params }) => {
|
||||
if (cachedData) {
|
||||
newsList = cachedData;
|
||||
} else {
|
||||
const data = await parent();
|
||||
const {apiKey, apiURL} = await parent();
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/stock-dividend', {
|
||||
const response = await fetch(apiURL + '/stock-dividend', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -11,16 +11,16 @@ export const load = async ({ parent, params }) => {
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
} else {
|
||||
const data = await parent();
|
||||
const {apiKey, apiURL} = await parent();
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/etf-holdings', {
|
||||
const response = await fetch(apiURL + '/etf-holdings', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -10,16 +10,16 @@ export const load = async ({ parent, params }) => {
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
} else {
|
||||
const data = await parent();
|
||||
const {apiKey, apiURL} = await parent();
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/stock-news', {
|
||||
const response = await fetch(apiURL + '/stock-news', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -1,19 +1,4 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL = import.meta.env.VITE_EU_API_URL; // Set a default API URL
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
function daysLeft(targetDate) {
|
||||
@ -28,9 +13,10 @@ function daysLeft(targetDate) {
|
||||
}
|
||||
|
||||
|
||||
export const load = async ({ params }) => {
|
||||
export const load = async ({ parent, params }) => {
|
||||
|
||||
const {apiKey, apiURL} = await parent();
|
||||
|
||||
|
||||
const getOptionsPlotData = async () => {
|
||||
let res;
|
||||
|
||||
@ -39,7 +25,6 @@ export const load = async ({ params }) => {
|
||||
res = cachedData;
|
||||
} else {
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
@ -1,19 +1,7 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
if (usRegion.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
export const load = async ({ params }) => {
|
||||
export const load = async ({ parent, params }) => {
|
||||
|
||||
|
||||
const getQuantStats = async () => {
|
||||
@ -24,6 +12,9 @@ export const load = async ({ params }) => {
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const {apiKey, apiURL} = await parent();
|
||||
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
@ -1,32 +1,18 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
export const load = async ({parent}) => {
|
||||
const getFDACalendar = async () => {
|
||||
let output;
|
||||
const data = await parent();
|
||||
|
||||
const cachedData = getCache('', 'getFDACalendar');
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
} else {
|
||||
// make the POST request to the endpoint
|
||||
|
||||
const { apiURL, apiKey, user} = await parent();
|
||||
|
||||
const response = await fetch(apiURL + '/fda-calendar', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
@ -36,7 +22,7 @@ export const load = async ({parent}) => {
|
||||
|
||||
output = await response.json();
|
||||
|
||||
output = data?.user?.tier !== 'Pro' ? output?.slice(0,6) : output;
|
||||
output = user?.tier !== 'Pro' ? output?.slice(0,6) : output;
|
||||
|
||||
setCache('', output, 'getFDACalendar');
|
||||
|
||||
|
||||
@ -1,24 +1,12 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion?.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
|
||||
export const load = async () => {
|
||||
|
||||
export const load = async ({parent}) => {
|
||||
|
||||
const { apiURL, apiKey} = await parent();
|
||||
|
||||
const getSP500HeatMap = async () => {
|
||||
let output;
|
||||
|
||||
|
||||
@ -11,14 +11,15 @@ export const load = async ({parent, params}) => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const data = await parent();
|
||||
const { apiURL, apiKey} = await parent();
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const postData = {'year': 'all'};
|
||||
|
||||
const response = await fetch(data?.apiURL + '/ipo-calendar', {
|
||||
const response = await fetch(apiURL + '/ipo-calendar', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
@ -10,14 +10,14 @@ export const load = async ({parent, params}) => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const data = await parent();
|
||||
const { apiURL, apiKey} = await parent();
|
||||
// make the POST request to the endpoint
|
||||
const postData = {'year': params.slug};
|
||||
|
||||
const response = await fetch(data?.apiURL + '/ipo-calendar', {
|
||||
const response = await fetch(apiURL + '/ipo-calendar', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
@ -1,24 +1,12 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
|
||||
export const load = async () => {
|
||||
export const load = async ({parent}) => {
|
||||
|
||||
const { apiURL, apiKey} = await parent();
|
||||
|
||||
|
||||
const getDailyGainerLoserActive = async () => {
|
||||
let output;
|
||||
|
||||
|
||||
@ -1,26 +1,12 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
export const load = async ({parent}) => {
|
||||
const getMostRetailVolume = async () => {
|
||||
let output;
|
||||
const data = await parent();
|
||||
const {apiKey, apiURL, user} = await parent();
|
||||
|
||||
|
||||
const cachedData = getCache('', 'getMostRetailVolume');
|
||||
if (cachedData) {
|
||||
@ -36,7 +22,7 @@ export const load = async ({parent}) => {
|
||||
|
||||
output = await response.json();
|
||||
|
||||
output = data?.user?.tier !== 'Pro' ? output?.slice(0,6) : output;
|
||||
output = user?.tier !== 'Pro' ? output?.slice(0,6) : output;
|
||||
|
||||
setCache('', output, 'getMostRetailVolume');
|
||||
|
||||
|
||||
@ -1,32 +1,16 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
export const load = async ({parent}) => {
|
||||
const getMostShortedStocks = async () => {
|
||||
let output;
|
||||
const data = await parent();
|
||||
const {apiKey, apiURL, user} = await parent();
|
||||
|
||||
const cachedData = getCache('', 'getMostShortedStocks');
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
} else {
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(apiURL + '/most-shorted-stocks', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
@ -36,7 +20,7 @@ export const load = async ({parent}) => {
|
||||
|
||||
output = await response.json();
|
||||
|
||||
output = data?.user?.tier !== 'Pro' ? output?.slice(0,6) : output;
|
||||
output = user?.tier !== 'Pro' ? output?.slice(0,6) : output;
|
||||
|
||||
setCache('', output, 'getMostShortedStocks');
|
||||
|
||||
|
||||
@ -1,18 +1,6 @@
|
||||
import { redirect, error} from '@sveltejs/kit';
|
||||
import { userRegion } from '$lib/store';
|
||||
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
let fastifyURL = import.meta.env.VITE_EU_FASTIFY_URL;
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
if (usRegion.includes(value)) {
|
||||
fastifyURL = import.meta.env.VITE_USEAST_FASTIFY_URL;
|
||||
} else {
|
||||
fastifyURL = import.meta.env.VITE_EU_FASTIFY_URL;
|
||||
}
|
||||
});
|
||||
|
||||
export const load = async ({ locals }) => {
|
||||
|
||||
if (!locals.pb.authStore.isValid) {
|
||||
@ -23,7 +11,7 @@ export const load = async ({ locals }) => {
|
||||
|
||||
const postData = {'userId': locals?.user?.id};
|
||||
|
||||
const response = await fetch(fastifyURL+'/get-notifications', {
|
||||
const response = await fetch(locals?.fastifyURL+'/get-notifications', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
|
||||
@ -1,24 +1,8 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
import defaultAvatar from '$lib/images/senator/default-avatar.png';
|
||||
import { getPartyForPoliticians } from '$lib/utils';
|
||||
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion?.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
let images = {};
|
||||
// Function to load images only when they are viewed
|
||||
@ -39,7 +23,7 @@ async function loadImages() {
|
||||
}
|
||||
|
||||
|
||||
export const load = async () => {
|
||||
export const load = async ({parent}) => {
|
||||
const getAllPolitician = async () => {
|
||||
let output;
|
||||
|
||||
@ -49,6 +33,9 @@ export const load = async () => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const {apiKey, apiURL} = await parent();
|
||||
|
||||
|
||||
const response = await fetch(apiURL + '/all-politicians', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
|
||||
@ -1,28 +1,13 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
import defaultAvatar from '$lib/images/senator/default-avatar.png';
|
||||
import { getPartyForPoliticians } from '$lib/utils';
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
let images = {};
|
||||
let politicianImage;
|
||||
let politicianDistrict;
|
||||
let politicianCongress;
|
||||
let politicianParty = 'n/a';
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion?.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Function to load images only when they are viewed
|
||||
async function loadImages() {
|
||||
const imageFiles = import.meta.glob('$lib/images/senator/*.png');
|
||||
@ -41,7 +26,7 @@ userRegion.subscribe(value => {
|
||||
}
|
||||
|
||||
|
||||
export const load = async ({params}) => {
|
||||
export const load = async ({parent, params}) => {
|
||||
const getPolitician = async () => {
|
||||
let res;
|
||||
|
||||
@ -50,9 +35,10 @@ export const load = async ({params}) => {
|
||||
if (cachedData) {
|
||||
res = cachedData;
|
||||
} else {
|
||||
const { apiURL, apiKey} = await parent();
|
||||
|
||||
const postData = {'politicianId': params.slug}
|
||||
// make the POST request to the endpoint
|
||||
const postData = {'politicianId': params.slug}
|
||||
|
||||
const response = await fetch(apiURL + '/politician-stats', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
||||
@ -1,23 +1,8 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
import defaultAvatar from '$lib/images/senator/default-avatar.png';
|
||||
import { getPartyForPoliticians } from '$lib/utils';
|
||||
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion?.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
let images = {};
|
||||
// Function to load images only when they are viewed
|
||||
@ -38,7 +23,7 @@ async function loadImages() {
|
||||
}
|
||||
|
||||
|
||||
export const load = async () => {
|
||||
export const load = async ({parent}) => {
|
||||
const getPoliticianRSS = async () => {
|
||||
let output;
|
||||
|
||||
@ -48,6 +33,8 @@ export const load = async () => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const {apiKey, apiURL} = await parent();
|
||||
|
||||
const response = await fetch(apiURL + '/congress-rss-feed', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
|
||||
@ -1,24 +1,7 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
userRegion?.subscribe(value => {
|
||||
|
||||
if (usRegion?.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
export const load = async () => {
|
||||
export const load = async ({parent}) => {
|
||||
|
||||
const getMiniPlotsIndex = async () => {
|
||||
let output;
|
||||
@ -28,7 +11,7 @@ export const load = async () => {
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const {apiKey, apiURL} = await parent();
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(apiURL + '/mini-plots-index', {
|
||||
method: 'GET',
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<script lang='ts'>
|
||||
import { goto } from '$app/navigation';
|
||||
import { strategyId, userRegion, screenWidth, numberOfUnreadNotification } from '$lib/store';
|
||||
import { strategyId, screenWidth, numberOfUnreadNotification } from '$lib/store';
|
||||
import Input from '$lib/components/Input.svelte';
|
||||
import toast from 'svelte-french-toast';
|
||||
import logo from "$lib/images/stock_screener_logo.png";
|
||||
@ -9,24 +9,6 @@
|
||||
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
let fastifyURL;
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
fastifyURL = import.meta.env.VITE_USEAST_FASTIFY_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
fastifyURL = import.meta.env.VITE_EU_FASTIFY_URL;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
export let data;
|
||||
export let form;
|
||||
@ -37,7 +19,7 @@ let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
async function getAllStrategies()
|
||||
{
|
||||
const postData = {'userId': data?.user?.id}
|
||||
const response = await fetch(fastifyURL+'/all-strategies', {
|
||||
const response = await fetch(data?.fastifyURL+'/all-strategies', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@ -85,7 +67,7 @@ async function createStrategy(event)
|
||||
|
||||
|
||||
|
||||
const response = await fetch(fastifyURL+'/create-strategy', {
|
||||
const response = await fetch(data?.fastifyURL+'/create-strategy', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@ -143,7 +125,7 @@ onMount(async () => {
|
||||
|
||||
const postData = {'strategyId': deleteStrategyId};
|
||||
|
||||
const response = await fetch(fastifyURL+'/delete-strategy', {
|
||||
const response = await fetch(data?.fastifyURL+'/delete-strategy', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
|
||||
@ -1,28 +1,12 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
let fastifyURL;
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
fastifyURL = import.meta.env.VITE_USEAST_FASTIFY_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
fastifyURL = import.meta.env.VITE_EU_FASTIFY_URL;
|
||||
}
|
||||
});
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
|
||||
|
||||
export const load = async ({parent, params}) => {
|
||||
|
||||
export const load = async ({params}) => {
|
||||
|
||||
const { apiURL, apiKey, fastifyURL} = await parent();
|
||||
|
||||
const getStrategyId = async () => {
|
||||
return params.strategyId;
|
||||
@ -83,8 +67,5 @@ export const load = async ({params}) => {
|
||||
getStockScreenerData: await getStockScreenerData(),
|
||||
getStrategy: await getStrategy(),
|
||||
getStrategyId: await getStrategyId(),
|
||||
apiURL,
|
||||
fastifyURL,
|
||||
apiKey,
|
||||
};
|
||||
};
|
||||
@ -3,7 +3,6 @@ import { goto } from '$app/navigation';
|
||||
import { screenWidth, numberOfUnreadNotification } from '$lib/store';
|
||||
import { abbreviateNumber } from '$lib/utils';
|
||||
import { page } from '$app/stores';
|
||||
import { fly } from 'svelte/transition';
|
||||
import logo from '$lib/images/box_logo.png';
|
||||
|
||||
import InfiniteLoading from '$lib/components/InfiniteLoading.svelte';
|
||||
@ -78,7 +77,7 @@ $: {
|
||||
|
||||
|
||||
|
||||
<section in:fly={{ x: -10, duration: 150, delay: 150 }} out:fly={{ x: 5, duration: 150 }} class="w-full max-w-4xl overflow-hidden m-auto min-h-screen pt-5 pb-40">
|
||||
<section class="w-full max-w-4xl overflow-hidden m-auto min-h-screen pt-5 pb-40">
|
||||
|
||||
<!--
|
||||
<div class="text-sm breadcrumbs ml-4">
|
||||
@ -89,7 +88,7 @@ $: {
|
||||
</div>
|
||||
-->
|
||||
|
||||
<div class="w-full max-w-4xl m-auto sm:bg-[#09090B] sm:rounded-xl h-auto pl-10 pr-10 pt-5 sm:pb-10 sm:pt-10 mt-3 mb-8">
|
||||
<div class="w-full max-w-4xl m-auto sm:bg-[#27272A] sm:rounded-xl h-auto pl-10 pr-10 pt-5 sm:pb-10 sm:pt-10 mt-3 mb-8">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-10">
|
||||
|
||||
<!-- Start Column -->
|
||||
|
||||
@ -1,24 +1,7 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
export const load = async () => {
|
||||
export const load = async ({parent}) => {
|
||||
const getStockList = async () => {
|
||||
let output;
|
||||
// Get cached data for the specific tickerID
|
||||
@ -27,7 +10,8 @@ export const load = async () => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
|
||||
const {apiKey, apiURL} = await parent();
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(apiURL + '/all-stock-tickers', {
|
||||
method: 'GET',
|
||||
|
||||
@ -12,16 +12,17 @@ export const load = async ({ parent, params }) => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const data = await parent();
|
||||
const {apiURL, apiKey} = await parent();
|
||||
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/analyst-ticker-history', {
|
||||
const response = await fetch(apiURL + '/analyst-ticker-history', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -11,17 +11,17 @@ export const load = async ({ parent, params }) => {
|
||||
newsList = cachedData;
|
||||
} else {
|
||||
|
||||
const data = await parent();
|
||||
const {apiURL, apiKey} = await parent();
|
||||
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/stock-dividend', {
|
||||
const response = await fetch(apiURL + '/stock-dividend', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -26,7 +26,7 @@ const transactionTypeMap = {
|
||||
|
||||
export const load = async ({ parent, params }) => {
|
||||
|
||||
const data = await parent();
|
||||
const {apiURL, apiKey} = await parent();
|
||||
|
||||
|
||||
const getInsiderTrading = async () => {
|
||||
@ -42,10 +42,10 @@ export const load = async ({ parent, params }) => {
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/insider-trading', {
|
||||
const response = await fetch(apiURL + '/insider-trading', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
@ -80,10 +80,10 @@ export const load = async ({ parent, params }) => {
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/insider-trading-statistics', {
|
||||
const response = await fetch(apiURL + '/insider-trading-statistics', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
@ -110,10 +110,10 @@ async function historicalPrice() {
|
||||
timePeriod: 'max',
|
||||
};
|
||||
|
||||
const response = await fetch(data?.apiURL+'/historical-price', {
|
||||
const response = await fetch(apiURL+'/historical-price', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
@ -123,7 +123,7 @@ async function historicalPrice() {
|
||||
//Adding this would create a bug hence I cant use the historicalPrice endpoint such as in +page.svelte but rather need to call
|
||||
// it again without modification.
|
||||
/*
|
||||
output= (data) => data?.map(({ time, open, high, low, close }) => ({
|
||||
output= (data) => map(({ time, open, high, low, close }) => ({
|
||||
time: Date.parse(time),
|
||||
open,
|
||||
high,
|
||||
|
||||
@ -12,17 +12,17 @@ export const load = async ({ parent, params }) => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const data = await parent();
|
||||
const {apiURL, apiKey} = await parent();
|
||||
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/congress-trading-ticker', {
|
||||
const response = await fetch(apiURL + '/congress-trading-ticker', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -12,17 +12,17 @@ export const load = async ({ parent, params }) => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const data = await parent();
|
||||
const {apiURL, apiKey} = await parent();
|
||||
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/stock-news', {
|
||||
const response = await fetch(apiURL + '/stock-news', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -16,7 +16,7 @@ function daysLeft(targetDate) {
|
||||
export const load = async ({ parent, params }) => {
|
||||
|
||||
|
||||
const data = await parent();
|
||||
const {apiKey, apiURL} = await parent();
|
||||
|
||||
|
||||
const getOptionsPlotData = async () => {
|
||||
@ -31,10 +31,10 @@ export const load = async ({ parent, params }) => {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
const response = await fetch(data?.apiURL + '/options-plot-ticker', {
|
||||
const response = await fetch(apiURL + '/options-plot-ticker', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
@ -92,10 +92,10 @@ export const load = async ({ parent, params }) => {
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/options-flow-ticker', {
|
||||
const response = await fetch(apiURL + '/options-flow-ticker', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -14,17 +14,17 @@ export const load = async ({ parent, params }) => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const data = await parent();
|
||||
const {apiKey, apiURL} = await parent();
|
||||
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/get-quant-stats', {
|
||||
const response = await fetch(apiURL + '/get-quant-stats', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -12,16 +12,16 @@ export const load = async ({ parent, params }) => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const data = await parent();
|
||||
const {apiKey, apiURL} = await parent();
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/stock-balance-sheet', {
|
||||
const response = await fetch(apiURL + '/stock-balance-sheet', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -11,17 +11,17 @@ export const load = async ({ parent, params }) => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const data = await parent();
|
||||
const {apiKey, apiURL} = await parent();
|
||||
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/stock-cash-flow', {
|
||||
const response = await fetch(apiURL + '/stock-cash-flow', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -10,16 +10,16 @@ export const load = async ({ parent, params }) => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const data = await parent();
|
||||
const {apiKey, apiURL} = await parent();
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/history-employees', {
|
||||
const response = await fetch(apiURL + '/history-employees', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -11,16 +11,16 @@ export const load = async ({ parent, params }) => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const data = await parent();
|
||||
const {apiKey, apiURL} = await parent();
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/stock-income', {
|
||||
const response = await fetch(apiURL + '/stock-income', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -11,16 +11,16 @@ export const load = async ({ parent, params }) => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const data = await parent();
|
||||
const {apiKey, apiURL} = await parent();
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/stock-ratios', {
|
||||
const response = await fetch(apiURL + '/stock-ratios', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -1,23 +1,8 @@
|
||||
import { userRegion, getCache, setCache } from '$lib/store';
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
}
|
||||
});
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
|
||||
export const load = async () => {
|
||||
export const load = async ({parent}) => {
|
||||
|
||||
const getMiniPlotsIndex = async () => {
|
||||
let output;
|
||||
@ -27,6 +12,7 @@ export const load = async () => {
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
} else {
|
||||
const {apiKey, apiURL} = await parent();
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(apiURL + '/mini-plots-index', {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user