all repos — website @ 53d704777f8899b8750b083cef47b8fdf5830373

My website

Use import.meta instead of Bun to get envvars
Alan Pearce alan@alanpearce.eu
Mon, 01 Apr 2024 20:11:44 +0200
commit

53d704777f8899b8750b083cef47b8fdf5830373

parent

734fbe8444db4454953663dd263a5778f8742eeb

3 files changed, 7 insertions(+), 5 deletions(-)

jump to
M bin/build.tsbin/build.ts
@@ -4,7 +4,7 @@ import log from "loglevel"; 
 import generateSite from "../src/templates";
 
-log.setLevel((Bun.env.LOG_LEVEL || "info") as log.LogLevelDesc);
+log.setLevel((import.meta.env.LOG_LEVEL || "info") as log.LogLevelDesc);
 
 fs.mkdirSync("public", { recursive: true });
 log.info("Generating site...");
M src/app.tssrc/app.ts
@@ -8,15 +8,17 @@ import log from "loglevel"; 
 import config from "./config";
 
-log.setLevel((Bun.env.LOG_LEVEL || "info") as log.LogLevelDesc);
+log.setLevel((import.meta.env.LOG_LEVEL || "info") as log.LogLevelDesc);
 
 Sentry.init({
-  release: `homestead@${Bun.env.FLY_MACHINE_VERSION}`,
+  release: `homestead@${import.meta.env.FLY_MACHINE_VERSION}`,
   tracesSampleRate: 1.0,
 });
 
 const expectedHostURL = new URL(
-  Bun.env.NODE_ENV === "production" ? config.base_url : "http://localhost:3000",
+  import.meta.env.NODE_ENV === "production"
+    ? config.base_url
+    : "http://localhost:3000",
 );
 const defaultHeaders = {
   ...config.extra.headers,
M src/index.tssrc/index.ts
@@ -2,7 +2,7 @@ import log from "loglevel"; 
 import { server, metricsServer } from "./app";
 
-log.setLevel((Bun.env.LOG_LEVEL || "info") as log.LogLevelDesc);
+log.setLevel((import.meta.env.LOG_LEVEL || "info") as log.LogLevelDesc);
 
 const metricsServed = Bun.serve(metricsServer);
 console.info(`Metrics server started on port ${metricsServed.port}`);