convert +page.ts to +page.server.ts
This commit is contained in:
parent
8149d25f29
commit
8d5b87f1ca
26
src/routes/analysts/+page.server.ts
Normal file
26
src/routes/analysts/+page.server.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
export const load = async ({ locals, setHeaders }) => {
|
||||||
|
const getTopAnalyst = async () => {
|
||||||
|
const { apiURL, apiKey, user } = locals;
|
||||||
|
|
||||||
|
const response = await fetch(apiURL + "/top-analysts", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
let output = await response?.json();
|
||||||
|
|
||||||
|
output = user?.tier !== "Pro" ? output?.reverse()?.slice(0, 6) : output;
|
||||||
|
|
||||||
|
setHeaders({ "cache-control": "public, max-age=3000" });
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getTopAnalyst: await getTopAnalyst(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -157,7 +157,7 @@ $: {
|
|||||||
<div class="text-sm sm:text-[1rem] breadcrumbs ml-4">
|
<div class="text-sm sm:text-[1rem] breadcrumbs ml-4">
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="/" class="text-gray-300">Home</a></li>
|
<li><a href="/" class="text-gray-300">Home</a></li>
|
||||||
<li class="text-gray-300">Top Shorted Stocks</li>
|
<li class="text-gray-300">Top Wall Street Analysts</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -1,34 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getTopAnalyst = async () => {
|
|
||||||
const { apiURL, apiKey, user } = await parent();
|
|
||||||
|
|
||||||
let output;
|
|
||||||
|
|
||||||
const cachedData = getCache("", "getTopAnalyst");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const response = await fetch(apiURL + "/top-analysts", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response?.json();
|
|
||||||
setCache("", output, "getTopAnalyst");
|
|
||||||
}
|
|
||||||
|
|
||||||
output = user?.tier !== "Pro" ? output?.reverse()?.slice(0, 6) : output;
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getTopAnalyst: await getTopAnalyst(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
27
src/routes/analysts/[slug]/+page.server.ts
Normal file
27
src/routes/analysts/[slug]/+page.server.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
export const load = async ({ locals, setHeaders, params }) => {
|
||||||
|
const getAnalystStats = async () => {
|
||||||
|
const { apiURL, apiKey } = locals;
|
||||||
|
|
||||||
|
const postData = { analystId: params.slug };
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/analyst-stats", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
let output = await response.json();
|
||||||
|
|
||||||
|
setHeaders({ "cache-control": "public, max-age=3000" });
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getAnalystStats: await getAnalystStats(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,38 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent, params }) => {
|
|
||||||
const getAnalystStats = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache(params.slug, "getAnalystStats");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiURL, apiKey } = await parent();
|
|
||||||
|
|
||||||
const postData = { analystId: params.slug };
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/analyst-stats", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getAnalystStats'
|
|
||||||
setCache(params.slug, output, "getAnalystStats");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getAnalystStats: await getAnalystStats(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
25
src/routes/analysts/top-stocks/+page.server.ts
Normal file
25
src/routes/analysts/top-stocks/+page.server.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
export const load = async ({ locals, setHeaders }) => {
|
||||||
|
const getTopAnalystStocks = async () => {
|
||||||
|
const { apiURL, apiKey, user } = locals;
|
||||||
|
|
||||||
|
const response = await fetch(apiURL + "/top-analysts-stocks", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
let output = await response.json();
|
||||||
|
|
||||||
|
output = user?.tier !== "Pro" ? output?.reverse()?.slice(0, 6) : output;
|
||||||
|
|
||||||
|
setHeaders({ "cache-control": "public, max-age=3000" });
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getTopAnalystStocks: await getTopAnalystStocks(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,33 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getTopAnalystStocks = async () => {
|
|
||||||
let output;
|
|
||||||
const { apiURL, apiKey, user } = await parent();
|
|
||||||
|
|
||||||
const cachedData = getCache("", "getTopAnalystStocks");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const response = await fetch(apiURL + "/top-analysts-stocks", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
setCache("", output, "getTopAnalystStocksg");
|
|
||||||
}
|
|
||||||
|
|
||||||
output = user?.tier !== "Pro" ? output?.reverse()?.slice(0, 6) : output;
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getTopAnalystStocks: await getTopAnalystStocks(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
26
src/routes/corporate-lobbying-tracker/+page.server.ts
Normal file
26
src/routes/corporate-lobbying-tracker/+page.server.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
export const load = async ({ locals, setHeaders }) => {
|
||||||
|
const getCorporateLobbyingTracker = async () => {
|
||||||
|
const { apiKey, apiURL, user } = locals;
|
||||||
|
|
||||||
|
const response = await fetch(apiURL + "/lobbying-tracker", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
let output = await response.json();
|
||||||
|
|
||||||
|
output = user?.tier !== "Pro" ? output?.slice(0, 6) : output;
|
||||||
|
|
||||||
|
setHeaders({ "cache-control": "public, max-age=3000" });
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getCorporateLobbyingTracker: await getCorporateLobbyingTracker(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,34 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getCorporateLobbyingTracker = async () => {
|
|
||||||
let output;
|
|
||||||
const { apiKey, apiURL, user } = await parent();
|
|
||||||
|
|
||||||
const cachedData = getCache("", "getCorporateLobbyingTracker");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const response = await fetch(apiURL + "/lobbying-tracker", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
setCache("", output, "getCorporateLobbyingTracker");
|
|
||||||
}
|
|
||||||
|
|
||||||
output = user?.tier !== "Pro" ? output?.slice(0, 6) : output;
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getCorporateLobbyingTracker: await getCorporateLobbyingTracker(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
26
src/routes/cramer-tracker/+page.server.ts
Normal file
26
src/routes/cramer-tracker/+page.server.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
export const load = async ({ locals, setHeaders }) => {
|
||||||
|
const getCramerTracker = async () => {
|
||||||
|
const { apiKey, apiURL, user } = locals;
|
||||||
|
|
||||||
|
const response = await fetch(apiURL + "/cramer-tracker", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
let output = await response.json();
|
||||||
|
|
||||||
|
output = user?.tier !== "Pro" ? output?.slice(0, 5) : output;
|
||||||
|
|
||||||
|
setHeaders({ "cache-control": "public, max-age=3000" });
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getCramerTracker: await getCramerTracker(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,36 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getCramerTracker = async () => {
|
|
||||||
let output;
|
|
||||||
const { apiKey, apiURL, user } = await parent();
|
|
||||||
|
|
||||||
const cachedData = getCache("", "getCramerTracker");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const response = await fetch(apiURL + "/cramer-tracker", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
setCache("", output, "getCramerTracker");
|
|
||||||
}
|
|
||||||
|
|
||||||
output = user?.tier !== "Pro" ? output?.slice(0, 5) : output;
|
|
||||||
|
|
||||||
//output = data?.user?.tier !== 'Pro' ? output?.slice(0,6) : output;
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getCramerTracker: await getCramerTracker(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
23
src/routes/dividends-calendar/+page.server.ts
Normal file
23
src/routes/dividends-calendar/+page.server.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
export const load = async ({ locals, setHeaders }) => {
|
||||||
|
const getDividendCalendar = async () => {
|
||||||
|
const { apiKey, apiURL } = locals;
|
||||||
|
const response = await fetch(apiURL + "/dividends-calendar", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
setHeaders({ "cache-control": "public, max-age=3000" });
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getDividendCalendar: await getDividendCalendar(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,35 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getDividendCalendar = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache("", "getDividendCalendar");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/dividends-calendar", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getDividendCalendar'
|
|
||||||
setCache("", output, "getDividendCalendar");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getDividendCalendar: await getDividendCalendar(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
23
src/routes/earnings-calendar/+page.server.ts
Normal file
23
src/routes/earnings-calendar/+page.server.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
export const load = async ({ locals, setHeaders }) => {
|
||||||
|
const getEarningsCalendar = async () => {
|
||||||
|
const { apiKey, apiURL } = locals;
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/earnings-calendar", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
setHeaders({ "cache-control": "public, max-age=3000" });
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getEarningsCalendar: await getEarningsCalendar(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,35 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getEarningsCalendar = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache("", "getEarningsCalendar");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/earnings-calendar", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getEarningsCalendar'
|
|
||||||
setCache("", output, "getEarningsCalendar");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getEarningsCalendar: await getEarningsCalendar(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
23
src/routes/economic-calendar/+page.server.ts
Normal file
23
src/routes/economic-calendar/+page.server.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
export const load = async ({ locals, setHeaders }) => {
|
||||||
|
const getEconomicCalendar = async () => {
|
||||||
|
const { apiURL, apiKey } = locals;
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/economic-calendar", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
setHeaders({ "cache-control": "public, max-age=3000" });
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getEconomicCalendar: await getEconomicCalendar(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,35 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getEconomicCalendar = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache("", "getEconomicCalendar");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiURL, apiKey } = await parent();
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/economic-calendar", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getEconomicCalendar'
|
|
||||||
setCache("", output, "getEconomicCalendar");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getEconomicCalendar: await getEconomicCalendar(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
24
src/routes/economic-indicator/+page.server.ts
Normal file
24
src/routes/economic-indicator/+page.server.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
export const load = async ({ locals, setHeaders }) => {
|
||||||
|
const getEconomicIndicator = async () => {
|
||||||
|
const { apiKey, apiURL } = locals;
|
||||||
|
|
||||||
|
const response = await fetch(apiURL + "/economic-indicator", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
setHeaders({ "cache-control": "public, max-age=3000" });
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getEconomicIndicator: await getEconomicIndicator(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,32 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getEconomicIndicator = async () => {
|
|
||||||
let output;
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
|
|
||||||
const cachedData = getCache("", "getEconomicIndicator");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const response = await fetch(apiURL + "/economic-indicator", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
setCache("", output, "getEconomicIndicator");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getEconomicIndicator: await getEconomicIndicator(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -1,14 +1,6 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
export const load = async ({ locals, setHeaders }) => {
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getAllHedgeFunds = async () => {
|
const getAllHedgeFunds = async () => {
|
||||||
const cachedData = getCache("", "getAllHedgeFunds");
|
const { apiURL, apiKey } = locals;
|
||||||
|
|
||||||
if (cachedData) {
|
|
||||||
return cachedData;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { apiURL, apiKey } = await parent();
|
|
||||||
const response = await fetch(apiURL + "/all-hedge-funds", {
|
const response = await fetch(apiURL + "/all-hedge-funds", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
@ -18,8 +10,8 @@ export const load = async ({ parent }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const output = await response.json();
|
const output = await response.json();
|
||||||
|
setHeaders({ "cache-control": "public, max-age=3000" });
|
||||||
|
|
||||||
setCache("", output, "getAllHedgeFunds");
|
|
||||||
return output;
|
return output;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1,20 +1,12 @@
|
|||||||
import { displayCompanyName, getCache, setCache } from "$lib/store";
|
import { displayCompanyName, getCache, setCache } from "$lib/store";
|
||||||
|
|
||||||
export const load = async ({ parent, params }) => {
|
export const load = async ({ params, locals, setHeaders }) => {
|
||||||
const getCIKNumber = async () => {
|
const getCIKNumber = async () => {
|
||||||
return params.slug;
|
return params.slug;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getHedgeFundsData = async () => {
|
const getHedgeFundsData = async () => {
|
||||||
const cachedData = getCache(params.slug, "getHedgeFundsData");
|
const { apiURL, apiKey } = locals;
|
||||||
|
|
||||||
if (cachedData) {
|
|
||||||
displayCompanyName.update(() => cachedData?.name ?? params.slug);
|
|
||||||
|
|
||||||
return cachedData;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { apiURL, apiKey } = await parent();
|
|
||||||
const response = await fetch(apiURL + "/cik-data", {
|
const response = await fetch(apiURL + "/cik-data", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@ -28,12 +20,12 @@ export const load = async ({ parent, params }) => {
|
|||||||
|
|
||||||
if (output?.holdings) {
|
if (output?.holdings) {
|
||||||
output.holdings = output?.holdings?.filter(
|
output.holdings = output?.holdings?.filter(
|
||||||
(item) => item?.sharesNumber && item?.symbol,
|
(item) => item?.sharesNumber && item?.symbol
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
displayCompanyName.update(() => output?.name ?? params.slug);
|
//displayCompanyName.update(() => output?.name ?? params.slug);
|
||||||
|
setHeaders({ "cache-control": "public, max-age=3000" });
|
||||||
|
|
||||||
setCache(params.slug, output, "getHedgeFundsData");
|
|
||||||
return output;
|
return output;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -21,6 +21,7 @@ use([BarChart, GridComponent, TooltipComponent, CanvasRenderer])
|
|||||||
export let data;
|
export let data;
|
||||||
let cloudFrontUrl = import.meta.env.VITE_IMAGE_URL;
|
let cloudFrontUrl = import.meta.env.VITE_IMAGE_URL;
|
||||||
|
|
||||||
|
|
||||||
function sectorSelector(sector) {
|
function sectorSelector(sector) {
|
||||||
let path;
|
let path;
|
||||||
switch(sector) {
|
switch(sector) {
|
||||||
@ -73,6 +74,7 @@ use([BarChart, GridComponent, TooltipComponent, CanvasRenderer])
|
|||||||
|
|
||||||
let isLoaded = false;
|
let isLoaded = false;
|
||||||
let rawData = data?.getHedgeFundsData;
|
let rawData = data?.getHedgeFundsData;
|
||||||
|
displayCompanyName.update(() => rawData?.name ?? 'Company Data')
|
||||||
let rawList = []
|
let rawList = []
|
||||||
let displayList = [];
|
let displayList = [];
|
||||||
let optionsData = {};
|
let optionsData = {};
|
||||||
|
|||||||
23
src/routes/industry/+page.server.ts
Normal file
23
src/routes/industry/+page.server.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
export const load = async ({ locals, setHeaders }) => {
|
||||||
|
const getSectorIndustryOverview = async () => {
|
||||||
|
const { apiKey, apiURL } = locals;
|
||||||
|
|
||||||
|
const response = await fetch(apiURL + "/sector-industry-overview", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response?.json();
|
||||||
|
setHeaders({ "cache-control": "public, max-age=3000" });
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getSectorIndustryOverview: await getSectorIndustryOverview(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,34 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getSectorIndustryOverview = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache("", "getSectorIndustryOverview");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
|
|
||||||
const response = await fetch(apiURL + "/sector-industry-overview", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
setCache("", output, "getSectorIndustryOverview");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getSectorIndustryOverview: await getSectorIndustryOverview(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
23
src/routes/industry/all/+page.server.ts
Normal file
23
src/routes/industry/all/+page.server.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
export const load = async ({ locals, setHeaders }) => {
|
||||||
|
const getIndustryOverview = async () => {
|
||||||
|
const { apiKey, apiURL } = locals;
|
||||||
|
|
||||||
|
const response = await fetch(apiURL + "/industry-overview", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
setHeaders({ "cache-control": "public, max-age=3000" });
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getIndustryOverview: await getIndustryOverview(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,34 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getIndustryOverview = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache("", "getIndustryOverview");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
|
|
||||||
const response = await fetch(apiURL + "/industry-overview", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
setCache("", output, "getIndustryOverview");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getIndustryOverview: await getIndustryOverview(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
24
src/routes/industry/sectors/+page.server.ts
Normal file
24
src/routes/industry/sectors/+page.server.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
export const load = async ({ locals, setHeaders }) => {
|
||||||
|
const getSectorOverview = async () => {
|
||||||
|
const { apiKey, apiURL } = locals;
|
||||||
|
|
||||||
|
const response = await fetch(apiURL + "/sector-overview", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
setHeaders({ "cache-control": "public, max-age=3000" });
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getSectorOverview: await getSectorOverview(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,34 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getSectorOverview = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache("", "getSectorOverview");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
|
|
||||||
const response = await fetch(apiURL + "/sector-overview", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
setCache("", output, "getSectorOverview");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getSectorOverview: await getSectorOverview(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
29
src/routes/list/industry/[slug]/+page.server.ts
Normal file
29
src/routes/list/industry/[slug]/+page.server.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
export const load = async ({ params, locals, setHeaders }) => {
|
||||||
|
const getIndustryStocks = async () => {
|
||||||
|
const { apiKey, apiURL } = locals;
|
||||||
|
|
||||||
|
const postData = { ticker: params.slug };
|
||||||
|
const response = await fetch(apiURL + "/industry-stocks", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
setHeaders({ "cache-control": "public, max-age=3000" });
|
||||||
|
|
||||||
|
//output = user?.tier !== "Pro" ? output?.slice(0, 5) : output;
|
||||||
|
|
||||||
|
//output = data?.user?.tier !== 'Pro' ? output?.slice(0,6) : output;
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getIndustryStocks: await getIndustryStocks(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,38 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent, params }) => {
|
|
||||||
const getIndustryStocks = async () => {
|
|
||||||
let output;
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
|
|
||||||
const cachedData = getCache(params.slug, "getIndustryStocks");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const postData = { ticker: params.slug };
|
|
||||||
const response = await fetch(apiURL + "/industry-stocks", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
setCache(params.slug, output, "getIndustryStocks");
|
|
||||||
}
|
|
||||||
|
|
||||||
//output = user?.tier !== "Pro" ? output?.slice(0, 5) : output;
|
|
||||||
|
|
||||||
//output = data?.user?.tier !== 'Pro' ? output?.slice(0,6) : output;
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getIndustryStocks: await getIndustryStocks(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
38
src/routes/market-mover/+page.server.ts
Normal file
38
src/routes/market-mover/+page.server.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
export const load = async ({ locals, setHeaders }) => {
|
||||||
|
const { apiURL, apiKey } = locals;
|
||||||
|
|
||||||
|
const getDailyGainerLoserActive = async () => {
|
||||||
|
const response = await fetch(apiURL + "/market-movers", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getMiniPlotsIndex = async () => {
|
||||||
|
const response = await fetch(apiURL + "/mini-plots-index", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
setHeaders({ "cache-control": "public, max-age=3000" });
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getDailyGainerLoserActive: await getDailyGainerLoserActive(),
|
||||||
|
getMiniPlotsIndex: await getMiniPlotsIndex(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,61 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const { apiURL, apiKey } = await parent();
|
|
||||||
|
|
||||||
const getDailyGainerLoserActive = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache("", "getDailyGainerLoserActive");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/market-movers", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
setCache("", output, "getDailyGainerLoserActive");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getMiniPlotsIndex = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache("", "getMiniPlotsIndex");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/mini-plots-index", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
setCache("", output, "getMiniPlotsIndex");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getDailyGainerLoserActive: await getDailyGainerLoserActive(),
|
|
||||||
getMiniPlotsIndex: await getMiniPlotsIndex(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
24
src/routes/market-news/+page.server.ts
Normal file
24
src/routes/market-news/+page.server.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
export const load = async ({ locals }) => {
|
||||||
|
const getMarketNews = async () => {
|
||||||
|
const { apiURL, apiKey } = locals;
|
||||||
|
const postData = { newsType: "stock-news" };
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/market-news", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getMarketNews: await getMarketNews(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,37 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getMarketNews = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache("", "getMarketNews");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiURL, apiKey } = await parent();
|
|
||||||
const postData = { newsType: "stock-news" };
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/market-news", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getMarketNews'
|
|
||||||
setCache("", output, "getMarketNews");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getMarketNews: await getMarketNews(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
25
src/routes/market-news/general/+page.server.ts
Normal file
25
src/routes/market-news/general/+page.server.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
export const load = async ({ locals }) => {
|
||||||
|
const getGeneralNews = async () => {
|
||||||
|
const { apiURL, apiKey } = locals;
|
||||||
|
const postData = { newsType: "general-news" };
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/market-news", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getGeneralNews: await getGeneralNews(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,38 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getGeneralNews = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache("", "getGeneralNews");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiURL, apiKey } = await parent();
|
|
||||||
const postData = { newsType: "general-news" };
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/market-news", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getGeneralNews'
|
|
||||||
setCache("", output, "getGeneralNews");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getGeneralNews: await getGeneralNews(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
26
src/routes/most-retail-volume/+page.server.ts
Normal file
26
src/routes/most-retail-volume/+page.server.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
export const load = async ({ locals, setHeaders }) => {
|
||||||
|
const getMostRetailVolume = async () => {
|
||||||
|
const { apiKey, apiURL, user } = locals;
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/most-retail-volume", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
let output = await response.json();
|
||||||
|
|
||||||
|
output = user?.tier !== "Pro" ? output?.slice(0, 6) : output;
|
||||||
|
setHeaders({ "cache-control": "public, max-age=3000" });
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getMostRetailVolume: await getMostRetailVolume(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,35 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getMostRetailVolume = async () => {
|
|
||||||
let output;
|
|
||||||
const { apiKey, apiURL, user } = await parent();
|
|
||||||
|
|
||||||
const cachedData = getCache("", "getMostRetailVolume");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/most-retail-volume", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
setCache("", output, "getMostRetailVolume");
|
|
||||||
}
|
|
||||||
|
|
||||||
output = user?.tier !== "Pro" ? output?.slice(0, 6) : output;
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getMostRetailVolume: await getMostRetailVolume(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
25
src/routes/most-shorted-stocks/+page.server.ts
Normal file
25
src/routes/most-shorted-stocks/+page.server.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
export const load = async ({ locals, setHeaders }) => {
|
||||||
|
const getMostShortedStocks = async () => {
|
||||||
|
const { apiKey, apiURL, user } = locals;
|
||||||
|
|
||||||
|
const response = await fetch(apiURL + "/most-shorted-stocks", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
let output = await response.json();
|
||||||
|
output = user?.tier !== "Pro" ? output?.slice(0, 6) : output;
|
||||||
|
|
||||||
|
setHeaders({ "cache-control": "public, max-age=3000" });
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getMostShortedStocks: await getMostShortedStocks(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,34 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getMostShortedStocks = async () => {
|
|
||||||
let output;
|
|
||||||
const { apiKey, apiURL, user } = await parent();
|
|
||||||
|
|
||||||
const cachedData = getCache("", "getMostShortedStocks");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const response = await fetch(apiURL + "/most-shorted-stocks", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
setCache("", output, "getMostShortedStocks");
|
|
||||||
}
|
|
||||||
|
|
||||||
output = user?.tier !== "Pro" ? output?.slice(0, 6) : output;
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getMostShortedStocks: await getMostShortedStocks(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
22
src/routes/options-flow/+page.server.ts
Normal file
22
src/routes/options-flow/+page.server.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
export const load = async ({ locals }) => {
|
||||||
|
const { apiURL, apiKey } = locals;
|
||||||
|
|
||||||
|
const getOptionsFlowFeed = async () => {
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/options-flow-feed", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getOptionsFlowFeed: await getOptionsFlowFeed(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -37,30 +37,10 @@ const checkMarketHour = async () => {
|
|||||||
isBeforeMarketOpenValue ||
|
isBeforeMarketOpenValue ||
|
||||||
isAfterMarketCloseValue ||
|
isAfterMarketCloseValue ||
|
||||||
holidays?.includes(currentDate)
|
holidays?.includes(currentDate)
|
||||||
),
|
)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
export const load = async () => {
|
||||||
await checkMarketHour();
|
await checkMarketHour();
|
||||||
const { apiURL, apiKey } = await parent();
|
|
||||||
|
|
||||||
const getOptionsFlowFeed = async () => {
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/options-flow-feed", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const output = await response.json();
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getOptionsFlowFeed: await getOptionsFlowFeed(),
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|||||||
50
src/routes/politicians/+page.server.ts
Normal file
50
src/routes/politicians/+page.server.ts
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import { getPartyForPoliticians } from "$lib/utils";
|
||||||
|
|
||||||
|
export const load = async ({ locals }) => {
|
||||||
|
const getAllPolitician = async () => {
|
||||||
|
let output;
|
||||||
|
|
||||||
|
const { apiKey, apiURL } = locals;
|
||||||
|
|
||||||
|
const response = await fetch(apiURL + "/all-politicians", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
output = await response.json();
|
||||||
|
|
||||||
|
// Cache the data for this specific tickerID with a specific name 'getAllPolitician'
|
||||||
|
|
||||||
|
output?.forEach((item) => {
|
||||||
|
let representative = item?.representative || "";
|
||||||
|
|
||||||
|
representative = representative
|
||||||
|
?.replace("Jr", "")
|
||||||
|
.replace(/Dr./g, "")
|
||||||
|
.replace(/Dr_/g, "");
|
||||||
|
|
||||||
|
const fullName = representative
|
||||||
|
?.replace(/(\s(?:Dr\s)?\w(?:\.|(?=\s)))?\s/g, "_")
|
||||||
|
.trim();
|
||||||
|
item.representative = fullName?.replace(/_/g, " ");
|
||||||
|
});
|
||||||
|
|
||||||
|
output = output?.map((item) => {
|
||||||
|
const party = getPartyForPoliticians(item?.representative);
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
party: party,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getAllPolitician: await getAllPolitician(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,59 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
import { getPartyForPoliticians } from "$lib/utils";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getAllPolitician = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache("", "getAllPolitician");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
|
|
||||||
const response = await fetch(apiURL + "/all-politicians", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getAllPolitician'
|
|
||||||
|
|
||||||
output?.forEach((item) => {
|
|
||||||
let representative = item?.representative || "";
|
|
||||||
|
|
||||||
representative = representative
|
|
||||||
?.replace("Jr", "")
|
|
||||||
.replace(/Dr./g, "")
|
|
||||||
.replace(/Dr_/g, "");
|
|
||||||
|
|
||||||
const fullName = representative
|
|
||||||
?.replace(/(\s(?:Dr\s)?\w(?:\.|(?=\s)))?\s/g, "_")
|
|
||||||
.trim();
|
|
||||||
item.representative = fullName?.replace(/_/g, " ");
|
|
||||||
});
|
|
||||||
|
|
||||||
output = output?.map((item) => {
|
|
||||||
const party = getPartyForPoliticians(item?.representative);
|
|
||||||
return {
|
|
||||||
...item,
|
|
||||||
party: party,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
setCache("", output, "getAllPolitician");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getAllPolitician: await getAllPolitician(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
50
src/routes/politicians/flow-data/+page.server.ts
Normal file
50
src/routes/politicians/flow-data/+page.server.ts
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import { getPartyForPoliticians } from "$lib/utils";
|
||||||
|
|
||||||
|
export const load = async ({ locals }) => {
|
||||||
|
const getPoliticianRSS = async () => {
|
||||||
|
let output;
|
||||||
|
|
||||||
|
const { apiKey, apiURL } = locals;
|
||||||
|
|
||||||
|
const response = await fetch(apiURL + "/congress-rss-feed", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
output = await response.json();
|
||||||
|
|
||||||
|
// Cache the data for this specific tickerID with a specific name 'getPoliticianRSS'
|
||||||
|
|
||||||
|
output?.forEach((item) => {
|
||||||
|
let representative = item?.representative || "";
|
||||||
|
|
||||||
|
representative = representative
|
||||||
|
?.replace("Jr", "")
|
||||||
|
.replace(/Dr./g, "")
|
||||||
|
.replace(/Dr_/g, "");
|
||||||
|
|
||||||
|
const fullName = representative
|
||||||
|
?.replace(/(\s(?:Dr\s)?\w(?:\.|(?=\s)))?\s/g, "_")
|
||||||
|
.trim();
|
||||||
|
item.representative = fullName?.replace(/_/g, " ");
|
||||||
|
});
|
||||||
|
|
||||||
|
output = output?.map((item) => {
|
||||||
|
const party = getPartyForPoliticians(item?.representative);
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
party: party,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getPoliticianRSS: await getPoliticianRSS(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,58 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
import { getPartyForPoliticians } from "$lib/utils";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getPoliticianRSS = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache("", "getPoliticianRSS");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
|
|
||||||
const response = await fetch(apiURL + "/congress-rss-feed", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getPoliticianRSS'
|
|
||||||
|
|
||||||
output?.forEach((item) => {
|
|
||||||
let representative = item?.representative || "";
|
|
||||||
|
|
||||||
representative = representative
|
|
||||||
?.replace("Jr", "")
|
|
||||||
.replace(/Dr./g, "")
|
|
||||||
.replace(/Dr_/g, "");
|
|
||||||
|
|
||||||
const fullName = representative
|
|
||||||
?.replace(/(\s(?:Dr\s)?\w(?:\.|(?=\s)))?\s/g, "_")
|
|
||||||
.trim();
|
|
||||||
item.representative = fullName?.replace(/_/g, " ");
|
|
||||||
});
|
|
||||||
|
|
||||||
output = output?.map((item) => {
|
|
||||||
const party = getPartyForPoliticians(item?.representative);
|
|
||||||
return {
|
|
||||||
...item,
|
|
||||||
party: party,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
setCache("", output, "getPoliticianRSS");
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getPoliticianRSS: await getPoliticianRSS(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
40
src/routes/price-alert/+page.server.ts
Normal file
40
src/routes/price-alert/+page.server.ts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
export const load = async ({ locals }) => {
|
||||||
|
const { apiKey, apiURL, fastifyURL, user } = locals;
|
||||||
|
|
||||||
|
const getPriceAlert = async () => {
|
||||||
|
const postData = { userId: user?.id };
|
||||||
|
const response = await fetch(fastifyURL + "/get-price-alert", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
let output = (await response.json())?.items;
|
||||||
|
output = output?.sort((a, b) => a?.symbol?.localeCompare(b?.symbol));
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getMiniPlotsIndex = async () => {
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/mini-plots-index", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getMiniPlotsIndex: await getMiniPlotsIndex(),
|
||||||
|
getPriceAlert: await getPriceAlert(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -83,26 +83,10 @@ rawData?.forEach(({ symbol, priceData, changesPercentage, previousClose }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let isLoaded = false;
|
let isLoaded = false;
|
||||||
let priceAlertList = [];
|
let priceAlertList = data?.getPriceAlert;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function getPriceAlert()
|
|
||||||
{
|
|
||||||
const postData = {'userId': data?.user?.id}
|
|
||||||
const response = await fetch(data?.fastifyURL+'/get-price-alert', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData)
|
|
||||||
});
|
|
||||||
|
|
||||||
priceAlertList = (await response.json())?.items;
|
|
||||||
priceAlertList= priceAlertList?.sort((a, b) => a?.symbol?.localeCompare(b?.symbol));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function stockSelector(symbol, assetType) {
|
function stockSelector(symbol, assetType) {
|
||||||
if (editMode) {
|
if (editMode) {
|
||||||
@ -164,11 +148,7 @@ async function handleDelete() {
|
|||||||
|
|
||||||
onMount( async () => {
|
onMount( async () => {
|
||||||
|
|
||||||
if (data?.user)
|
|
||||||
{
|
|
||||||
await getPriceAlert()
|
|
||||||
|
|
||||||
}
|
|
||||||
isLoaded = true;
|
isLoaded = true;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,34 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getMiniPlotsIndex = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache("", "getMiniPlotsIndex");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/mini-plots-index", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
setCache("", output, "getMiniPlotsIndex");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getMiniPlotsIndex: await getMiniPlotsIndex(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -1,7 +1,3 @@
|
|||||||
export const config = {
|
|
||||||
runtime: "nodejs20.x",
|
|
||||||
};
|
|
||||||
|
|
||||||
const pages = [
|
const pages = [
|
||||||
{ title: "/" },
|
{ title: "/" },
|
||||||
{ title: "/cramer-tracker" },
|
{ title: "/cramer-tracker" },
|
||||||
@ -133,7 +129,7 @@ const sitemap = (
|
|||||||
posts,
|
posts,
|
||||||
articles,
|
articles,
|
||||||
stocks,
|
stocks,
|
||||||
pages,
|
pages
|
||||||
) => `<?xml version="1.0" encoding="UTF-8" ?>
|
) => `<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<urlset
|
<urlset
|
||||||
xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"
|
xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"
|
||||||
@ -149,7 +145,7 @@ const sitemap = (
|
|||||||
<url>
|
<url>
|
||||||
<loc>${website}${page.title}</loc>
|
<loc>${website}${page.title}</loc>
|
||||||
</url>
|
</url>
|
||||||
`,
|
`
|
||||||
)
|
)
|
||||||
.join("")}
|
.join("")}
|
||||||
${stocks
|
${stocks
|
||||||
@ -174,7 +170,7 @@ const sitemap = (
|
|||||||
<url>
|
<url>
|
||||||
<loc>${website}/blog/article/${article.id}</loc>
|
<loc>${website}/blog/article/${article.id}</loc>
|
||||||
</url>
|
</url>
|
||||||
`,
|
`
|
||||||
)
|
)
|
||||||
.join("")}
|
.join("")}
|
||||||
${posts
|
${posts
|
||||||
@ -183,7 +179,7 @@ const sitemap = (
|
|||||||
<url>
|
<url>
|
||||||
<loc>${website}/community/post/${post.id}</loc>
|
<loc>${website}/community/post/${post.id}</loc>
|
||||||
</url>
|
</url>
|
||||||
`,
|
`
|
||||||
)
|
)
|
||||||
.join("")}
|
.join("")}
|
||||||
</urlset>`;
|
</urlset>`;
|
||||||
|
|||||||
23
src/routes/stock-splits-calendar/+page.server.ts
Normal file
23
src/routes/stock-splits-calendar/+page.server.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
export const load = async ({ locals, setHeaders }) => {
|
||||||
|
const getStockSplitsCalendar = async () => {
|
||||||
|
const { apiKey, apiURL } = locals;
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/stock-splits-calendar", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
setHeaders({ "cache-control": "public, max-age=3000" });
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getStockSplitsCalendar: await getStockSplitsCalendar(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,35 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getStockSplitsCalendar = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache("", "getStockSplitsCalendar");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/stock-splits-calendar", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getStockSplitsCalendar'
|
|
||||||
setCache("", output, "getStockSplitsCalendar");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getStockSplitsCalendar: await getStockSplitsCalendar(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
23
src/routes/stocks/+page.server.ts
Normal file
23
src/routes/stocks/+page.server.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
export const load = async ({ locals }) => {
|
||||||
|
const getStockList = async () => {
|
||||||
|
const { apiKey, apiURL } = locals;
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/all-stock-tickers", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getStockList: await getStockList(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,35 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent }) => {
|
|
||||||
const getStockList = async () => {
|
|
||||||
let output;
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache("", "getStockList");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/all-stock-tickers", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getStockList'
|
|
||||||
setCache("", output, "getStockList");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getStockList: await getStockList(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
30
src/routes/stocks/[tickerID]/dividends/+page.server.ts
Normal file
30
src/routes/stocks/[tickerID]/dividends/+page.server.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
export const load = async ({ params, locals }) => {
|
||||||
|
const getStockDividend = async () => {
|
||||||
|
let newsList;
|
||||||
|
|
||||||
|
const { apiURL, apiKey } = locals;
|
||||||
|
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
};
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/stock-dividend", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
newsList = await response.json();
|
||||||
|
|
||||||
|
return newsList;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getStockDividend: await getStockDividend(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,41 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent, params }) => {
|
|
||||||
const getStockDividend = async () => {
|
|
||||||
let newsList;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache(params.tickerID, "getStockDividend");
|
|
||||||
if (cachedData) {
|
|
||||||
newsList = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiURL, apiKey } = await parent();
|
|
||||||
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
};
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/stock-dividend", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
newsList = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getStockDividend'
|
|
||||||
setCache(params.tickerID, newsList, "getStockDividend");
|
|
||||||
}
|
|
||||||
|
|
||||||
return newsList;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getStockDividend: await getStockDividend(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
28
src/routes/stocks/[tickerID]/forecast/+page.server.ts
Normal file
28
src/routes/stocks/[tickerID]/forecast/+page.server.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
export const load = async ({ locals, params }) => {
|
||||||
|
const getAnalystEstimate = async () => {
|
||||||
|
const { apiURL, apiKey } = locals;
|
||||||
|
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
};
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/analyst-estimate", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getAnalystEstimate: await getAnalystEstimate(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,39 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent, params }) => {
|
|
||||||
const getAnalystEstimate = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
const cachedData = getCache(params.tickerID, "getAnalystEstimate");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiURL, apiKey } = await parent();
|
|
||||||
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
};
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/analyst-estimate", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
setCache(params.tickerID, output, "getAnalystEstimate");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getAnalystEstimate: await getAnalystEstimate(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
28
src/routes/stocks/[tickerID]/forecast/ai/+page.server.ts
Normal file
28
src/routes/stocks/[tickerID]/forecast/ai/+page.server.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
export const load = async ({ locals, params }) => {
|
||||||
|
const getAnalystTickerHistory = async () => {
|
||||||
|
const { apiURL, apiKey } = locals;
|
||||||
|
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
};
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/analyst-ticker-history", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getAnalystTickerHistory: await getAnalystTickerHistory(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,39 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent, params }) => {
|
|
||||||
const getAnalystTickerHistory = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
const cachedData = getCache(params.tickerID, "getAnalystTickerHistory");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiURL, apiKey } = await parent();
|
|
||||||
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
};
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/analyst-ticker-history", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
setCache(params.tickerID, output, "getAnalystTickerHistory");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getAnalystTickerHistory: await getAnalystTickerHistory(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
export const load = async ({ parent, params }) => {
|
||||||
|
const getAnalystTickerHistory = async () => {
|
||||||
|
const { apiURL, apiKey } = await parent();
|
||||||
|
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
};
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/analyst-ticker-history", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getAnalystTickerHistory: await getAnalystTickerHistory(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,39 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent, params }) => {
|
|
||||||
const getAnalystTickerHistory = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
const cachedData = getCache(params.tickerID, "getAnalystTickerHistory");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiURL, apiKey } = await parent();
|
|
||||||
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
};
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/analyst-ticker-history", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
setCache(params.tickerID, output, "getAnalystTickerHistory");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getAnalystTickerHistory: await getAnalystTickerHistory(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
112
src/routes/stocks/[tickerID]/insider/+page.server.ts
Normal file
112
src/routes/stocks/[tickerID]/insider/+page.server.ts
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
const transactionTypeMap = {
|
||||||
|
"P-Purchase": "Bought",
|
||||||
|
"A-Award": "Grant",
|
||||||
|
"D-Return": "Grant",
|
||||||
|
"G-Gift": "Grant",
|
||||||
|
"S-Sale": "Sold",
|
||||||
|
"M-Exempt": "Exercise",
|
||||||
|
"X-InTheMoney": "Exercise",
|
||||||
|
"C-Conversion": "Exercise",
|
||||||
|
"F-InKind": "Sold",
|
||||||
|
"J-Other": (item) => {
|
||||||
|
if (item.acquistionOrDisposition === "D") {
|
||||||
|
return "Sold";
|
||||||
|
} else if (item.acquistionOrDisposition === "A") {
|
||||||
|
return "Bought";
|
||||||
|
} else {
|
||||||
|
return "Other";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"": "n/a",
|
||||||
|
};
|
||||||
|
|
||||||
|
export const load = async ({ locals, params }) => {
|
||||||
|
const { apiURL, apiKey } = locals;
|
||||||
|
|
||||||
|
const getInsiderTrading = async () => {
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
};
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/insider-trading", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
let output = await response.json();
|
||||||
|
|
||||||
|
output = output?.map((item) => ({
|
||||||
|
...item,
|
||||||
|
transactionType:
|
||||||
|
typeof transactionTypeMap[item?.transactionType] === "function"
|
||||||
|
? transactionTypeMap[item?.transactionType](item)
|
||||||
|
: transactionTypeMap[item?.transactionType] || "n/a",
|
||||||
|
}));
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getInsiderTradingStatistics = async () => {
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
};
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/insider-trading-statistics", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response?.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
async function historicalPrice() {
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
timePeriod: "max",
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await fetch(apiURL + "/historical-price", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = (await response?.json()) ?? [];
|
||||||
|
|
||||||
|
//Adding this would create a bug hence I cant use the historicalPrice endpoint such as in +page.svelte but rather need to call
|
||||||
|
// it again without modification.
|
||||||
|
/*
|
||||||
|
output= (data) => map(({ time, open, high, low, close }) => ({
|
||||||
|
time: Date.parse(time),
|
||||||
|
open,
|
||||||
|
high,
|
||||||
|
low,
|
||||||
|
close
|
||||||
|
}));
|
||||||
|
*/
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getInsiderTrading: await getInsiderTrading(),
|
||||||
|
getInsiderTradingStatistics: await getInsiderTradingStatistics(),
|
||||||
|
getHistoricalPrice: await historicalPrice(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,141 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
const transactionTypeMap = {
|
|
||||||
"P-Purchase": "Bought",
|
|
||||||
"A-Award": "Grant",
|
|
||||||
"D-Return": "Grant",
|
|
||||||
"G-Gift": "Grant",
|
|
||||||
"S-Sale": "Sold",
|
|
||||||
"M-Exempt": "Exercise",
|
|
||||||
"X-InTheMoney": "Exercise",
|
|
||||||
"C-Conversion": "Exercise",
|
|
||||||
"F-InKind": "Sold",
|
|
||||||
"J-Other": (item) => {
|
|
||||||
if (item.acquistionOrDisposition === "D") {
|
|
||||||
return "Sold";
|
|
||||||
} else if (item.acquistionOrDisposition === "A") {
|
|
||||||
return "Bought";
|
|
||||||
} else {
|
|
||||||
return "Other";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"": "n/a",
|
|
||||||
};
|
|
||||||
|
|
||||||
export const load = async ({ parent, params }) => {
|
|
||||||
const { apiURL, apiKey } = await parent();
|
|
||||||
|
|
||||||
const getInsiderTrading = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
const cachedData = getCache(params.tickerID, "getInsiderTrading");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
};
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/insider-trading", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
output = output?.map((item) => ({
|
|
||||||
...item,
|
|
||||||
transactionType:
|
|
||||||
typeof transactionTypeMap[item?.transactionType] === "function"
|
|
||||||
? transactionTypeMap[item?.transactionType](item)
|
|
||||||
: transactionTypeMap[item?.transactionType] || "n/a",
|
|
||||||
}));
|
|
||||||
|
|
||||||
setCache(params.tickerID, output, "getInsiderTrading");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getInsiderTradingStatistics = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
const cachedData = getCache(params.tickerID, "getInsiderTradingStatistics");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
};
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/insider-trading-statistics", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response?.json();
|
|
||||||
|
|
||||||
setCache(params.tickerID, output, "getInsiderTradingStatistics");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
async function historicalPrice() {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
const cachedData = getCache(params.tickerID, "historicalPrice" + "insider");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
timePeriod: "max",
|
|
||||||
};
|
|
||||||
|
|
||||||
const response = await fetch(apiURL + "/historical-price", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = (await response?.json()) ?? [];
|
|
||||||
|
|
||||||
//Adding this would create a bug hence I cant use the historicalPrice endpoint such as in +page.svelte but rather need to call
|
|
||||||
// it again without modification.
|
|
||||||
/*
|
|
||||||
output= (data) => map(({ time, open, high, low, close }) => ({
|
|
||||||
time: Date.parse(time),
|
|
||||||
open,
|
|
||||||
high,
|
|
||||||
low,
|
|
||||||
close
|
|
||||||
}));
|
|
||||||
*/
|
|
||||||
|
|
||||||
setCache(params.tickerID, output, "historicalPrice" + "insider");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getInsiderTrading: await getInsiderTrading(),
|
|
||||||
getInsiderTradingStatistics: await getInsiderTradingStatistics(),
|
|
||||||
getHistoricalPrice: await historicalPrice(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
export const load = async ({ locals, params }) => {
|
||||||
|
const getSenateTrading = async () => {
|
||||||
|
const { apiURL, apiKey } = locals;
|
||||||
|
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
};
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/congress-trading-ticker", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getSenateTrading: await getSenateTrading(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,41 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent, params }) => {
|
|
||||||
const getSenateTrading = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache(params.tickerID, "getSenateTrading");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiURL, apiKey } = await parent();
|
|
||||||
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
};
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/congress-trading-ticker", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getSenateTrading'
|
|
||||||
setCache(params.tickerID, output, "getSenateTrading");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getSenateTrading: await getSenateTrading(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
const now = new Date();
|
||||||
|
const year = now?.getFullYear()?.toString();
|
||||||
|
const quarter = (Math.floor(now?.getMonth() / 3) + 1)?.toString();
|
||||||
|
|
||||||
|
export const load = async ({ locals, params }) => {
|
||||||
|
const getTranscripts = async () => {
|
||||||
|
let output;
|
||||||
|
|
||||||
|
const { apiKey, apiURL } = locals;
|
||||||
|
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
quarter: quarter,
|
||||||
|
year: year,
|
||||||
|
};
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/earnings-call-transcripts", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getTranscripts: await getTranscripts(),
|
||||||
|
quarter,
|
||||||
|
year,
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,56 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
const now = new Date();
|
|
||||||
const year = now?.getFullYear()?.toString();
|
|
||||||
const quarter = (Math.floor(now?.getMonth() / 3) + 1)?.toString();
|
|
||||||
|
|
||||||
export const load = async ({ parent, params }) => {
|
|
||||||
const getTranscripts = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache(
|
|
||||||
`${params.tickerID}-Q-1-2024`,
|
|
||||||
"getTranscripts",
|
|
||||||
);
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
quarter: quarter,
|
|
||||||
year: year,
|
|
||||||
};
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/earnings-call-transcripts", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getTranscripts'
|
|
||||||
setCache(
|
|
||||||
`${params.tickerID}-Q-${quarter}-${year}`,
|
|
||||||
output,
|
|
||||||
"getTranscripts",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getTranscripts: await getTranscripts(),
|
|
||||||
quarter,
|
|
||||||
year,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
28
src/routes/stocks/[tickerID]/news/+page.server.ts
Normal file
28
src/routes/stocks/[tickerID]/news/+page.server.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
export const load = async ({ locals, params }) => {
|
||||||
|
const getStockNews = async () => {
|
||||||
|
const { apiURL, apiKey } = locals;
|
||||||
|
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
};
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/stock-news", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getStockNews: await getStockNews(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -91,10 +91,10 @@ function loadMoreData() {
|
|||||||
|
|
||||||
|
|
||||||
<section class="w-auto max-w-4xl bg-[#09090B] overflow-hidden text-black h-full mb-40">
|
<section class="w-auto max-w-4xl bg-[#09090B] overflow-hidden text-black h-full mb-40">
|
||||||
<div class="m-auto h-full overflow-hidden ">
|
<div class="m-auto h-full overflow-hidden w-full">
|
||||||
<main class="">
|
<main class="w-full">
|
||||||
<div class="sm:p-7 m-auto mt-2 sm:mt-0">
|
<div class="sm:p-7 m-auto mt-2 sm:mt-0 w-full">
|
||||||
<div class="mb-6">
|
<div class="mb-6 w-full">
|
||||||
<h1 class="text-2xl sm:text-3xl text-white font-bold">
|
<h1 class="text-2xl sm:text-3xl text-white font-bold">
|
||||||
News
|
News
|
||||||
</h1>
|
</h1>
|
||||||
|
|||||||
@ -1,41 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent, params }) => {
|
|
||||||
const getStockNews = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache(params.tickerID, "getStockNews");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiURL, apiKey } = await parent();
|
|
||||||
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
};
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/stock-news", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getStockNews'
|
|
||||||
setCache(params.tickerID, output, "getStockNews");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getStockNews: await getStockNews(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
94
src/routes/stocks/[tickerID]/options/+page.server.ts
Normal file
94
src/routes/stocks/[tickerID]/options/+page.server.ts
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
export const load = async ({ locals, params }) => {
|
||||||
|
const getOptionsPlotData = async () => {
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await fetch(locals?.apiURL + "/options-plot-ticker", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": locals?.apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getOptionsHistoricalData = async () => {
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
};
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(
|
||||||
|
locals?.apiURL + "/options-historical-data-ticker",
|
||||||
|
{
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": locals?.apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getOptionsChainData = async () => {
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
};
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(
|
||||||
|
locals?.apiURL + "/options-chain-data-ticker",
|
||||||
|
{
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": locals?.apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getOptionsGexData = async () => {
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
};
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(locals?.apiURL + "/options-gex-ticker", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": locals?.apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getOptionsPlotData: await getOptionsPlotData(),
|
||||||
|
getOptionsHistoricalData: await getOptionsHistoricalData(),
|
||||||
|
getOptionsChainData: await getOptionsChainData(),
|
||||||
|
getOptionsGexData: await getOptionsGexData(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,122 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent, params }) => {
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
|
|
||||||
const getOptionsPlotData = async () => {
|
|
||||||
const cachedData = getCache(params.tickerID, "getOptionsPlotData");
|
|
||||||
if (cachedData) {
|
|
||||||
return cachedData;
|
|
||||||
} else {
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
};
|
|
||||||
|
|
||||||
const response = await fetch(apiURL + "/options-plot-ticker", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
const output = await response.json();
|
|
||||||
|
|
||||||
setCache(params.tickerID, output, "getOptionsPlotData");
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const getOptionsHistoricalData = async () => {
|
|
||||||
let output;
|
|
||||||
const cachedData = getCache(params.tickerID, "getOptionsHistoricalData");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
};
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/options-historical-data-ticker", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
setCache(params.tickerID, output, "getOptionsHistoricalData");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getOptionsChainData = async () => {
|
|
||||||
let output;
|
|
||||||
const cachedData = getCache(params.tickerID, "getOptionsChainData");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
};
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/options-chain-data-ticker", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
setCache(params.tickerID, output, "getOptionsChainData");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getOptionsGexData = async () => {
|
|
||||||
let output;
|
|
||||||
const cachedData = getCache(params.tickerID, "getOptionsGexData");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
};
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/options-gex-ticker", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
setCache(params.tickerID, output, "getOptionsGexData");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getOptionsPlotData: await getOptionsPlotData(),
|
|
||||||
getOptionsHistoricalData: await getOptionsHistoricalData(),
|
|
||||||
getOptionsChainData: await getOptionsChainData(),
|
|
||||||
getOptionsGexData: await getOptionsGexData(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -2,11 +2,40 @@ import { error, fail, redirect } from "@sveltejs/kit";
|
|||||||
import { validateData } from "$lib/utils";
|
import { validateData } from "$lib/utils";
|
||||||
import { loginUserSchema, registerUserSchema } from "$lib/schemas";
|
import { loginUserSchema, registerUserSchema } from "$lib/schemas";
|
||||||
|
|
||||||
|
export const load = async ({ locals, params }) => {
|
||||||
|
const getQuantStats = async () => {
|
||||||
|
const { apiKey, apiURL } = locals;
|
||||||
|
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
};
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/get-quant-stats", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getQuantStats: await getQuantStats(),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
login: async ({ request, locals }) => {
|
login: async ({ request, locals }) => {
|
||||||
const { formData, errors } = await validateData(
|
const { formData, errors } = await validateData(
|
||||||
await request.formData(),
|
await request.formData(),
|
||||||
loginUserSchema,
|
loginUserSchema
|
||||||
);
|
);
|
||||||
|
|
||||||
if (errors) {
|
if (errors) {
|
||||||
@ -40,7 +69,7 @@ export const actions = {
|
|||||||
register: async ({ locals, request }) => {
|
register: async ({ locals, request }) => {
|
||||||
const { formData, errors } = await validateData(
|
const { formData, errors } = await validateData(
|
||||||
await request.formData(),
|
await request.formData(),
|
||||||
registerUserSchema,
|
registerUserSchema
|
||||||
);
|
);
|
||||||
|
|
||||||
if (errors) {
|
if (errors) {
|
||||||
@ -94,7 +123,7 @@ await locals.pb?.collection('users').update(
|
|||||||
const redirectURL = `${url.origin}/oauth`;
|
const redirectURL = `${url.origin}/oauth`;
|
||||||
|
|
||||||
const targetItem = authMethods.authProviders?.findIndex(
|
const targetItem = authMethods.authProviders?.findIndex(
|
||||||
(item) => item?.name === providerSelected,
|
(item) => item?.name === providerSelected
|
||||||
);
|
);
|
||||||
//console.log("==================")
|
//console.log("==================")
|
||||||
//console.log(authMethods.authProviders)
|
//console.log(authMethods.authProviders)
|
||||||
|
|||||||
@ -1,41 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent, params }) => {
|
|
||||||
const getQuantStats = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache(params.tickerID, "getQuantStats");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
};
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/get-quant-stats", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getQuantStats'
|
|
||||||
setCache(params.tickerID, output, "getQuantStats");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getQuantStats: await getQuantStats(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
import { getCache, setCache } from "$lib/store";
|
||||||
|
|
||||||
|
export const load = async ({ locals, params }) => {
|
||||||
|
const getBalanceSheetStatement = async () => {
|
||||||
|
const { apiKey, apiURL } = locals;
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
};
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/stock-balance-sheet", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getBalanceSheetStatement: await getBalanceSheetStatement(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,40 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent, params }) => {
|
|
||||||
const getBalanceSheetStatement = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache(params.tickerID, "getBalanceSheetStatement");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
};
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/stock-balance-sheet", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getBalanceSheetStatement'
|
|
||||||
setCache(params.tickerID, output, "getBalanceSheetStatement");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getBalanceSheetStatement: await getBalanceSheetStatement(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
28
src/routes/stocks/[tickerID]/stats/cash-flow/+page.server.ts
Normal file
28
src/routes/stocks/[tickerID]/stats/cash-flow/+page.server.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
export const load = async ({ locals, params }) => {
|
||||||
|
const getCashFlowStatement = async () => {
|
||||||
|
const { apiKey, apiURL } = locals;
|
||||||
|
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
};
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/stock-cash-flow", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getCashFlowStatement: await getCashFlowStatement(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,41 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent, params }) => {
|
|
||||||
const getCashFlowStatement = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache(params.tickerID, "getCashFlowStatement");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
};
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/stock-cash-flow", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getCashFlowStatement'
|
|
||||||
setCache(params.tickerID, output, "getCashFlowStatement");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getCashFlowStatement: await getCashFlowStatement(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
27
src/routes/stocks/[tickerID]/stats/employees/+page.server.ts
Normal file
27
src/routes/stocks/[tickerID]/stats/employees/+page.server.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
export const load = async ({ locals, params }) => {
|
||||||
|
const getHistoryEmployee = async () => {
|
||||||
|
const { apiKey, apiURL } = locals;
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
};
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/history-employees", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getHistoryEmployee: await getHistoryEmployee(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,39 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent, params }) => {
|
|
||||||
const getHistoryEmployee = async () => {
|
|
||||||
let output;
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache(params.tickerID, "getHistoryEmployee");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
};
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/history-employees", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getHistoryEmployee'
|
|
||||||
setCache(params.tickerID, output, "getHistoryEmployee");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getHistoryEmployee: await getHistoryEmployee(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
27
src/routes/stocks/[tickerID]/stats/income/+page.server.ts
Normal file
27
src/routes/stocks/[tickerID]/stats/income/+page.server.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
export const load = async ({ locals, params }) => {
|
||||||
|
const getIncomeStatement = async () => {
|
||||||
|
const { apiKey, apiURL } = locals;
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
};
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/stock-income", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getIncomeStatement: await getIncomeStatement(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,40 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent, params }) => {
|
|
||||||
const getIncomeStatement = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache(params.tickerID, "getIncomeStatement");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
};
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/stock-income", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getIncomeStatement'
|
|
||||||
setCache(params.tickerID, output, "getIncomeStatement");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getIncomeStatement: await getIncomeStatement(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
export const load = async ({ locals, params }) => {
|
||||||
|
const getHistoricalMarketCap = async () => {
|
||||||
|
const { apiKey, apiURL } = locals;
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
};
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/historical-market-cap", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getHistoricalMarketCap: await getHistoricalMarketCap(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -249,6 +249,7 @@ async function plotData()
|
|||||||
type: 'line',
|
type: 'line',
|
||||||
areaStyle: {opacity: 0.2},
|
areaStyle: {opacity: 0.2},
|
||||||
smooth: true,
|
smooth: true,
|
||||||
|
symbol: 'none',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
tooltip: {
|
tooltip: {
|
||||||
|
|||||||
@ -1,40 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent, params }) => {
|
|
||||||
const getHistoricalMarketCap = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache(params.tickerID, "getHistoricalMarketCap");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
};
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/historical-market-cap", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getHistoricalMarketCap'
|
|
||||||
setCache(params.tickerID, output, "getHistoricalMarketCap");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getHistoricalMarketCap: await getHistoricalMarketCap(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
28
src/routes/stocks/[tickerID]/stats/ratios/+page.server.ts
Normal file
28
src/routes/stocks/[tickerID]/stats/ratios/+page.server.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
export const load = async ({ locals, params }) => {
|
||||||
|
const getRatiosStatement = async () => {
|
||||||
|
const { apiKey, apiURL } = locals;
|
||||||
|
|
||||||
|
const postData = {
|
||||||
|
ticker: params.tickerID,
|
||||||
|
};
|
||||||
|
|
||||||
|
// make the POST request to the endpoint
|
||||||
|
const response = await fetch(apiURL + "/stock-ratios", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await response.json();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make sure to return a promise
|
||||||
|
return {
|
||||||
|
getRatiosStatement: await getRatiosStatement(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,41 +0,0 @@
|
|||||||
import { getCache, setCache } from "$lib/store";
|
|
||||||
|
|
||||||
export const load = async ({ parent, params }) => {
|
|
||||||
const getRatiosStatement = async () => {
|
|
||||||
let output;
|
|
||||||
|
|
||||||
// Get cached data for the specific tickerID
|
|
||||||
const cachedData = getCache(params.tickerID, "getRatiosStatement");
|
|
||||||
if (cachedData) {
|
|
||||||
output = cachedData;
|
|
||||||
} else {
|
|
||||||
const { apiKey, apiURL } = await parent();
|
|
||||||
|
|
||||||
const postData = {
|
|
||||||
ticker: params.tickerID,
|
|
||||||
};
|
|
||||||
|
|
||||||
// make the POST request to the endpoint
|
|
||||||
const response = await fetch(apiURL + "/stock-ratios", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-KEY": apiKey,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(postData),
|
|
||||||
});
|
|
||||||
|
|
||||||
output = await response.json();
|
|
||||||
|
|
||||||
// Cache the data for this specific tickerID with a specific name 'getRatiosStatement'
|
|
||||||
setCache(params.tickerID, output, "getRatiosStatement");
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make sure to return a promise
|
|
||||||
return {
|
|
||||||
getRatiosStatement: await getRatiosStatement(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
Loading…
x
Reference in New Issue
Block a user