clean code
This commit is contained in:
parent
4add3521b3
commit
65e1066b45
@ -22,14 +22,23 @@ export const handle = async ({ event, resolve }) => {
|
|||||||
event?.request?.headers?.get('x-vercel-id') ?? 'fra1::fra1::8t4xg-1700258428633-157d82fdfcc7',
|
event?.request?.headers?.get('x-vercel-id') ?? 'fra1::fra1::8t4xg-1700258428633-157d82fdfcc7',
|
||||||
);
|
);
|
||||||
|
|
||||||
const userRegion = event?.locals?.region?.split("::")?.at(0)?.split("::")?.at(0)
|
const userRegion = event?.locals?.region?.split("::")?.at(0)?.split("::")?.at(0) || '';
|
||||||
|
|
||||||
|
// Set a default API URL
|
||||||
|
let pbUrl = import.meta.env.VITE_EU_POCKETBASE_URL;
|
||||||
|
let apiURL = import.meta.env.VITE_EU_API_URL;
|
||||||
|
let fastifyURL = import.meta.env.VITE_EU_FASTIFY_URL;
|
||||||
|
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||||
|
|
||||||
let pbUrl = import.meta.env.VITE_EU_POCKETBASE_URL; // Set a default API URL
|
|
||||||
|
|
||||||
if (usRegion?.includes(userRegion)) {
|
if (usRegion?.includes(userRegion)) {
|
||||||
pbUrl = import.meta.env.VITE_USEAST_POCKETBASE_URL;
|
pbUrl = import.meta.env.VITE_USEAST_POCKETBASE_URL;
|
||||||
|
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||||
|
fastifyURL = import.meta.env.VITE_USEAST_FASTIFY_URL;
|
||||||
} else {
|
} else {
|
||||||
pbUrl = import.meta.env.VITE_EU_POCKETBASE_URL;
|
pbUrl = import.meta.env.VITE_EU_POCKETBASE_URL;
|
||||||
|
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||||
|
fastifyURL = import.meta.env.VITE_EU_FASTIFY_URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -42,10 +51,16 @@ export const handle = async ({ event, resolve }) => {
|
|||||||
if (event?.locals?.pb?.authStore?.isValid) {
|
if (event?.locals?.pb?.authStore?.isValid) {
|
||||||
await event?.locals?.pb?.collection('users')?.authRefresh();
|
await event?.locals?.pb?.collection('users')?.authRefresh();
|
||||||
event.locals.user = serializeNonPOJOs(event?.locals?.pb?.authStore?.model);
|
event.locals.user = serializeNonPOJOs(event?.locals?.pb?.authStore?.model);
|
||||||
|
event.locals.apiURL = apiURL;
|
||||||
|
event.locals.fastifyURL = fastifyURL;
|
||||||
|
event.locals.apiKey = apiKey;
|
||||||
}
|
}
|
||||||
} catch(_) {
|
} catch(_) {
|
||||||
event?.locals?.pb?.authStore?.clear();
|
event?.locals?.pb?.authStore?.clear();
|
||||||
event.locals.user = undefined;
|
event.locals.user = undefined;
|
||||||
|
event.locals.apiURL = apiURL;
|
||||||
|
event.locals.fastifyURL = fastifyURL;
|
||||||
|
event.locals.apiKey = apiKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,22 +1,10 @@
|
|||||||
<script lang='ts'>
|
<script lang='ts'>
|
||||||
import toast from 'svelte-french-toast';
|
import toast from 'svelte-french-toast';
|
||||||
import { userRegion, stockTicker, etfTicker, cryptoTicker, assetType, screenWidth } from "$lib/store";
|
import { stockTicker, etfTicker, cryptoTicker, assetType, screenWidth } from "$lib/store";
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
|
||||||
|
|
||||||
let fastifyURL;
|
|
||||||
|
|
||||||
userRegion.subscribe(value => {
|
|
||||||
if (usRegion.includes(value)) {
|
|
||||||
fastifyURL = import.meta.env.VITE_USEAST_FASTIFY_URL;
|
|
||||||
} else {
|
|
||||||
fastifyURL = import.meta.env.VITE_EU_FASTIFY_URL;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
let isClicked = false;
|
let isClicked = false;
|
||||||
|
|
||||||
@ -27,7 +15,7 @@ async function createPortfolio(event) {
|
|||||||
|
|
||||||
const postData = {'userId': data?.user?.id}
|
const postData = {'userId': data?.user?.id}
|
||||||
|
|
||||||
const response = await fetch(fastifyURL+'/create-portfolio', {
|
const response = await fetch(data?.fastifyURL+'/create-portfolio', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<script lang='ts'>
|
<script lang='ts'>
|
||||||
import {analystEstimateComponent, stockTicker, screenWidth, userRegion, getCache, setCache} from '$lib/store';
|
import {analystEstimateComponent, stockTicker, screenWidth, getCache, setCache} from '$lib/store';
|
||||||
import InfoModal from '$lib/components/InfoModal.svelte';
|
import InfoModal from '$lib/components/InfoModal.svelte';
|
||||||
|
|
||||||
import { LayerCake, Html } from 'layercake';
|
import { LayerCake, Html } from 'layercake';
|
||||||
@ -13,19 +13,6 @@ export let data;
|
|||||||
|
|
||||||
let analystEstimateList = [];
|
let analystEstimateList = [];
|
||||||
let isLoaded = false;
|
let isLoaded = false;
|
||||||
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 deactivateContent = data?.user?.tier === 'Pro' ? false : true;
|
let deactivateContent = data?.user?.tier === 'Pro' ? false : true;
|
||||||
|
|
||||||
@ -75,10 +62,10 @@ const getAnalystEstimate = async (ticker) => {
|
|||||||
|
|
||||||
const postData = {'ticker': ticker};
|
const postData = {'ticker': ticker};
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(apiURL + '/analyst-estimate', {
|
const response = await fetch(data?.apiURL + '/analyst-estimate', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,25 +1,10 @@
|
|||||||
<script lang ='ts'>
|
<script lang ='ts'>
|
||||||
import { analystInsightComponent, stockTicker, userRegion, getCache, setCache} from '$lib/store';
|
import { analystInsightComponent, stockTicker, getCache, setCache} from '$lib/store';
|
||||||
import InfoModal from '$lib/components/InfoModal.svelte';
|
import InfoModal from '$lib/components/InfoModal.svelte';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
let isLoaded = false;
|
let isLoaded = false;
|
||||||
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 rawData = {};
|
let rawData = {};
|
||||||
|
|
||||||
@ -51,10 +36,10 @@ function latestInfoDate(inputDate) {
|
|||||||
|
|
||||||
const postData = {'ticker': ticker};
|
const postData = {'ticker': ticker};
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(apiURL + '/analyst-insight', {
|
const response = await fetch(data?.apiURL + '/analyst-insight', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<script lang ='ts'>
|
<script lang ='ts'>
|
||||||
import { borrowedShareComponent, displayCompanyName, stockTicker, assetType, etfTicker, screenWidth, userRegion, getCache, setCache} from '$lib/store';
|
import { borrowedShareComponent, displayCompanyName, stockTicker, assetType, etfTicker, screenWidth, getCache, setCache} from '$lib/store';
|
||||||
import InfoModal from '$lib/components/InfoModal.svelte';
|
import InfoModal from '$lib/components/InfoModal.svelte';
|
||||||
import { Chart } from 'svelte-echarts'
|
import { Chart } from 'svelte-echarts'
|
||||||
import { abbreviateNumber, formatDateRange } from "$lib/utils";
|
import { abbreviateNumber, formatDateRange } from "$lib/utils";
|
||||||
@ -8,22 +8,7 @@
|
|||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
let isLoaded = false;
|
let isLoaded = false;
|
||||||
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 rawData = [];
|
let rawData = [];
|
||||||
let optionsData;
|
let optionsData;
|
||||||
let avgFee;
|
let avgFee;
|
||||||
@ -190,10 +175,10 @@ function findLowestAndHighestFee(data, lastDateStr) {
|
|||||||
|
|
||||||
const postData = {'ticker': ticker};
|
const postData = {'ticker': ticker};
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(apiURL + '/borrowed-share', {
|
const response = await fetch(data?.apiURL + '/borrowed-share', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<script lang ='ts'>
|
<script lang ='ts'>
|
||||||
import { clinicalTrialComponent, displayCompanyName, stockTicker, assetType, etfTicker, screenWidth, userRegion, getCache, setCache} from '$lib/store';
|
import { clinicalTrialComponent, displayCompanyName, stockTicker, assetType, etfTicker, screenWidth, getCache, setCache} from '$lib/store';
|
||||||
import InfoModal from '$lib/components/InfoModal.svelte';
|
import InfoModal from '$lib/components/InfoModal.svelte';
|
||||||
import { Chart } from 'svelte-echarts'
|
import { Chart } from 'svelte-echarts'
|
||||||
import { abbreviateNumber, formatString } from "$lib/utils";
|
import { abbreviateNumber, formatString } from "$lib/utils";
|
||||||
@ -8,20 +8,7 @@
|
|||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
let isLoaded = false;
|
let isLoaded = false;
|
||||||
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 rawData = [];
|
let rawData = [];
|
||||||
let displayList = []
|
let displayList = []
|
||||||
@ -172,10 +159,10 @@ const getClinicalTrial = async (ticker) => {
|
|||||||
|
|
||||||
const postData = {'ticker': ticker};
|
const postData = {'ticker': ticker};
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(apiURL + '/clinical-trial', {
|
const response = await fetch(data?.apiURL + '/clinical-trial', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import {getImageURL, formatDate} from '$lib/utils';
|
import {getImageURL, formatDate} from '$lib/utils';
|
||||||
import toast from 'svelte-french-toast';
|
import toast from 'svelte-french-toast';
|
||||||
import { userRegion, commentAdded, commentIdDeleted, screenWidth, replyCommentClicked, editCommentClicked, scrollToComment } from '$lib/store';
|
import { commentAdded, commentIdDeleted, screenWidth, replyCommentClicked, editCommentClicked, scrollToComment } from '$lib/store';
|
||||||
import TextEditor from '$lib/components/TextEditor.svelte';
|
import TextEditor from '$lib/components/TextEditor.svelte';
|
||||||
import { marked } from 'marked';
|
import { marked } from 'marked';
|
||||||
import { tick } from 'svelte';
|
import { tick } from 'svelte';
|
||||||
@ -115,7 +115,7 @@ const handleUpvote = async (event) => {
|
|||||||
} else {
|
} else {
|
||||||
upvoteCounter--;
|
upvoteCounter--;
|
||||||
}
|
}
|
||||||
const response = await fetch(fastifyURL+'/upvote-comment', {
|
const response = await fetch(data?.fastifyURL+'/upvote-comment', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
@ -151,7 +151,7 @@ const handleDownvote = async (event) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const response = await fetch(fastifyURL+'/downvote-comment', {
|
const response = await fetch(data?.fastifyURL+'/downvote-comment', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
@ -161,18 +161,6 @@ const handleDownvote = async (event) => {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
|
||||||
|
|
||||||
let fastifyURL;
|
|
||||||
|
|
||||||
userRegion.subscribe(value => {
|
|
||||||
if (usRegion.includes(value)) {
|
|
||||||
fastifyURL = import.meta.env.VITE_USEAST_FASTIFY_URL;
|
|
||||||
} else {
|
|
||||||
fastifyURL = import.meta.env.VITE_EU_FASTIFY_URL;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
let deleteCommentId = comment?.id
|
let deleteCommentId = comment?.id
|
||||||
|
|
||||||
@ -201,7 +189,7 @@ const handleDownvote = async (event) => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const response = await fetch(fastifyURL+'/delete-comment', {
|
const response = await fetch(data?.fastifyURL+'/delete-comment', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<script lang ='ts'>
|
<script lang ='ts'>
|
||||||
import { failToDeliverComponent, displayCompanyName, stockTicker, assetType, etfTicker, screenWidth, userRegion, getCache, setCache} from '$lib/store';
|
import { failToDeliverComponent, displayCompanyName, stockTicker, assetType, etfTicker, screenWidth, getCache, setCache} from '$lib/store';
|
||||||
import InfoModal from '$lib/components/InfoModal.svelte';
|
import InfoModal from '$lib/components/InfoModal.svelte';
|
||||||
import { Chart } from 'svelte-echarts'
|
import { Chart } from 'svelte-echarts'
|
||||||
import { abbreviateNumber, formatDateRange } from "$lib/utils";
|
import { abbreviateNumber, formatDateRange } from "$lib/utils";
|
||||||
@ -8,21 +8,8 @@
|
|||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
let isLoaded = false;
|
let isLoaded = false;
|
||||||
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 rawData = [];
|
let rawData = [];
|
||||||
let optionsData;
|
let optionsData;
|
||||||
@ -40,7 +27,7 @@ function findLowestAndHighestPrice(data, lastDateStr) {
|
|||||||
const firstDate = new Date(lastDate.getFullYear(), lastDate.getMonth(), 1);
|
const firstDate = new Date(lastDate.getFullYear(), lastDate.getMonth(), 1);
|
||||||
|
|
||||||
// Filter data to include only prices within the specified month period
|
// Filter data to include only prices within the specified month period
|
||||||
const filteredData = data.filter(item => {
|
const filteredData = data?.filter(item => {
|
||||||
const currentDate = new Date(item?.date);
|
const currentDate = new Date(item?.date);
|
||||||
return currentDate >= firstDate && currentDate <= lastDate;
|
return currentDate >= firstDate && currentDate <= lastDate;
|
||||||
});
|
});
|
||||||
@ -184,10 +171,10 @@ function findLowestAndHighestPrice(data, lastDateStr) {
|
|||||||
|
|
||||||
const postData = {'ticker': ticker};
|
const postData = {'ticker': ticker};
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(apiURL + '/fail-to-deliver', {
|
const response = await fetch(data?.apiURL + '/fail-to-deliver', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<script lang ='ts'>
|
<script lang ='ts'>
|
||||||
import { governmentContractComponent, displayCompanyName, stockTicker, screenWidth, userRegion, getCache, setCache} from '$lib/store';
|
import { governmentContractComponent, displayCompanyName, stockTicker, screenWidth, getCache, setCache} from '$lib/store';
|
||||||
import InfoModal from '$lib/components/InfoModal.svelte';
|
import InfoModal from '$lib/components/InfoModal.svelte';
|
||||||
import { Chart } from 'svelte-echarts'
|
import { Chart } from 'svelte-echarts'
|
||||||
import { abbreviateNumber, formatString } from "$lib/utils";
|
import { abbreviateNumber, formatString } from "$lib/utils";
|
||||||
@ -8,20 +8,6 @@
|
|||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
let isLoaded = false;
|
let isLoaded = false;
|
||||||
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 rawData = [];
|
let rawData = [];
|
||||||
@ -161,10 +147,10 @@ let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
|||||||
|
|
||||||
const postData = {'ticker': ticker};
|
const postData = {'ticker': ticker};
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(apiURL + '/government-contract', {
|
const response = await fetch(data?.apiURL + '/government-contract', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<script lang='ts'>
|
<script lang='ts'>
|
||||||
import { revenueSegmentationComponent, stockTicker, screenWidth, userRegion, getCache, setCache} from '$lib/store';
|
import { revenueSegmentationComponent, stockTicker, screenWidth, getCache, setCache} from '$lib/store';
|
||||||
import { abbreviateNumber, formatString } from '$lib/utils';
|
import { abbreviateNumber, formatString } from '$lib/utils';
|
||||||
import Sankey from '$lib/components/Sankey.svelte';
|
import Sankey from '$lib/components/Sankey.svelte';
|
||||||
import { LayerCake, Svg } from 'layercake';
|
import { LayerCake, Svg } from 'layercake';
|
||||||
@ -8,23 +8,10 @@
|
|||||||
import InfoModal from '$lib/components/InfoModal.svelte';
|
import InfoModal from '$lib/components/InfoModal.svelte';
|
||||||
|
|
||||||
export let userTier;
|
export let userTier;
|
||||||
|
export let apiURL;
|
||||||
|
export let apiKey;
|
||||||
|
|
||||||
let isLoaded = false;
|
let isLoaded = false;
|
||||||
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 revenueSegmentation = [];
|
let revenueSegmentation = [];
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
||||||
import { userRegion, searchBarData, stockTicker, etfTicker, cryptoTicker, screenWidth} from '$lib/store';
|
import { searchBarData, stockTicker, etfTicker, cryptoTicker, userRegion, screenWidth} from '$lib/store';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import Search from "lucide-svelte/icons/search";
|
import Search from "lucide-svelte/icons/search";
|
||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||||
let apiURL;
|
let apiURL;
|
||||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||||
|
|
||||||
|
|
||||||
userRegion.subscribe(value => {
|
userRegion.subscribe(value => {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
<script lang ='ts'>
|
<script lang ='ts'>
|
||||||
import { shareStatisticsComponent, displayCompanyName, stockTicker, screenWidth, userRegion, getCache, setCache} from '$lib/store';
|
import { shareStatisticsComponent, displayCompanyName, stockTicker, screenWidth, getCache, setCache} from '$lib/store';
|
||||||
import InfoModal from '$lib/components/InfoModal.svelte';
|
import InfoModal from '$lib/components/InfoModal.svelte';
|
||||||
import { Chart } from 'svelte-echarts'
|
import { Chart } from 'svelte-echarts'
|
||||||
import { abbreviateNumber } from "$lib/utils";
|
import { abbreviateNumber } from "$lib/utils";
|
||||||
@ -10,21 +10,7 @@
|
|||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
let isLoaded = false;
|
let isLoaded = false;
|
||||||
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 rawData = {};
|
let rawData = {};
|
||||||
let optionsData;
|
let optionsData;
|
||||||
@ -123,10 +109,10 @@ const getShareStatistics = async (ticker) => {
|
|||||||
|
|
||||||
const postData = {'ticker': ticker};
|
const postData = {'ticker': ticker};
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(apiURL + '/share-statistics', {
|
const response = await fetch(data?.apiURL + '/share-statistics', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<script lang ='ts'>
|
<script lang ='ts'>
|
||||||
import { abbreviateNumber } from "$lib/utils";
|
import { abbreviateNumber } from "$lib/utils";
|
||||||
|
|
||||||
import { swapComponent, stockTicker, screenWidth, userRegion, getCache, setCache} from '$lib/store';
|
import { swapComponent, stockTicker, screenWidth, getCache, setCache} from '$lib/store';
|
||||||
import InfoModal from '$lib/components/InfoModal.svelte';
|
import InfoModal from '$lib/components/InfoModal.svelte';
|
||||||
import { Chart } from 'svelte-echarts'
|
import { Chart } from 'svelte-echarts'
|
||||||
import { Motion, AnimateSharedLayout } from "svelte-motion";
|
import { Motion, AnimateSharedLayout } from "svelte-motion";
|
||||||
@ -27,21 +27,6 @@
|
|||||||
activeIdx = index;
|
activeIdx = index;
|
||||||
optionsData = getPlotOptions(activeIdx === 0 ? 'effectiveDate' : 'expirationDate');
|
optionsData = getPlotOptions(activeIdx === 0 ? 'effectiveDate' : 'expirationDate');
|
||||||
}
|
}
|
||||||
|
|
||||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
|
||||||
|
|
||||||
let apiURL;
|
|
||||||
|
|
||||||
|
|
||||||
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 rawData = [];
|
let rawData = [];
|
||||||
let optionsData;
|
let optionsData;
|
||||||
@ -190,11 +175,11 @@
|
|||||||
rawData = cachedData;
|
rawData = cachedData;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${apiURL}/swap-ticker`, {
|
const response = await fetch(`${data?.apiURL}/swap-ticker`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"X-API-KEY": import.meta.env.VITE_STOCKNEAR_API_KEY
|
"X-API-KEY": data?.apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ ticker })
|
body: JSON.stringify({ ticker })
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,26 +1,12 @@
|
|||||||
|
|
||||||
<script lang ='ts'>
|
<script lang ='ts'>
|
||||||
import { displayCompanyName, trendAnalysisComponent, stockTicker, etfTicker, cryptoTicker, assetType, userRegion, getCache, setCache} from '$lib/store';
|
import { displayCompanyName, trendAnalysisComponent, stockTicker, etfTicker, cryptoTicker, assetType, getCache, setCache} from '$lib/store';
|
||||||
import InfoModal from '$lib/components/InfoModal.svelte';
|
import InfoModal from '$lib/components/InfoModal.svelte';
|
||||||
//import Chart from '$lib/components/Chart.svelte';
|
//import Chart from '$lib/components/Chart.svelte';
|
||||||
//import Lazy from 'svelte-lazy';
|
//import Lazy from 'svelte-lazy';
|
||||||
|
|
||||||
let trendList = [];
|
let trendList = [];
|
||||||
let isLoaded = false;
|
let isLoaded = false;
|
||||||
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 let data;
|
export let data;
|
||||||
|
|
||||||
@ -50,10 +36,10 @@ const getTrendAnalysis = async (ticker) => {
|
|||||||
|
|
||||||
const postData = {'ticker': ticker};
|
const postData = {'ticker': ticker};
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(apiURL + '/trend-analysis', {
|
const response = await fetch(data?.apiURL + '/trend-analysis', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
<script lang ='ts'>
|
<script lang ='ts'>
|
||||||
import { varComponent, displayCompanyName, stockTicker, etfTicker, cryptoTicker, userRegion, assetType, getCache, setCache} from '$lib/store';
|
import { varComponent, displayCompanyName, stockTicker, etfTicker, cryptoTicker, assetType, getCache, setCache} from '$lib/store';
|
||||||
import InfoModal from '$lib/components/InfoModal.svelte';
|
import InfoModal from '$lib/components/InfoModal.svelte';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
@ -11,20 +11,6 @@
|
|||||||
let valueAtRisk;
|
let valueAtRisk;
|
||||||
let varDict = {}
|
let varDict = {}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const getVaR = async (ticker) => {
|
const getVaR = async (ticker) => {
|
||||||
// Get cached data for the specific tickerID
|
// Get cached data for the specific tickerID
|
||||||
@ -35,10 +21,10 @@ let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
|||||||
|
|
||||||
const postData = {'ticker': ticker};
|
const postData = {'ticker': ticker};
|
||||||
// make the POST request to the endpoint
|
// make the POST request to the endpoint
|
||||||
const response = await fetch(apiURL + '/value-at-risk', {
|
const response = await fetch(data?.apiURL + '/value-at-risk', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -8,6 +8,9 @@ export const load = ({ locals, cookies }) => {
|
|||||||
user: locals.user,
|
user: locals.user,
|
||||||
region: locals.region,
|
region: locals.region,
|
||||||
cookieConsent: consent,
|
cookieConsent: consent,
|
||||||
|
apiURL: locals.apiURL,
|
||||||
|
fastifyURL: locals.fastifyURL,
|
||||||
|
apiKey: locals.apiKey,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,6 +20,9 @@ export const load = ({ locals, cookies }) => {
|
|||||||
user: undefined,
|
user: undefined,
|
||||||
region: locals.region,
|
region: locals.region,
|
||||||
cookieConsent: consent,
|
cookieConsent: consent,
|
||||||
|
apiURL: locals.apiURL,
|
||||||
|
fastifyURL: locals.fastifyURL,
|
||||||
|
apiKey: locals.apiKey,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||||
|
|
||||||
let companyName;
|
let companyName;
|
||||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
|
||||||
|
|
||||||
function cleanString(input) {
|
function cleanString(input) {
|
||||||
// Define a list of substrings to remove (case insensitive)
|
// Define a list of substrings to remove (case insensitive)
|
||||||
@ -29,7 +28,7 @@ function cleanString(input) {
|
|||||||
return input?.replace(pattern, '')?.trim();
|
return input?.replace(pattern, '')?.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchData = async (apiURL, endpoint, ticker) => {
|
const fetchData = async (apiURL, apiKey, endpoint, ticker) => {
|
||||||
|
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: ticker
|
ticker: ticker
|
||||||
@ -121,33 +120,32 @@ export const load = async ({ params, locals, cookies, setHeaders}) => {
|
|||||||
|
|
||||||
const userRegion = locals?.region?.split("::")[0];
|
const userRegion = locals?.region?.split("::")[0];
|
||||||
|
|
||||||
let apiURL;
|
let apiURL = locals?.apiURL;
|
||||||
|
let fastifyURL = locals?.fastifyURL;
|
||||||
let fastifyURL;
|
let apiKey = locals?.apiKey;
|
||||||
|
let wsURL;
|
||||||
|
|
||||||
if (usRegion?.includes(userRegion)) {
|
if (usRegion?.includes(userRegion)) {
|
||||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
wsURL = import.meta.env.VITE_USEAST_WS_URL;
|
||||||
fastifyURL = import.meta.env.VITE_USEAST_FASTIFY_URL;
|
|
||||||
} else {
|
} else {
|
||||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
wsURL = import.meta.env.VITE_EU_WS_URL;
|
||||||
fastifyURL = import.meta.env.VITE_EU_FASTIFY_URL;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const promises = [
|
const promises = [
|
||||||
fetchData(apiURL,'/fair-price',params.tickerID),
|
fetchData(apiURL,apiKey, '/fair-price',params.tickerID),
|
||||||
fetchData(apiURL,'/similar-stocks',params.tickerID),
|
fetchData(apiURL,apiKey, '/similar-stocks',params.tickerID),
|
||||||
fetchData(apiURL,'/stockdeck',params.tickerID),
|
fetchData(apiURL,apiKey, '/stockdeck',params.tickerID),
|
||||||
fetchData(apiURL,'/stock-correlation',params.tickerID),
|
fetchData(apiURL,apiKey, '/stock-correlation',params.tickerID),
|
||||||
fetchData(apiURL,'/analyst-summary-rating',params.tickerID),
|
fetchData(apiURL,apiKey, '/analyst-summary-rating',params.tickerID),
|
||||||
fetchData(apiURL,'/stock-quote',params.tickerID),
|
fetchData(apiURL,apiKey, '/stock-quote',params.tickerID),
|
||||||
fetchData(apiURL,'/stock-rating',params.tickerID),
|
fetchData(apiURL,apiKey, '/stock-rating',params.tickerID),
|
||||||
fetchData(apiURL,'/bull-bear-say',params.tickerID),
|
fetchData(apiURL,apiKey, '/bull-bear-say',params.tickerID),
|
||||||
fetchData(apiURL,'/wiim',params.tickerID),
|
fetchData(apiURL,apiKey, '/wiim',params.tickerID),
|
||||||
fetchData(apiURL,'/top-etf-ticker-holder',params.tickerID),
|
fetchData(apiURL,apiKey, '/top-etf-ticker-holder',params.tickerID),
|
||||||
fetchData(apiURL,'/one-day-price',params.tickerID),
|
fetchData(apiURL,apiKey, '/one-day-price',params.tickerID),
|
||||||
fetchWatchlist(fastifyURL, locals?.user?.id),
|
fetchWatchlist(fastifyURL, locals?.user?.id),
|
||||||
fetchPortfolio(fastifyURL, locals?.user?.id),
|
fetchPortfolio(fastifyURL, locals?.user?.id),
|
||||||
fetchCommunitySentiment(locals?.pb, params.tickerID, cookies)
|
fetchCommunitySentiment(locals?.pb, params.tickerID, cookies)
|
||||||
@ -192,6 +190,7 @@ export const load = async ({ params, locals, cookies, setHeaders}) => {
|
|||||||
getUserPortfolio,
|
getUserPortfolio,
|
||||||
getCommunitySentiment,
|
getCommunitySentiment,
|
||||||
companyName,
|
companyName,
|
||||||
|
wsURL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<script lang='ts'>
|
<script lang='ts'>
|
||||||
|
|
||||||
import {searchBarData, userRegion, globalForm, screenWidth, openPriceAlert, currentPortfolioPrice, realtimePrice, isCrosshairMoveActive, currentPrice, priceIncrease, displayCompanyName, traded, stockTicker, isOpen } from '$lib/store';
|
import {searchBarData, globalForm, screenWidth, openPriceAlert, currentPortfolioPrice, realtimePrice, isCrosshairMoveActive, currentPrice, priceIncrease, displayCompanyName, traded, stockTicker, isOpen } from '$lib/store';
|
||||||
|
|
||||||
import { onMount, onDestroy, afterUpdate} from "svelte";
|
import { onMount, onDestroy, afterUpdate} from "svelte";
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
@ -15,24 +15,6 @@
|
|||||||
$realtimePrice = null;
|
$realtimePrice = null;
|
||||||
|
|
||||||
|
|
||||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
|
||||||
let fastifyURL;
|
|
||||||
let wsURL;
|
|
||||||
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;
|
|
||||||
fastifyURL = import.meta.env.VITE_USEAST_FASTIFY_URL;
|
|
||||||
wsURL = import.meta.env.VITE_USEAST_WS_URL;
|
|
||||||
} else {
|
|
||||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
|
||||||
fastifyURL = import.meta.env.VITE_EU_FASTIFY_URL;
|
|
||||||
wsURL = import.meta.env.VITE_EU_WS_URL;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
async function loadSearchData() {
|
async function loadSearchData() {
|
||||||
|
|
||||||
@ -43,10 +25,10 @@ async function loadSearchData() {
|
|||||||
else {
|
else {
|
||||||
|
|
||||||
// make the GET request to the endpoint
|
// make the GET request to the endpoint
|
||||||
const response = await fetch(apiURL+'/searchbar-data', {
|
const response = await fetch(data?.apiURL+'/searchbar-data', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json","X-API-KEY": apiKey
|
"Content-Type": "application/json","X-API-KEY": data?.apiKey
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -180,7 +162,7 @@ async function toggleUserWatchlist(watchListId: string) {
|
|||||||
'ticker': $stockTicker,
|
'ticker': $stockTicker,
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await fetch(fastifyURL + '/update-watchlist', {
|
const response = await fetch(data?.fastifyURL + '/update-watchlist', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
@ -215,7 +197,7 @@ async function fetchPortfolio()
|
|||||||
{
|
{
|
||||||
const postData = {'userId': data?.user?.id};
|
const postData = {'userId': data?.user?.id};
|
||||||
|
|
||||||
const response = await fetch(fastifyURL+'/get-portfolio-data', {
|
const response = await fetch(data?.fastifyURL+'/get-portfolio-data', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
@ -250,7 +232,7 @@ async function websocketRealtimeData() {
|
|||||||
|
|
||||||
previousTicker = $stockTicker;
|
previousTicker = $stockTicker;
|
||||||
try {
|
try {
|
||||||
socket = new WebSocket(wsURL+"/realtime-data");
|
socket = new WebSocket(data?.wsURL+"/realtime-data");
|
||||||
|
|
||||||
socket.addEventListener('open', () => {
|
socket.addEventListener('open', () => {
|
||||||
//console.log('WebSocket connection opened');
|
//console.log('WebSocket connection opened');
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import { displayCompanyName, stockTicker, assetType, isOpen, isAfterMarketClose,
|
|||||||
|
|
||||||
export const load = async ({ params, data }) => {
|
export const load = async ({ params, data }) => {
|
||||||
|
|
||||||
|
|
||||||
stockTicker.update( value => params.tickerID?.toUpperCase());
|
stockTicker.update( value => params.tickerID?.toUpperCase());
|
||||||
assetType.update( value => 'stock');
|
assetType.update( value => 'stock');
|
||||||
|
|
||||||
|
|||||||
@ -3,25 +3,12 @@
|
|||||||
import {AreaSeries, Chart, PriceLine, CandlestickSeries} from 'svelte-lightweight-charts';
|
import {AreaSeries, Chart, PriceLine, CandlestickSeries} from 'svelte-lightweight-charts';
|
||||||
|
|
||||||
import { TrackingModeExitMode } from 'lightweight-charts';
|
import { TrackingModeExitMode } from 'lightweight-charts';
|
||||||
import {getCache, setCache, swapComponent, analystInsightComponent, governmentContractComponent, optionsNetFlowComponent, impliedVolatilityComponent, borrowedShareComponent, clinicalTrialComponent, optionComponent, failToDeliverComponent, marketMakerComponent, analystEstimateComponent, sentimentComponent, screenWidth, displayCompanyName, numberOfUnreadNotification, globalForm, varComponent, shareStatisticsComponent, enterpriseComponent, darkPoolComponent, retailVolumeComponent, shareholderComponent, trendAnalysisComponent, revenueSegmentationComponent, priceAnalysisComponent, fundamentalAnalysisComponent, userRegion, isCrosshairMoveActive, realtimePrice, priceIncrease, currentPortfolioPrice, currentPrice, stockTicker, isOpen, isBeforeMarketOpen, isWeekend} from '$lib/store';
|
import {getCache, setCache, swapComponent, analystInsightComponent, governmentContractComponent, optionsNetFlowComponent, impliedVolatilityComponent, borrowedShareComponent, clinicalTrialComponent, optionComponent, failToDeliverComponent, marketMakerComponent, analystEstimateComponent, sentimentComponent, screenWidth, displayCompanyName, numberOfUnreadNotification, globalForm, varComponent, shareStatisticsComponent, enterpriseComponent, darkPoolComponent, retailVolumeComponent, shareholderComponent, trendAnalysisComponent, revenueSegmentationComponent, priceAnalysisComponent, fundamentalAnalysisComponent, isCrosshairMoveActive, realtimePrice, priceIncrease, currentPortfolioPrice, currentPrice, stockTicker, isOpen, isBeforeMarketOpen, isWeekend} from '$lib/store';
|
||||||
import { onDestroy, onMount } from 'svelte';
|
import { onDestroy, onMount } from 'svelte';
|
||||||
import BullBearSay from '$lib/components/BullBearSay.svelte';
|
import BullBearSay from '$lib/components/BullBearSay.svelte';
|
||||||
import CommunitySentiment from '$lib/components/CommunitySentiment.svelte';
|
import CommunitySentiment from '$lib/components/CommunitySentiment.svelte';
|
||||||
import Lazy from '$lib/components/Lazy.svelte';
|
import Lazy from '$lib/components/Lazy.svelte';
|
||||||
|
|
||||||
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 let data;
|
export let data;
|
||||||
export let form;
|
export let form;
|
||||||
@ -333,10 +320,10 @@ async function historicalPrice(timePeriod:string) {
|
|||||||
timePeriod: timePeriod,
|
timePeriod: timePeriod,
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await fetch(apiURL+'/historical-price', {
|
const response = await fetch(data?.apiURL+'/historical-price', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
@ -430,10 +417,10 @@ async function getPrePostQuote() {
|
|||||||
|
|
||||||
if(!$isOpen) {
|
if(!$isOpen) {
|
||||||
const postData = { ticker: $stockTicker};
|
const postData = { ticker: $stockTicker};
|
||||||
const response = await fetch(apiURL+'/pre-post-quote', {
|
const response = await fetch(data?.apiURL+'/pre-post-quote', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
@ -1369,7 +1356,7 @@ function changeChartType() {
|
|||||||
<Lazy>
|
<Lazy>
|
||||||
<div class="w-full pt-10 sm:pl-6 sm:pb-6 sm:pt-6 m-auto {!$revenueSegmentationComponent ? 'hidden' : ''}">
|
<div class="w-full pt-10 sm:pl-6 sm:pb-6 sm:pt-6 m-auto {!$revenueSegmentationComponent ? 'hidden' : ''}">
|
||||||
{#await import('$lib/components/RevenueSegmentation.svelte') then {default: Comp}}
|
{#await import('$lib/components/RevenueSegmentation.svelte') then {default: Comp}}
|
||||||
<svelte:component this={Comp} userTier={data?.user?.tier}/>
|
<svelte:component this={Comp} apiURL={data?.apiURL} apiKey={data?.apiKey} userTier={data?.user?.tier}/>
|
||||||
{/await}
|
{/await}
|
||||||
</div>
|
</div>
|
||||||
</Lazy>
|
</Lazy>
|
||||||
|
|||||||
@ -1,21 +1,10 @@
|
|||||||
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 getQuantStats = async () => {
|
const getQuantStats = async () => {
|
||||||
let output;
|
let output;
|
||||||
|
|
||||||
@ -24,15 +13,18 @@ export const load = async ({ params }) => {
|
|||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
const data = 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(apiURL + '/get-quant-stats', {
|
const response = await fetch(data?.apiURL + '/get-quant-stats', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,35 +1,25 @@
|
|||||||
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 => {
|
export const load = async ({ parent, params }) => {
|
||||||
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 getHistoryEmployee = async () => {
|
const getHistoryEmployee = async () => {
|
||||||
let output;
|
let output;
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
// Get cached data for the specific tickerID
|
||||||
const cachedData = getCache(params.tickerID, 'getHistoryEmployee');
|
const cachedData = getCache(params.tickerID, 'getHistoryEmployee');
|
||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
output = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
const data = 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(apiURL + '/history-employees', {
|
const response = await fetch(data?.apiURL + '/history-employees', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user