Skip to main content
This release is 1 version behind 0.23.0 — the latest version of @http/host-deno-deploy. Jump to latest

Built and signed on GitHub Actions

Hosting on Deno Deploy, for production/staging deployments.

This package works with Deno
This package works with Deno
JSR Score
94%
Published
3 months ago (0.21.0)
Package root>deno_deploy_etag.ts
import { eTag } from "jsr:/@std/http@^1.0.0-rc.5/etag"; /** * Get a default ETag for use in Deno deploy with `serveFile`/`serveDir`/`staticRoute`. * * NOTE: This can still be used in other runtimes and outside Deno Deploy, it'll just return undefined. */ export async function denoDeployEtag(): Promise<string | undefined> { if (!("Deno" in globalThis)) { return undefined; } const permission = (await Deno.permissions.query?.({ name: "env", variable: "DENO_DEPLOYMENT_ID", })).state ?? "granted"; const denoDeploymentId = permission === "granted" ? Deno.env.get("DENO_DEPLOYMENT_ID") : undefined; return denoDeploymentId ? eTag(denoDeploymentId, { weak: true }) : undefined; }