Skip to main content
Home

Built and signed on GitHub Actions

Manage IPs and TTLs of records through the DigitalOcean API

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
a year ago (0.9.1)

do-dns-update

Update a dns record through the DigitalOcean API.

Personally im using it to make sure that my gaming server that is sitting behind a dynamic IP got a working subdomain pointing to it :)

Installation

#For Deno
deno add @pinta365/do-dns-update

#For Bun
bunx jsr add @pinta365/do-dns-update

#For Node.js
npx jsr add @pinta365/do-dns-update

Usage

As simple as it gets, this sets the IP of a record. Check out the return object format below the code example.

import { RecordManager } from "@pinta365/do-dns-update";
const apiKey = "...."; // API key from Digital Ocean (https://cloud.digitalocean.com/account/api/)

// Instantiate with your API key.
const manager = new RecordManager(apiKey);

// Sets game.example.com to your current public IP
const updatedRecord = await manager.setIP("game", "example.com");
console.log(updatedRecord);
// Output:
// {
//   success: true,                // true/false
//   record: "game.example.com",   // affected record
//   ip: "217.64.123.123",         // ip number
//   message: "Update successful"  // No update needed / Update successful
// }

// Or with an override IP of "123.123.123.123" instead of your current public IP
const updatedRecord = await manager.setIP("game", "example.com", "123.123.123.123");
console.log(updatedRecord);
// Output:
// {
//   success: true,                // true/false
//   record: "game.example.com",   // affected record
//   ip: "123.123.123.123",        // ip number
//   message: "Update successful"  // No update needed / Update successful
// }

Interfaces for the return objects

//setIP()
interface IPSetResponse {
    success: boolean; // Indicates if the operation was successful.
    record: string; // The record (subdomain+domain) affected by the operation.
    ip: string | null; // The IP address set for the subdomain.
    message: string; // Message detailing the outcome of the operation.
}

//setTTL()
interface TTLSetResponse {
    success: boolean; // Indicates if the operation was successful.
    record: string; // The record (subdomain+domain) affected by the operation.
    ttl: number; // The time to live for the record, in seconds.
    message: string; // Message detailing the outcome of the operation.
}

Methods

RecordManager Class

setIP(subdomain: string, domain: string, ipOverride: string | null = null): IPSetResponse;

setTTL(subdomain: string, domain: string, ttl: number): TTLSetResponse;

Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@pinta365/do-dns-update

Import symbol

import * as do_dns_update from "@pinta365/do-dns-update";
or

Import directly with a jsr specifier

import * as do_dns_update from "jsr:@pinta365/do-dns-update";

Add Package

pnpm i jsr:@pinta365/do-dns-update
or (using pnpm 10.8 or older)
pnpm dlx jsr add @pinta365/do-dns-update

Import symbol

import * as do_dns_update from "@pinta365/do-dns-update";

Add Package

yarn add jsr:@pinta365/do-dns-update
or (using Yarn 4.8 or older)
yarn dlx jsr add @pinta365/do-dns-update

Import symbol

import * as do_dns_update from "@pinta365/do-dns-update";

Add Package

npx jsr add @pinta365/do-dns-update

Import symbol

import * as do_dns_update from "@pinta365/do-dns-update";

Add Package

bunx jsr add @pinta365/do-dns-update

Import symbol

import * as do_dns_update from "@pinta365/do-dns-update";