From 371171e61de02437bf5b23a83a7615fd1807c3ec Mon Sep 17 00:00:00 2001 From: Taevas Date: Fri, 7 Mar 2025 17:43:41 +0100 Subject: [PATCH] Various adjustments --- README.md | 4 ++-- api/coding_github.ts | 4 +--- api/coding_gitlab.ts | 6 ++---- api/coding_kitsudev.ts | 4 +--- api/fediverse_kitsuclub.ts | 4 +--- api/gaming_osu.ts | 4 +--- api/gaming_speedruncom.ts | 4 +--- api/hacking_hackthebox.ts | 6 ++---- api/japanese_wanikani.ts | 8 +++----- api/media_anilist.ts | 6 ++---- api/media_lastfm.ts | 4 +--- api/website_umami.ts | 6 ++---- eslint.config.mjs | 1 - index.css | 2 +- index.ts | 2 +- package.json | 3 ++- src/App.css | 2 +- src/Infos/DataHandler.tsx | 4 ++-- src/Infos/Gaming/Osu.tsx | 2 +- src/Main/Tabs/About/index.tsx | 4 ++-- src/Main/Tabs/Projects/index.tsx | 2 +- 21 files changed, 30 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 0ef8281..60ea087 100644 --- a/README.md +++ b/README.md @@ -11,12 +11,12 @@ bun dev ## Environment variables -This package uses [`@carbon/icons-react`](https://github.com/carbon-design-system/carbon/tree/main/packages/icons-react), which **installs [a telemetry package which can be disabled](https://github.com/ibm-telemetry/telemetry-js/tree/main#opting-out-of-ibm-telemetry-data-collection):** +This website uses [`@carbon/icons-react`](https://github.com/carbon-design-system/carbon/tree/main/packages/icons-react), which **installs [a telemetry package which can be disabled](https://github.com/ibm-telemetry/telemetry-js/tree/main#opting-out-of-ibm-telemetry-data-collection):** Set the environment variable IBM_TELEMETRY_DISABLED to true -This package makes use of several online APIs through Netlify in order to deliver the `Infos` that are available on the right side of the website, accessing most of these APIs requires a key (or similar), which can be set through the following environment variables: +This website makes use of several online APIs in order to deliver the `Infos` that are available on the right side of the main page, accessing most of these APIs requires a key (or similar), which can be set through the following environment variables: - `API_GITHUB` - `API_GITLAB` diff --git a/api/coding_github.ts b/api/coding_github.ts index 8ac45da..2341da5 100644 --- a/api/coding_github.ts +++ b/api/coding_github.ts @@ -19,7 +19,5 @@ export const coding_github: Handler = async () => { } : undefined, }; - return new Response(new Blob([JSON.stringify(info)], { - type: "application/json", - }), {status: 200}); + return Response.json(info, {status: 200}); }; diff --git a/api/coding_gitlab.ts b/api/coding_gitlab.ts index 9d6e854..ebf00d3 100644 --- a/api/coding_gitlab.ts +++ b/api/coding_gitlab.ts @@ -14,8 +14,6 @@ export const coding_gitlab: Handler = async () => { const activity: GitlabInfo = { date: created_at.substring(0, created_at.indexOf("T")), }; - - return new Response(new Blob([JSON.stringify(activity)], { - type: "application/json", - }), {status: 200}); + + return Response.json(activity, {status: 200}); }; diff --git a/api/coding_kitsudev.ts b/api/coding_kitsudev.ts index fc095b7..e67fe9c 100644 --- a/api/coding_kitsudev.ts +++ b/api/coding_kitsudev.ts @@ -16,7 +16,5 @@ export const coding_kitsudev: Handler = async () => { date: kitsudev[0].created }; - return new Response(new Blob([JSON.stringify(info)], { - type: "application/json", - }), {status: 200}); + return Response.json(info, {status: 200}); }; diff --git a/api/fediverse_kitsuclub.ts b/api/fediverse_kitsuclub.ts index 22b5921..34cd3ef 100644 --- a/api/fediverse_kitsuclub.ts +++ b/api/fediverse_kitsuclub.ts @@ -87,7 +87,5 @@ export const fediverse_kitsuclub: Handler = async () => { }) }; - return new Response(new Blob([JSON.stringify(activity)], { - type: "application/json", - }), {status: 200}); + return Response.json(activity, {status: 200}); }; diff --git a/api/gaming_osu.ts b/api/gaming_osu.ts index 9564779..8e537b1 100644 --- a/api/gaming_osu.ts +++ b/api/gaming_osu.ts @@ -26,7 +26,5 @@ export const gaming_osu: Handler = async (params) => { }, }; - return new Response(new Blob([JSON.stringify(info)], { - type: "application/json", - }), {status: 200}); + return Response.json(info, {status: 200}); }; diff --git a/api/gaming_speedruncom.ts b/api/gaming_speedruncom.ts index 112a4df..01be70d 100644 --- a/api/gaming_speedruncom.ts +++ b/api/gaming_speedruncom.ts @@ -74,9 +74,7 @@ export const gaming_speedruncom: Handler = async () => { run.time = run.time.substring(1); } - return new Response(new Blob([JSON.stringify(run)], { - type: "application/json", - }), {status: 200}); + return Response.json(run, {status: 200}); }; // https://gist.github.com/vankasteelj/74ab7793133f4b257ea3 diff --git a/api/hacking_hackthebox.ts b/api/hacking_hackthebox.ts index 8a9fd18..b995321 100644 --- a/api/hacking_hackthebox.ts +++ b/api/hacking_hackthebox.ts @@ -15,8 +15,6 @@ export const hacking_hackthebox: Handler = async () => { pwn.machine_avatar = `https://www.hackthebox.com${pwn.machine_avatar}`; pwn.date = pwn.date.substring(0, pwn.date.indexOf("T")); - - return new Response(new Blob([JSON.stringify(pwn)], { - type: "application/json", - }), {status: 200}); + + return Response.json(pwn, {status: 200}); }; diff --git a/api/japanese_wanikani.ts b/api/japanese_wanikani.ts index 96ba700..1ce1eb5 100644 --- a/api/japanese_wanikani.ts +++ b/api/japanese_wanikani.ts @@ -57,7 +57,7 @@ export const japanese_wanikani: Handler = async () => { const toRequest = urlsToRequest.map((url) => new Promise(async (resolve) => { const response = await fetch(url, {headers: { "Authorization": `Bearer ${process.env["API_WANIKANI"]}`, - "Content-Type": "application.json", + "Content-Type": "application/json", }}); resolve(await response.json()); })); @@ -93,7 +93,7 @@ export const japanese_wanikani: Handler = async () => { const subjectIdsAll = subjectIdsLessons.concat(subjectIdsReviews); const subjects = await (await fetch(`https://api.wanikani.com/v2/subjects?ids=${subjectIdsAll.toString()}`, {headers: { "Authorization": `Bearer ${process.env["API_WANIKANI"]}`, - "Content-Type": "application.json", + "Content-Type": "application/json", }})).json() as {data: Subject[]}; const lessons = addStuffToLearn(subjectIdsLessons, summary.data.lessons, subjects.data); @@ -107,7 +107,5 @@ export const japanese_wanikani: Handler = async () => { moreThingsToReviewAt, }; - return new Response(new Blob([JSON.stringify(info)], { - type: "application/json", - }), {status: 200}); + return Response.json(info, {status: 200}); }; diff --git a/api/media_anilist.ts b/api/media_anilist.ts index 9316e53..01bce26 100644 --- a/api/media_anilist.ts +++ b/api/media_anilist.ts @@ -62,8 +62,6 @@ export const media_anilist: Handler = async () => { anime.startDate = anime.startDate.substring(0, anime.startDate.indexOf("T")); anime.updateDate = anime.updateDate.substring(0, anime.updateDate.indexOf("T")); anime.endDate = anime.endDate.substring(0, anime.endDate.indexOf("T")); - - return new Response(new Blob([JSON.stringify(anime)], { - type: "application/json", - }), {status: 200}); + + return Response.json(anime, {status: 200}); }; diff --git a/api/media_lastfm.ts b/api/media_lastfm.ts index 3956240..2c6a826 100644 --- a/api/media_lastfm.ts +++ b/api/media_lastfm.ts @@ -39,7 +39,5 @@ export const media_lastfm: Handler = async () => { date: lastfm.recenttracks.track[0].date?.uts ?? String(Date.now()), }; - return new Response(new Blob([JSON.stringify(track)], { - type: "application/json", - }), {status: 200}); + return Response.json(track, {status: 200}); }; diff --git a/api/website_umami.ts b/api/website_umami.ts index 2482402..1153af4 100644 --- a/api/website_umami.ts +++ b/api/website_umami.ts @@ -17,7 +17,7 @@ export const website_umami: Handler = async () => { const now = new Date(); const response = await fetch(`${api_server}/websites/${website_id}/stats?startAt=${Number(new Date("2025"))}&endAt=${Number(now)}`, { headers: { - "Accept": "application.json", + "Accept": "application/json", "Authorization": `Bearer ${token?.access_token}` }, }); @@ -43,7 +43,5 @@ export const website_umami: Handler = async () => { totaltime: umami.totaltime.value }; - return new Response(new Blob([JSON.stringify(info)], { - type: "application/json", - }), {status: 200}); + return Response.json(info, {status: 200}); }; diff --git a/eslint.config.mjs b/eslint.config.mjs index d8f09b2..4c97003 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -37,7 +37,6 @@ export default tseslint.config( }, { ignores: [ - ".netlify/*", "dist/*", "*.js", "*.cjs", diff --git a/index.css b/index.css index 44619ec..ff6f481 100644 --- a/index.css +++ b/index.css @@ -1563,7 +1563,7 @@ video { @font-face { font-family: "LexendDeca"; - src: url("./assets/fonts/LexendDeca-Regular.ttf") format("truetype"); + src: url("assets/fonts/LexendDeca-Regular.ttf") format("truetype"); font-weight: normal; diff --git a/index.ts b/index.ts index c18c501..ff5eabc 100644 --- a/index.ts +++ b/index.ts @@ -38,7 +38,7 @@ const builds = await Bun.build({ }); const server = Bun.serve({ - port: 8080, + idleTimeout: 30, fetch: async (req) => { const url = new URL(req.url); const parameters = url.searchParams; diff --git a/package.json b/package.json index 9e203c5..67c3b3c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,8 @@ "scripts": { "dev": "bunx bun css && bun --hot index.ts", "css": "bun tailwindcss -i ./src/App.css -o index.css", - "lint": "bunx eslint ." + "lint": "bunx eslint .", + "start": "bun run index.ts" }, "dependencies": { "@bachmacintosh/wanikani-api-types": "^1.7.0", diff --git a/src/App.css b/src/App.css index 09345b8..a9d8a59 100644 --- a/src/App.css +++ b/src/App.css @@ -4,7 +4,7 @@ @font-face { font-family: "LexendDeca"; - src: url("./assets/fonts/LexendDeca-Regular.ttf") format("truetype"); + src: url("assets/fonts/LexendDeca-Regular.ttf") format("truetype"); font-weight: normal; font-style: normal; } diff --git a/src/Infos/DataHandler.tsx b/src/Infos/DataHandler.tsx index cbc145a..584fcf2 100644 --- a/src/Infos/DataHandler.tsx +++ b/src/Infos/DataHandler.tsx @@ -1,7 +1,7 @@ import React, {useState, useEffect} from "react"; /** Takes care of getting data regularly */ -export default function DataHandler(netlifyFunctionName: string, updateEveryXSeconds: number, expectData = true) { +export default function DataHandler(apiEndpoint: string, updateEveryXSeconds: number, expectData = true) { const [data, setData]: [T | undefined, React.Dispatch>] = useState(); const [error, setError] = useState(false); const [count, setCount] = useState(0); @@ -9,7 +9,7 @@ export default function DataHandler(netlifyFuncti // Try to get and set data const updateData = async () => { try { - const response = await fetch("/api/" + netlifyFunctionName); + const response = await fetch("/api/" + apiEndpoint); if (!response.ok) {throw "failed";}; setData(expectData ? await response.json() : true); setError(false); diff --git a/src/Infos/Gaming/Osu.tsx b/src/Infos/Gaming/Osu.tsx index 4cb75a1..ce1e897 100644 --- a/src/Infos/Gaming/Osu.tsx +++ b/src/Infos/Gaming/Osu.tsx @@ -28,7 +28,7 @@ export default function Osu(args: {ruleset: Ruleset}) { try { setElements([
- {`${ruleset} + {`${ruleset}

Global: #{data.ranks.global}

{data.country}: #{data.ranks.country}

diff --git a/src/Main/Tabs/About/index.tsx b/src/Main/Tabs/About/index.tsx index 842354b..fe189ab 100644 --- a/src/Main/Tabs/About/index.tsx +++ b/src/Main/Tabs/About/index.tsx @@ -13,7 +13,7 @@ export default function About({ const elements = [(
- Flag of Brittany + Flag of Brittany o/ I'm Taevas, a young person from (western France) who is currently invested in game development. I also do stuff related to web development, networking, and cybersecurity more rarely!

} fr={

o/ Je m'appelle Taevas, je suis une jeune personne de Bretagne qui s'investit dans le développement de jeux-vidéos. Je fais aussi des trucs qui touchent au développement web, aux réseaux, et plus rarement à la cybersécurité!

} @@ -31,7 +31,7 @@ export default function About({
- A drawing of Lain + A drawing of Lain I really like Japanese media! I'll pretty much always choose to have some drawing of Lain Iwakura from as my profile picture on the various websites I have an account on, as it is a piece of media I deeply enjoy.

} diff --git a/src/Main/Tabs/Projects/index.tsx b/src/Main/Tabs/Projects/index.tsx index a55d6f9..0851189 100644 --- a/src/Main/Tabs/Projects/index.tsx +++ b/src/Main/Tabs/Projects/index.tsx @@ -13,7 +13,7 @@ export default function Projects({ const elements = [(
- SwordVenture thumbnail + SwordVenture thumbnail initially was but months after the project ended, I made the choice to recode it from scratch in , a proper game engine!

} fr={

était à la base mais quelques mois plus tard, j'ai fait le choix de le refaire en entier dans , qui est un véritable moteur de jeu vidéo !

}