diff --git a/lib/index.js b/lib/index.js index e5317dc..6985d06 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,4 +1,3 @@ -import { aggregateTokens } from "./aggregator.js"; const name = "dsh-plugin-token-heatmap"; const inject = ["webServer"]; function apply(ctx) { @@ -19,6 +18,7 @@ function apply(ctx) { } if (req.method === "GET" && (pathname === "/api/dsh-token-heatmap" || pathname === "/api/dsh-token-heatmap/stats")) { try { + const { aggregateTokens } = await import(`./aggregator.js?t=${Date.now()}`); const data = await aggregateTokens(); res.writeHead(200, { "Content-Type": "application/json; charset=utf-8", diff --git a/src/server/index.ts b/src/server/index.ts index 739f767..901909e 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -1,5 +1,3 @@ -import { aggregateTokens } from "./aggregator.js"; - export const name = "dsh-plugin-token-heatmap"; export const inject = ["webServer"]; @@ -12,7 +10,6 @@ export function apply(ctx: any) { const url = new URL(req.url, "http://localhost"); const pathname = url.pathname.replace(/\/+$/, ""); - // Set common headers res.setHeader("Access-Control-Allow-Origin", "*"); res.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS"); res.setHeader("Access-Control-Allow-Headers", "Content-Type"); @@ -25,6 +22,7 @@ export function apply(ctx: any) { if (req.method === "GET" && (pathname === "/api/dsh-token-heatmap" || pathname === "/api/dsh-token-heatmap/stats")) { try { + const { aggregateTokens } = await import(`./aggregator.js?t=${Date.now()}`); const data = await aggregateTokens(); res.writeHead(200, { "Content-Type": "application/json; charset=utf-8",