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 userRegion = regionHeader.split('::')[0];
|
||||||
|
|
||||||
const isUsRegion = usRegion.has(userRegion);
|
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 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 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'];
|
const wsURL = import.meta.env[isUsRegion ? 'VITE_USEAST_WS_URL' : 'VITE_EU_WS_URL'];
|
||||||
|
|
||||||
event.locals = {
|
event.locals = {
|
||||||
region: decodeURIComponent(regionHeader),
|
region: decodeURIComponent(regionHeader),
|
||||||
pb: new PocketBase(pbUrl),
|
pb: new PocketBase(pbURL),
|
||||||
apiURL,
|
apiURL,
|
||||||
fastifyURL,
|
fastifyURL,
|
||||||
wsURL,
|
wsURL,
|
||||||
|
|||||||
@ -1,27 +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 } ) => {
|
export const load = async ({parent}) => {
|
||||||
|
|
||||||
const getTopAnalyst = async () => {
|
const getTopAnalyst = async () => {
|
||||||
const data = await parent()
|
const { apiURL, apiKey, user} = await parent();
|
||||||
|
|
||||||
let output;
|
let output;
|
||||||
|
|
||||||
const cachedData = getCache('', 'getTopAnalyst');
|
const cachedData = getCache('', 'getTopAnalyst');
|
||||||
@ -40,7 +25,7 @@ export const load = async ( { parent } ) => {
|
|||||||
setCache('', output, 'getTopAnalyst');
|
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;
|
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'];
|
export const load = async ({parent, params}) => {
|
||||||
|
|
||||||
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}) => {
|
|
||||||
const getAnalystStats = async () => {
|
const getAnalystStats = async () => {
|
||||||
let output;
|
let output;
|
||||||
|
|
||||||
@ -28,6 +11,8 @@ export const load = async ({params}) => {
|
|||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
const { apiURL, apiKey} = await parent();
|
||||||
|
|
||||||
const postData = {'analystId': params.slug}
|
const postData = {'analystId': params.slug}
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(apiURL + '/analyst-stats', {
|
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}) => {
|
export const load = async ({parent}) => {
|
||||||
const getTopAnalystStocks = async () => {
|
const getTopAnalystStocks = async () => {
|
||||||
let output;
|
let output;
|
||||||
const data = await parent();
|
const { apiURL, apiKey, user} = await parent();
|
||||||
|
|
||||||
const cachedData = getCache('', 'getTopAnalystStocks');
|
const cachedData = getCache('', 'getTopAnalystStocks');
|
||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} 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',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
"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;
|
return output;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -2,10 +2,10 @@ import { pb } from "$lib/pocketbase";
|
|||||||
import { getCache, setCache } from '$lib/store';
|
import { getCache, setCache } from '$lib/store';
|
||||||
|
|
||||||
|
|
||||||
export const load = async () => {
|
export const load = async ({parent}) => {
|
||||||
const getAllBlogPost = async () => {
|
const getAllBlogPost = async () => {
|
||||||
let output;
|
let output;
|
||||||
|
console.log(await parent())
|
||||||
// Get cached data for the specific tickerID
|
// Get cached data for the specific tickerID
|
||||||
const cachedData = getCache('allBlogPost', 'getAllBlogPost');
|
const cachedData = getCache('allBlogPost', 'getAllBlogPost');
|
||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
|
|||||||
@ -51,7 +51,6 @@ $: {
|
|||||||
<!-- Other meta tags -->
|
<!-- Other meta tags -->
|
||||||
<meta property="og:title" content={`List of All Crypto Ticker Symbols · stocknear`}/>
|
<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: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"/>
|
<meta property="og:type" content="website"/>
|
||||||
<!-- Add more Open Graph meta tags as needed -->
|
<!-- Add more Open Graph meta tags as needed -->
|
||||||
|
|
||||||
@ -59,7 +58,6 @@ $: {
|
|||||||
<meta name="twitter:card" content="summary_large_image"/>
|
<meta name="twitter:card" content="summary_large_image"/>
|
||||||
<meta name="twitter:title" content={`List of All Crypto Ticker Symbols · stocknear`}/>
|
<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: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 -->
|
<!-- Add more Twitter meta tags as needed -->
|
||||||
|
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
@ -74,7 +72,7 @@ $: {
|
|||||||
</div>
|
</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">
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-10">
|
||||||
|
|
||||||
<!-- Start Column -->
|
<!-- Start Column -->
|
||||||
|
|||||||
@ -1,24 +1,8 @@
|
|||||||
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 getCryptoList = async () => {
|
const getCryptoList = async () => {
|
||||||
let output;
|
let output;
|
||||||
|
|
||||||
@ -28,8 +12,7 @@ export const load = async () => {
|
|||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
const {apiKey, apiURL} = await parent();
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + '/all-crypto-tickers', {
|
const response = await fetch(apiURL + '/all-crypto-tickers', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@ -1,24 +1,9 @@
|
|||||||
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 getSenateTrading = async () => {
|
const getSenateTrading = async () => {
|
||||||
let output;
|
let output;
|
||||||
|
|
||||||
@ -27,6 +12,9 @@ export const load = async ({ params }) => {
|
|||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
const {apiKey, apiURL} = await parent();
|
||||||
|
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: params.tickerID
|
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'];
|
export const load = async ({ parent, params }) => {
|
||||||
|
|
||||||
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 }) => {
|
|
||||||
const getStockNews = async () => {
|
const getStockNews = async () => {
|
||||||
let output;
|
let output;
|
||||||
|
|
||||||
@ -26,6 +10,9 @@ export const load = async ({ params }) => {
|
|||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
const {apiKey, apiURL} = await parent();
|
||||||
|
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: params.tickerID
|
ticker: params.tickerID
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,19 +1,8 @@
|
|||||||
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 getQuantStats = async () => {
|
const getQuantStats = async () => {
|
||||||
@ -24,6 +13,8 @@ export const load = async ({ params }) => {
|
|||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
const {apiKey, apiURL} = await parent();
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: params.tickerID
|
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 () => {
|
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}) => {
|
export const load = async ({parent}) => {
|
||||||
|
|
||||||
checkMarketHour()
|
checkMarketHour()
|
||||||
const getDarkPoolFlow = async () => {
|
const getDarkPoolFlow = async () => {
|
||||||
let output;
|
let output;
|
||||||
const data = await parent();
|
|
||||||
|
|
||||||
const cachedData = getCache('', 'getDarkPoolFlow');
|
const cachedData = getCache('', 'getDarkPoolFlow');
|
||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
// make the POST request to the endpoint
|
|
||||||
|
const {apiKey, apiURL} = await parent();
|
||||||
const response = await fetch(apiURL + '/dark-pool-flow', {
|
const response = await fetch(apiURL + '/dark-pool-flow', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@ -11,12 +11,12 @@ export const load = async ({parent}) => {
|
|||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const data = await parent();
|
const {apiKey, apiURL} = await parent();
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(data?.apiURL + '/dividends-calendar', {
|
const response = await fetch(apiURL + '/dividends-calendar', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
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;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const data = await parent();
|
const {apiKey, apiURL} = await parent();
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(data?.apiURL + '/earnings-calendar', {
|
const response = await fetch(apiURL + '/earnings-calendar', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
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 { numberOfUnreadNotification, screenWidth } from '$lib/store';
|
||||||
import { abbreviateNumber } from '$lib/utils';
|
import { abbreviateNumber } from '$lib/utils';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
import { fly } from 'svelte/transition';
|
|
||||||
import logo from '$lib/images/box_logo.png';
|
import logo from '$lib/images/box_logo.png';
|
||||||
|
|
||||||
import InfiniteLoading from '$lib/components/InfiniteLoading.svelte';
|
import InfiniteLoading from '$lib/components/InfiniteLoading.svelte';
|
||||||
@ -64,7 +63,6 @@ $: {
|
|||||||
<!-- Other meta tags -->
|
<!-- Other meta tags -->
|
||||||
<meta property="og:title" content={`List of All ETF Ticker Symbols · stocknear`}/>
|
<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: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"/>
|
<meta property="og:type" content="website"/>
|
||||||
<!-- Add more Open Graph meta tags as needed -->
|
<!-- Add more Open Graph meta tags as needed -->
|
||||||
|
|
||||||
@ -72,12 +70,11 @@ $: {
|
|||||||
<meta name="twitter:card" content="summary_large_image"/>
|
<meta name="twitter:card" content="summary_large_image"/>
|
||||||
<meta name="twitter:title" content={`List of All ETF Ticker Symbols · stocknear`}/>
|
<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: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 -->
|
<!-- Add more Twitter meta tags as needed -->
|
||||||
|
|
||||||
</svelte:head>
|
</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">
|
<div class="text-sm breadcrumbs ml-4">
|
||||||
<ul>
|
<ul>
|
||||||
@ -87,7 +84,7 @@ $: {
|
|||||||
</div>
|
</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">
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-10">
|
||||||
|
|
||||||
<!-- Start Column -->
|
<!-- Start Column -->
|
||||||
|
|||||||
@ -1,24 +1,8 @@
|
|||||||
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 getETFList = async () => {
|
const getETFList = async () => {
|
||||||
let output;
|
let output;
|
||||||
|
|
||||||
@ -28,7 +12,7 @@ export const load = async () => {
|
|||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
const {apiKey, apiURL} = await parent();
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(apiURL + '/all-etf-tickers', {
|
const response = await fetch(apiURL + '/all-etf-tickers', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
|||||||
@ -10,16 +10,16 @@ export const load = async ({ parent, params }) => {
|
|||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
const data = await parent();
|
const {apiKey, apiURL} = await parent();
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: params.tickerID
|
ticker: params.tickerID
|
||||||
};
|
};
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
// 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',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,16 +10,16 @@ export const load = async ({ parent, params }) => {
|
|||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
newsList = cachedData;
|
newsList = cachedData;
|
||||||
} else {
|
} else {
|
||||||
const data = await parent();
|
const {apiKey, apiURL} = await parent();
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: params.tickerID
|
ticker: params.tickerID
|
||||||
};
|
};
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(data?.apiURL + '/stock-dividend', {
|
const response = await fetch(apiURL + '/stock-dividend', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -11,16 +11,16 @@ export const load = async ({ parent, params }) => {
|
|||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
const data = await parent();
|
const {apiKey, apiURL} = await parent();
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: params.tickerID
|
ticker: params.tickerID
|
||||||
};
|
};
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(data?.apiURL + '/etf-holdings', {
|
const response = await fetch(apiURL + '/etf-holdings', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,16 +10,16 @@ export const load = async ({ parent, params }) => {
|
|||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
const data = await parent();
|
const {apiKey, apiURL} = await parent();
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: params.tickerID
|
ticker: params.tickerID
|
||||||
};
|
};
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(data?.apiURL + '/stock-news', {
|
const response = await fetch(apiURL + '/stock-news', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,19 +1,4 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function daysLeft(targetDate) {
|
function daysLeft(targetDate) {
|
||||||
@ -28,8 +13,9 @@ function daysLeft(targetDate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const load = async ({ params }) => {
|
export const load = async ({ parent, params }) => {
|
||||||
|
|
||||||
|
const {apiKey, apiURL} = await parent();
|
||||||
|
|
||||||
const getOptionsPlotData = async () => {
|
const getOptionsPlotData = async () => {
|
||||||
let res;
|
let res;
|
||||||
@ -39,7 +25,6 @@ export const load = async ({ params }) => {
|
|||||||
res = cachedData;
|
res = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: params.tickerID
|
ticker: params.tickerID
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,19 +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 getQuantStats = async () => {
|
const getQuantStats = async () => {
|
||||||
@ -24,6 +12,9 @@ export const load = async ({ params }) => {
|
|||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
const {apiKey, apiURL} = await parent();
|
||||||
|
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: params.tickerID
|
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}) => {
|
export const load = async ({parent}) => {
|
||||||
const getFDACalendar = async () => {
|
const getFDACalendar = async () => {
|
||||||
let output;
|
let output;
|
||||||
const data = await parent();
|
|
||||||
|
|
||||||
const cachedData = getCache('', 'getFDACalendar');
|
const cachedData = getCache('', 'getFDACalendar');
|
||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
// make the POST request to the endpoint
|
|
||||||
|
const { apiURL, apiKey, user} = await parent();
|
||||||
|
|
||||||
const response = await fetch(apiURL + '/fda-calendar', {
|
const response = await fetch(apiURL + '/fda-calendar', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
@ -36,7 +22,7 @@ export const load = async ({parent}) => {
|
|||||||
|
|
||||||
output = await response.json();
|
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');
|
setCache('', output, 'getFDACalendar');
|
||||||
|
|
||||||
|
|||||||
@ -1,24 +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 () => {
|
|
||||||
|
export const load = async ({parent}) => {
|
||||||
|
|
||||||
|
const { apiURL, apiKey} = await parent();
|
||||||
|
|
||||||
const getSP500HeatMap = async () => {
|
const getSP500HeatMap = async () => {
|
||||||
let output;
|
let output;
|
||||||
|
|
||||||
|
|||||||
@ -11,14 +11,15 @@ export const load = async ({parent, params}) => {
|
|||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const data = await parent();
|
const { apiURL, apiKey} = await parent();
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const postData = {'year': 'all'};
|
const postData = {'year': 'all'};
|
||||||
|
|
||||||
const response = await fetch(data?.apiURL + '/ipo-calendar', {
|
const response = await fetch(apiURL + '/ipo-calendar', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData),
|
body: JSON.stringify(postData),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,14 +10,14 @@ export const load = async ({parent, params}) => {
|
|||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const data = await parent();
|
const { apiURL, apiKey} = await parent();
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const postData = {'year': params.slug};
|
const postData = {'year': params.slug};
|
||||||
|
|
||||||
const response = await fetch(data?.apiURL + '/ipo-calendar', {
|
const response = await fetch(apiURL + '/ipo-calendar', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData),
|
body: JSON.stringify(postData),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,24 +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 () => {
|
export const load = async ({parent}) => {
|
||||||
|
|
||||||
|
const { apiURL, apiKey} = await parent();
|
||||||
|
|
||||||
|
|
||||||
const getDailyGainerLoserActive = async () => {
|
const getDailyGainerLoserActive = async () => {
|
||||||
let output;
|
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}) => {
|
export const load = async ({parent}) => {
|
||||||
const getMostRetailVolume = async () => {
|
const getMostRetailVolume = async () => {
|
||||||
let output;
|
let output;
|
||||||
const data = await parent();
|
const {apiKey, apiURL, user} = await parent();
|
||||||
|
|
||||||
|
|
||||||
const cachedData = getCache('', 'getMostRetailVolume');
|
const cachedData = getCache('', 'getMostRetailVolume');
|
||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
@ -36,7 +22,7 @@ export const load = async ({parent}) => {
|
|||||||
|
|
||||||
output = await response.json();
|
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');
|
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}) => {
|
export const load = async ({parent}) => {
|
||||||
const getMostShortedStocks = async () => {
|
const getMostShortedStocks = async () => {
|
||||||
let output;
|
let output;
|
||||||
const data = 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 {
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + '/most-shorted-stocks', {
|
const response = await fetch(apiURL + '/most-shorted-stocks', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
@ -36,7 +20,7 @@ export const load = async ({parent}) => {
|
|||||||
|
|
||||||
output = await response.json();
|
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');
|
setCache('', output, 'getMostShortedStocks');
|
||||||
|
|
||||||
|
|||||||
@ -1,18 +1,6 @@
|
|||||||
import { redirect, error} from '@sveltejs/kit';
|
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 }) => {
|
export const load = async ({ locals }) => {
|
||||||
|
|
||||||
if (!locals.pb.authStore.isValid) {
|
if (!locals.pb.authStore.isValid) {
|
||||||
@ -23,7 +11,7 @@ export const load = async ({ locals }) => {
|
|||||||
|
|
||||||
const postData = {'userId': locals?.user?.id};
|
const postData = {'userId': locals?.user?.id};
|
||||||
|
|
||||||
const response = await fetch(fastifyURL+'/get-notifications', {
|
const response = await fetch(locals?.fastifyURL+'/get-notifications', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"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 defaultAvatar from '$lib/images/senator/default-avatar.png';
|
||||||
import { getPartyForPoliticians } from '$lib/utils';
|
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 = {};
|
let images = {};
|
||||||
// Function to load images only when they are viewed
|
// 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 () => {
|
const getAllPolitician = async () => {
|
||||||
let output;
|
let output;
|
||||||
|
|
||||||
@ -49,6 +33,9 @@ export const load = async () => {
|
|||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
const {apiKey, apiURL} = await parent();
|
||||||
|
|
||||||
|
|
||||||
const response = await fetch(apiURL + '/all-politicians', {
|
const response = await fetch(apiURL + '/all-politicians', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
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 defaultAvatar from '$lib/images/senator/default-avatar.png';
|
||||||
import { getPartyForPoliticians } from '$lib/utils';
|
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 images = {};
|
||||||
let politicianImage;
|
let politicianImage;
|
||||||
let politicianDistrict;
|
let politicianDistrict;
|
||||||
let politicianCongress;
|
let politicianCongress;
|
||||||
let politicianParty = 'n/a';
|
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
|
// Function to load images only when they are viewed
|
||||||
async function loadImages() {
|
async function loadImages() {
|
||||||
const imageFiles = import.meta.glob('$lib/images/senator/*.png');
|
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 () => {
|
const getPolitician = async () => {
|
||||||
let res;
|
let res;
|
||||||
|
|
||||||
@ -50,9 +35,10 @@ export const load = async ({params}) => {
|
|||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
res = cachedData;
|
res = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
const { apiURL, apiKey} = await parent();
|
||||||
|
|
||||||
|
const postData = {'politicianId': params.slug}
|
||||||
|
|
||||||
const postData = {'politicianId': params.slug}
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + '/politician-stats', {
|
const response = await fetch(apiURL + '/politician-stats', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
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 defaultAvatar from '$lib/images/senator/default-avatar.png';
|
||||||
import { getPartyForPoliticians } from '$lib/utils';
|
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 = {};
|
let images = {};
|
||||||
// Function to load images only when they are viewed
|
// 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 () => {
|
const getPoliticianRSS = async () => {
|
||||||
let output;
|
let output;
|
||||||
|
|
||||||
@ -48,6 +33,8 @@ export const load = async () => {
|
|||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
const {apiKey, apiURL} = await parent();
|
||||||
|
|
||||||
const response = await fetch(apiURL + '/congress-rss-feed', {
|
const response = await fetch(apiURL + '/congress-rss-feed', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@ -1,24 +1,7 @@
|
|||||||
import { userRegion, getCache, setCache } from '$lib/store';
|
import { getCache, setCache } from '$lib/store';
|
||||||
|
|
||||||
|
|
||||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
export const load = async ({parent}) => {
|
||||||
|
|
||||||
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 () => {
|
|
||||||
|
|
||||||
const getMiniPlotsIndex = async () => {
|
const getMiniPlotsIndex = async () => {
|
||||||
let output;
|
let output;
|
||||||
@ -28,7 +11,7 @@ export const load = async () => {
|
|||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
const {apiKey, apiURL} = await parent();
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(apiURL + '/mini-plots-index', {
|
const response = await fetch(apiURL + '/mini-plots-index', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<script lang='ts'>
|
<script lang='ts'>
|
||||||
import { goto } from '$app/navigation';
|
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 Input from '$lib/components/Input.svelte';
|
||||||
import toast from 'svelte-french-toast';
|
import toast from 'svelte-french-toast';
|
||||||
import logo from "$lib/images/stock_screener_logo.png";
|
import logo from "$lib/images/stock_screener_logo.png";
|
||||||
@ -9,24 +9,6 @@
|
|||||||
|
|
||||||
import { onMount } from 'svelte';
|
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 data;
|
||||||
export let form;
|
export let form;
|
||||||
@ -37,7 +19,7 @@ let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
|||||||
async function getAllStrategies()
|
async function getAllStrategies()
|
||||||
{
|
{
|
||||||
const postData = {'userId': data?.user?.id}
|
const postData = {'userId': data?.user?.id}
|
||||||
const response = await fetch(fastifyURL+'/all-strategies', {
|
const response = await fetch(data?.fastifyURL+'/all-strategies', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"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',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
@ -143,7 +125,7 @@ onMount(async () => {
|
|||||||
|
|
||||||
const postData = {'strategyId': deleteStrategyId};
|
const postData = {'strategyId': deleteStrategyId};
|
||||||
|
|
||||||
const response = await fetch(fastifyURL+'/delete-strategy', {
|
const response = await fetch(data?.fastifyURL+'/delete-strategy', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
|
|||||||
@ -1,28 +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;
|
|
||||||
|
|
||||||
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 const load = async ({parent, params}) => {
|
||||||
|
|
||||||
export const load = async ({params}) => {
|
|
||||||
|
const { apiURL, apiKey, fastifyURL} = await parent();
|
||||||
|
|
||||||
const getStrategyId = async () => {
|
const getStrategyId = async () => {
|
||||||
return params.strategyId;
|
return params.strategyId;
|
||||||
@ -83,8 +67,5 @@ export const load = async ({params}) => {
|
|||||||
getStockScreenerData: await getStockScreenerData(),
|
getStockScreenerData: await getStockScreenerData(),
|
||||||
getStrategy: await getStrategy(),
|
getStrategy: await getStrategy(),
|
||||||
getStrategyId: await getStrategyId(),
|
getStrategyId: await getStrategyId(),
|
||||||
apiURL,
|
|
||||||
fastifyURL,
|
|
||||||
apiKey,
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -3,7 +3,6 @@ import { goto } from '$app/navigation';
|
|||||||
import { screenWidth, numberOfUnreadNotification } from '$lib/store';
|
import { screenWidth, numberOfUnreadNotification } from '$lib/store';
|
||||||
import { abbreviateNumber } from '$lib/utils';
|
import { abbreviateNumber } from '$lib/utils';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
import { fly } from 'svelte/transition';
|
|
||||||
import logo from '$lib/images/box_logo.png';
|
import logo from '$lib/images/box_logo.png';
|
||||||
|
|
||||||
import InfiniteLoading from '$lib/components/InfiniteLoading.svelte';
|
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">
|
<div class="text-sm breadcrumbs ml-4">
|
||||||
@ -89,7 +88,7 @@ $: {
|
|||||||
</div>
|
</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">
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-10">
|
||||||
|
|
||||||
<!-- Start Column -->
|
<!-- 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'];
|
export const load = async ({parent}) => {
|
||||||
|
|
||||||
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 () => {
|
|
||||||
const getStockList = async () => {
|
const getStockList = async () => {
|
||||||
let output;
|
let output;
|
||||||
// Get cached data for the specific tickerID
|
// Get cached data for the specific tickerID
|
||||||
@ -27,6 +10,7 @@ export const load = async () => {
|
|||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
const {apiKey, apiURL} = await parent();
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(apiURL + '/all-stock-tickers', {
|
const response = await fetch(apiURL + '/all-stock-tickers', {
|
||||||
|
|||||||
@ -12,16 +12,17 @@ export const load = async ({ parent, params }) => {
|
|||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const data = await parent();
|
const {apiURL, apiKey} = await parent();
|
||||||
|
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: params.tickerID
|
ticker: params.tickerID
|
||||||
};
|
};
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
// 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',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -11,17 +11,17 @@ export const load = async ({ parent, params }) => {
|
|||||||
newsList = cachedData;
|
newsList = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const data = await parent();
|
const {apiURL, apiKey} = await parent();
|
||||||
|
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: params.tickerID
|
ticker: params.tickerID
|
||||||
};
|
};
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(data?.apiURL + '/stock-dividend', {
|
const response = await fetch(apiURL + '/stock-dividend', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -26,7 +26,7 @@ const transactionTypeMap = {
|
|||||||
|
|
||||||
export const load = async ({ parent, params }) => {
|
export const load = async ({ parent, params }) => {
|
||||||
|
|
||||||
const data = await parent();
|
const {apiURL, apiKey} = await parent();
|
||||||
|
|
||||||
|
|
||||||
const getInsiderTrading = async () => {
|
const getInsiderTrading = async () => {
|
||||||
@ -42,10 +42,10 @@ export const load = async ({ parent, params }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(data?.apiURL + '/insider-trading', {
|
const response = await fetch(apiURL + '/insider-trading', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
@ -80,10 +80,10 @@ export const load = async ({ parent, params }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
// 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',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
@ -110,10 +110,10 @@ async function historicalPrice() {
|
|||||||
timePeriod: 'max',
|
timePeriod: 'max',
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await fetch(data?.apiURL+'/historical-price', {
|
const response = await fetch(apiURL+'/historical-price', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
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
|
//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.
|
// 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),
|
time: Date.parse(time),
|
||||||
open,
|
open,
|
||||||
high,
|
high,
|
||||||
|
|||||||
@ -12,17 +12,17 @@ export const load = async ({ parent, params }) => {
|
|||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const data = await parent();
|
const {apiURL, apiKey} = await parent();
|
||||||
|
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: params.tickerID
|
ticker: params.tickerID
|
||||||
};
|
};
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
// 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',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -12,17 +12,17 @@ export const load = async ({ parent, params }) => {
|
|||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const data = await parent();
|
const {apiURL, apiKey} = await parent();
|
||||||
|
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: params.tickerID
|
ticker: params.tickerID
|
||||||
};
|
};
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(data?.apiURL + '/stock-news', {
|
const response = await fetch(apiURL + '/stock-news', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -16,7 +16,7 @@ function daysLeft(targetDate) {
|
|||||||
export const load = async ({ parent, params }) => {
|
export const load = async ({ parent, params }) => {
|
||||||
|
|
||||||
|
|
||||||
const data = await parent();
|
const {apiKey, apiURL} = await parent();
|
||||||
|
|
||||||
|
|
||||||
const getOptionsPlotData = async () => {
|
const getOptionsPlotData = async () => {
|
||||||
@ -31,10 +31,10 @@ export const load = async ({ parent, params }) => {
|
|||||||
ticker: params.tickerID
|
ticker: params.tickerID
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await fetch(data?.apiURL + '/options-plot-ticker', {
|
const response = await fetch(apiURL + '/options-plot-ticker', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
@ -92,10 +92,10 @@ export const load = async ({ parent, params }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
// 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',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -14,17 +14,17 @@ export const load = async ({ parent, params }) => {
|
|||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const data = await parent();
|
const {apiKey, apiURL} = await parent();
|
||||||
|
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: params.tickerID
|
ticker: params.tickerID
|
||||||
};
|
};
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
// 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',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -12,16 +12,16 @@ export const load = async ({ parent, params }) => {
|
|||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const data = await parent();
|
const {apiKey, apiURL} = await parent();
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: params.tickerID
|
ticker: params.tickerID
|
||||||
};
|
};
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
// 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',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -11,17 +11,17 @@ export const load = async ({ parent, params }) => {
|
|||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const data = await parent();
|
const {apiKey, apiURL} = await parent();
|
||||||
|
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: params.tickerID
|
ticker: params.tickerID
|
||||||
};
|
};
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
// 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',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,16 +10,16 @@ export const load = async ({ parent, params }) => {
|
|||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const data = await parent();
|
const {apiKey, apiURL} = await parent();
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: params.tickerID
|
ticker: params.tickerID
|
||||||
};
|
};
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(data?.apiURL + '/history-employees', {
|
const response = await fetch(apiURL + '/history-employees', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -11,16 +11,16 @@ export const load = async ({ parent, params }) => {
|
|||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const data = await parent();
|
const {apiKey, apiURL} = await parent();
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: params.tickerID
|
ticker: params.tickerID
|
||||||
};
|
};
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(data?.apiURL + '/stock-income', {
|
const response = await fetch(apiURL + '/stock-income', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -11,16 +11,16 @@ export const load = async ({ parent, params }) => {
|
|||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const data = await parent();
|
const {apiKey, apiURL} = await parent();
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: params.tickerID
|
ticker: params.tickerID
|
||||||
};
|
};
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(data?.apiURL + '/stock-ratios', {
|
const response = await fetch(apiURL + '/stock-ratios', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,23 +1,8 @@
|
|||||||
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 () => {
|
const getMiniPlotsIndex = async () => {
|
||||||
let output;
|
let output;
|
||||||
@ -27,6 +12,7 @@ export const load = async () => {
|
|||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
const {apiKey, apiURL} = await parent();
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(apiURL + '/mini-plots-index', {
|
const response = await fetch(apiURL + '/mini-plots-index', {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user