From 303c2132a194c2e8c54fa0e2f09a4b28a57ef4b9 Mon Sep 17 00:00:00 2001 From: Niki Wix Skaarup Date: Sun, 6 Apr 2025 00:12:17 +0200 Subject: [PATCH 1/3] ts... --- tsconfig.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 9c62f74..0abd418 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,25 +1,25 @@ { "compilerOptions": { // Environment setup & latest features - "lib": ["ESNext"], + "lib": [ + "ESNext", + "DOM", + ], "target": "ESNext", "module": "ESNext", "moduleDetection": "force", "jsx": "react-jsx", "allowJs": true, - // Bundler mode "moduleResolution": "bundler", "allowImportingTsExtensions": true, "verbatimModuleSyntax": true, "noEmit": true, - // Best practices "strict": true, "skipLibCheck": true, "noFallthroughCasesInSwitch": true, "noUncheckedIndexedAccess": true, - // Some stricter flags (disabled by default) "noUnusedLocals": false, "noUnusedParameters": false, From fb56769405d3ddbdfe5d65ec7203c5fe9c80b0ea Mon Sep 17 00:00:00 2001 From: Niki Wix Skaarup Date: Sun, 6 Apr 2025 00:16:11 +0200 Subject: [PATCH 2/3] cache --- src/server.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/server.ts b/src/server.ts index 329cb29..8bf6ba7 100644 --- a/src/server.ts +++ b/src/server.ts @@ -25,9 +25,9 @@ const entriesCacheTimeLimit = 1000 * 15; async function getEntriesCached() { if (entriesCacheTime + entriesCacheTimeLimit < Date.now()) { - const data = await ptApi.query(); - entriesCache = JSON.stringify(data); - entriesCacheTime = Date.now(); + const data = await ptApi.query(); + entriesCache = JSON.stringify(data); + entriesCacheTime = Date.now(); } return entriesCache; } @@ -100,9 +100,8 @@ Bun.serve({ globalThis.loginTokens.add(token); - if (entriesCacheTime + entriesCacheTimeLimit < Date.now()) { - setTimeout(getEntriesCached, 1); - } + setTimeout(getEntriesCached, 1); + return new Response('Login successful', { headers }); } From 0d06e26d8985e54436839c7e09ccf144b4eb8c97 Mon Sep 17 00:00:00 2001 From: Niki Wix Skaarup Date: Sun, 6 Apr 2025 02:27:03 +0200 Subject: [PATCH 3/3] unneeded --- Dockerfile | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8eaf5c5..a93edda 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,8 @@ FROM oven/bun:latest AS base WORKDIR /app +ENV NODE_ENV=production + # install dependencies into temp directory # this will cache them and speed up future builds FROM base AS install @@ -22,7 +24,6 @@ COPY --from=install /temp/dev/node_modules node_modules COPY . . # [optional] tests & build -ENV NODE_ENV=production # RUN bun test # RUN bun run build @@ -34,5 +35,4 @@ COPY --from=install /temp/prod/node_modules node_modules COPY --from=prerelease /app/ . # run the app - -ENTRYPOINT [ "bun", "run", "start" ] +ENTRYPOINT [ "bun", "start" ] diff --git a/package.json b/package.json index f4b03d6..5567cf1 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "type": "module", "private": true, "scripts": { - "start": "bun run src/server.ts", + "start": "bun src/server.ts", "dev": "bun --watch run src/server.ts", "hot": "bun --hot run src/server.ts", "build": "bun build src/server.ts --compile --minify --sourcemap --target=bun-linux-x64-modern --outfile server",