clean code
This commit is contained in:
parent
265c83c1fd
commit
f54cc2f355
@ -11,12 +11,14 @@ export const handle = async ({ event, resolve }) => {
|
||||
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),
|
||||
apiURL,
|
||||
fastifyURL,
|
||||
wsURL,
|
||||
apiKey: import.meta.env.VITE_STOCKNEAR_API_KEY
|
||||
};
|
||||
|
||||
|
||||
@ -1,28 +1,13 @@
|
||||
|
||||
export const load = ({ locals, cookies }) => {
|
||||
|
||||
const consent = cookies?.get('cookie-consent')
|
||||
|
||||
if (locals.user) {
|
||||
return {
|
||||
user: locals.user,
|
||||
region: locals.region,
|
||||
cookieConsent: consent,
|
||||
apiURL: locals.apiURL,
|
||||
fastifyURL: locals.fastifyURL,
|
||||
apiKey: locals.apiKey,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
const { user, region, apiURL, fastifyURL, wsURL, apiKey } = locals;
|
||||
|
||||
return {
|
||||
user: undefined,
|
||||
region: locals.region,
|
||||
cookieConsent: consent,
|
||||
apiURL: locals.apiURL,
|
||||
fastifyURL: locals.fastifyURL,
|
||||
apiKey: locals.apiKey,
|
||||
user: user || undefined,
|
||||
region,
|
||||
cookieConsent: cookies?.get('cookie-consent'),
|
||||
apiURL,
|
||||
fastifyURL,
|
||||
wsURL,
|
||||
apiKey,
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let companyName;
|
||||
|
||||
@ -63,20 +62,9 @@ async function fetchPortfolio(fastifyURL, userId)
|
||||
export const load = async ({ params, locals, setHeaders}) => {
|
||||
|
||||
|
||||
const userRegion = locals?.region?.split("::")[0];
|
||||
|
||||
let apiURL = locals?.apiURL;
|
||||
let fastifyURL = locals?.fastifyURL;
|
||||
let apiKey = locals?.apiKey;
|
||||
let wsURL;
|
||||
|
||||
if (usRegion?.includes(userRegion)) {
|
||||
wsURL = import.meta.env.VITE_USEAST_WS_URL;
|
||||
} else {
|
||||
wsURL = import.meta.env.VITE_EU_WS_URL;
|
||||
};
|
||||
|
||||
|
||||
|
||||
const promises = [
|
||||
fetchData(apiURL,apiKey,'/crypto-profile',params.tickerID),
|
||||
|
||||
@ -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 getDividendCalendar = async () => {
|
||||
let output;
|
||||
|
||||
@ -28,12 +11,12 @@ export const load = async () => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
|
||||
const data = await parent();
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(apiURL + '/dividends-calendar', {
|
||||
const response = await fetch(data?.apiURL + '/dividends-calendar', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -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 getEarningsCalendar = async () => {
|
||||
let output;
|
||||
|
||||
@ -28,12 +11,12 @@ export const load = async () => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
|
||||
const data = await parent();
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(apiURL + '/earnings-calendar', {
|
||||
const response = await fetch(data?.apiURL + '/earnings-calendar', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -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 getEconomicCalendar = async () => {
|
||||
let output;
|
||||
|
||||
@ -28,7 +11,7 @@ export const load = async () => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
|
||||
const { apiURL, apiKey } = await parent();
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(apiURL + '/economic-calendar', {
|
||||
method: 'GET',
|
||||
|
||||
@ -1,6 +1,3 @@
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let companyName;
|
||||
|
||||
|
||||
@ -88,28 +85,10 @@ async function fetchPortfolio(fastifyURL, userId)
|
||||
|
||||
export const load = async ({ params, locals, setHeaders}) => {
|
||||
|
||||
const userRegion = locals?.region?.split("::")[0];
|
||||
|
||||
let apiURL = locals?.apiURL;
|
||||
let fastifyURL = locals?.fastifyURL;
|
||||
let apiKey = locals?.apiKey;
|
||||
let wsURL;
|
||||
|
||||
if (usRegion?.includes(userRegion)) {
|
||||
wsURL = import.meta.env.VITE_USEAST_WS_URL;
|
||||
} else {
|
||||
wsURL = import.meta.env.VITE_EU_WS_URL;
|
||||
};
|
||||
|
||||
if (usRegion?.includes(userRegion)) {
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
let wsURL = locals?.wsURL;
|
||||
|
||||
|
||||
const promises = [
|
||||
|
||||
@ -1,24 +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;
|
||||
import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
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 () => {
|
||||
let output;
|
||||
|
||||
@ -27,15 +10,16 @@ export const load = async ({ params }) => {
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
} else {
|
||||
const data = await parent();
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(apiURL + '/congress-trading-ticker', {
|
||||
const response = await fetch(data?.apiURL + '/congress-trading-ticker', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -1,22 +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 getStockDividend = async () => {
|
||||
let newsList;
|
||||
|
||||
@ -25,15 +10,16 @@ export const load = async ({ params }) => {
|
||||
if (cachedData) {
|
||||
newsList = cachedData;
|
||||
} else {
|
||||
const data = await parent();
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(apiURL + '/stock-dividend', {
|
||||
const response = await fetch(data?.apiURL + '/stock-dividend', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -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 ({ params }) => {
|
||||
export const load = async ({ parent, params }) => {
|
||||
const getETFHoldings = async () => {
|
||||
let output;
|
||||
|
||||
@ -27,15 +11,16 @@ export const load = async ({ params }) => {
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
} else {
|
||||
const data = await parent();
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(apiURL + '/etf-holdings', {
|
||||
const response = await fetch(data?.apiURL + '/etf-holdings', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -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 getStockNews = async () => {
|
||||
let output;
|
||||
|
||||
@ -27,15 +10,16 @@ export const load = async ({ params }) => {
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
} else {
|
||||
const data = await parent();
|
||||
const postData = {
|
||||
ticker: params.tickerID
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(apiURL + '/stock-news', {
|
||||
const response = await fetch(data?.apiURL + '/stock-news', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -1,65 +1,31 @@
|
||||
import { userRegion, displayCompanyName, 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 }) => {
|
||||
import { displayCompanyName, getCache, setCache } from '$lib/store';
|
||||
|
||||
export const load = async ({ parent, params }) => {
|
||||
const getHedgeFundsData = async () => {
|
||||
let output;
|
||||
|
||||
// Get cached data for the specific tickerID
|
||||
const cachedData = getCache(params.slug, 'getHedgeFundsData');
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
}
|
||||
else {
|
||||
if (cachedData) return cachedData;
|
||||
|
||||
|
||||
const postData = {
|
||||
cik: params.slug
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(apiURL + '/cik-data', {
|
||||
const { apiURL, apiKey } = await parent();
|
||||
const response = await fetch(apiURL+'/cik-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": apiKey
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
body: JSON.stringify({ cik: params.slug })
|
||||
});
|
||||
|
||||
output = await response.json();
|
||||
const output = await response.json();
|
||||
|
||||
// Cache the data for this specific tickerID with a specific name 'getHedgeFundsData'
|
||||
try {
|
||||
output.holdings = output?.holdings?.filter(item => item?.sharesNumber !== 0 && item?.symbol !== null); //item?.symbol !== null
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
if (output?.holdings) {
|
||||
output.holdings = output?.holdings?.filter(item => item?.sharesNumber && item?.symbol);
|
||||
}
|
||||
|
||||
setCache(params.slug, output, 'getHedgeFundsData');
|
||||
}
|
||||
|
||||
|
||||
|
||||
displayCompanyName.update(value => output?.name ?? params.slug)
|
||||
displayCompanyName.update(() => output?.name ?? params.slug);
|
||||
return output;
|
||||
};
|
||||
|
||||
// Make sure to return a promise
|
||||
return {
|
||||
getHedgeFundsData: await getHedgeFundsData()
|
||||
};
|
||||
|
||||
@ -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 getIPOCalendar = async () => {
|
||||
let output;
|
||||
|
||||
@ -28,13 +11,14 @@ export const load = async ({params}) => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const data = await parent();
|
||||
// make the POST request to the endpoint
|
||||
const postData = {'year': 'all'};
|
||||
|
||||
const response = await fetch(apiURL + '/ipo-calendar', {
|
||||
const response = await fetch(data?.apiURL + '/ipo-calendar', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
@ -1,24 +1,6 @@
|
||||
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 getIPOCalendar = async () => {
|
||||
let output;
|
||||
|
||||
@ -28,13 +10,14 @@ export const load = async ({params}) => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const data = await parent();
|
||||
// make the POST request to the endpoint
|
||||
const postData = {'year': params.slug};
|
||||
|
||||
const response = await fetch(apiURL + '/ipo-calendar', {
|
||||
const response = await fetch(data?.apiURL + '/ipo-calendar', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
@ -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 getAmexStocks = async () => {
|
||||
let output;
|
||||
|
||||
@ -28,6 +11,7 @@ export const load = async () => {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
const { apiURL, apiKey} = await parent();
|
||||
const postData = {'filterList': 'amex'}
|
||||
|
||||
const response = await fetch(apiURL + '/filter-stock-list', {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { userRegion, isOpen} from '$lib/store';
|
||||
import { isOpen} from '$lib/store';
|
||||
|
||||
|
||||
const checkMarketHour = async () => {
|
||||
@ -19,30 +19,10 @@ const checkMarketHour = async () => {
|
||||
}
|
||||
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let wsURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion?.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
wsURL = import.meta.env.VITE_USEAST_WS_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
wsURL = import.meta.env.VITE_EU_WS_URL;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export const load = async () => {
|
||||
export const load = async ({parent}) => {
|
||||
await checkMarketHour();
|
||||
const { apiURL, apiKey} = await parent();
|
||||
|
||||
const getOptionsFlowFeed = async () => {
|
||||
// make the POST request to the endpoint
|
||||
@ -60,6 +40,5 @@ export const load = async () => {
|
||||
// Make sure to return a promise
|
||||
return {
|
||||
getOptionsFlowFeed: await getOptionsFlowFeed(),
|
||||
wsURL,
|
||||
};
|
||||
};
|
||||
@ -1,4 +1,4 @@
|
||||
import { userRegion, isOpen} from '$lib/store';
|
||||
import {isOpen} from '$lib/store';
|
||||
|
||||
|
||||
const checkMarketHour = async () => {
|
||||
@ -19,30 +19,9 @@ const checkMarketHour = async () => {
|
||||
}
|
||||
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let apiURL;
|
||||
let wsURL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
userRegion.subscribe(value => {
|
||||
|
||||
if (usRegion?.includes(value)) {
|
||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
wsURL = import.meta.env.VITE_USEAST_WS_URL;
|
||||
} else {
|
||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||
wsURL = import.meta.env.VITE_EU_WS_URL;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export const load = async () => {
|
||||
export const load = async ({parent}) => {
|
||||
await checkMarketHour();
|
||||
const { apiURL, apiKey } = await parent();
|
||||
|
||||
const getOptionsZeroDTE = async () => {
|
||||
// make the POST request to the endpoint
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
|
||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||
|
||||
let companyName;
|
||||
|
||||
function cleanString(input) {
|
||||
@ -117,20 +115,10 @@ async function fetchCommunitySentiment(pb, ticker, cookies)
|
||||
|
||||
export const load = async ({ params, locals, cookies, setHeaders}) => {
|
||||
|
||||
const userRegion = locals?.region?.split("::")[0];
|
||||
|
||||
let apiURL = locals?.apiURL;
|
||||
let fastifyURL = locals?.fastifyURL;
|
||||
let apiKey = locals?.apiKey;
|
||||
let wsURL;
|
||||
|
||||
if (usRegion?.includes(userRegion)) {
|
||||
wsURL = import.meta.env.VITE_USEAST_WS_URL;
|
||||
} else {
|
||||
wsURL = import.meta.env.VITE_EU_WS_URL;
|
||||
};
|
||||
|
||||
|
||||
let wsURL = locals?.wsURL;
|
||||
|
||||
|
||||
const promises = [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user