Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

@bunny.net/scriptable-dns-types

Ambient TypeScript types for the bunny.net Scriptable DNS runtime.

Scriptable DNS scripts run with a set of globals injected by the runtime (ARecord, Monitoring, RoutingEngine, and so on). Because the runtime does not support import, these are provided as ambient declarations: they power editor autocomplete and an optional typecheck step, but are never imported at runtime.

Usage

Add the package as a dev dependency, then reference it from your script or your tsconfig.json.

Reference from the script file:

/// <reference types="@bunny.net/scriptable-dns-types" />

/** @param {DnsRequest} query */
export default function handleQuery(query) {
  if (query.request.geoLocation.country === "DE") {
    return new ARecord("203.0.113.20", 30);
  }
  return new ARecord("203.0.113.10", 30);
}

Or wire it up globally in tsconfig.json:

{
  "compilerOptions": {
    "allowJs": true,
    "checkJs": true,
    "noEmit": true,
    "types": ["@bunny.net/scriptable-dns-types"],
  },
}

The CLI scaffolds all of this for you with bunny dns scripts init.