All files / app-leaderboard/src/pages client-script.ts

100% Statements 3/3
100% Branches 0/0
100% Functions 2/2
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16          11x     11x 1x            
import type { Hono } from 'hono';
import type { AppEnv } from '../app.ts';
import { CLIENT_JS, CLIENT_JS_HASH } from './client.generated.ts';
 
/** Where the pages' client script (client/main.ts) is served; the hash in the name lets browsers keep it forever. */
export const CLIENT_SCRIPT_PATH = `/assets/client.${CLIENT_JS_HASH}.js`;
 
export function mountClientScript(app: Hono<AppEnv>): void {
  app.get(CLIENT_SCRIPT_PATH, (c) =>
    c.body(CLIENT_JS, 200, {
      'content-type': 'text/javascript; charset=utf-8',
      'cache-control': 'public, max-age=31536000, immutable',
    }),
  );
}