npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

cloudflare-dyndns-updater

v1.0.0

Published

A TypeScript Express application that dynamically updates DNS records on Cloudflare with the current public IP address

Readme

Cloudflare Dynamic DNS Updater

This is a TypeScript Express application that dynamically updates DNS records on Cloudflare with the current public IP address of the server. It uses the Cloudflare API to perform the updates and includes authentication via API key.

Features

  • Fetches the current public IP address using the ipify API
  • Updates specified DNS records in Cloudflare API with the current IP address
  • Secured with an API key to prevent unauthorized access
  • Includes unique request IDs for all API responses
  • Provides human-friendly JSON responses with automatic pretty-printing
  • Clear separation between public and protected endpoints

Installation

Using npm

npm install cloudflare-dyndns-updater

From GitHub

  1. Clone the repository:
    git clone https://github.com/rdp-datacenter/ip-update.git
  2. Navigate to the project directory:
    cd ip-update
  3. Install dependencies:
    npm install
  4. Build the TypeScript files:
    npm run build

Getting Started

Prerequisites

  • Node.js (v14 or higher recommended)
  • npm or yarn
  • A Cloudflare account with API credentials
  • An .env file with the necessary configuration values

Environment Variables

Create a .env file in the root directory with the following variables:

  • PORT: Port number for the Express server (default is 5555)
  • CF_DNS: Comma-separated list of Cloudflare DNS record IDs that you want to update
  • CF_ZONE: Cloudflare Zone ID where DNS records are managed
  • CF_MAIL: Cloudflare Email address associated with the account
  • CF_AUTH: Cloudflare API token for authentication
  • RDP_API_KEY: Your own API key used to authenticate requests to this service

Example .env file:

RDP_API_KEY=your_own_generated_key
CF_DNS=record1,record2,record3
CF_ZONE=your_cloudflare_zone_id
CF_MAIL=your_cloudflare_email
CF_AUTH=your_cloudflare_auth_token
PORT=3000

Usage

As a standalone application

  1. Start the server:
    npm start
  2. Access the service information by sending a GET request to the root endpoint:
    curl -X GET http://localhost:5555/
  3. Update the DNS records by sending a GET request to the update endpoint with your API key:
    curl -X GET http://localhost:5555/update?api_key=<your-secure-api-key>
    Or using the header method:
    curl -X GET -H "rdp-key: <your-secure-api-key>" http://localhost:5555/update

As a module in your Node.js project

const { app } = require('cloudflare-dyndns-updater');
// Or with ES Modules
// import { app } from 'cloudflare-dyndns-updater';

// You can now use the Express app instance
const port = process.env.PORT || 3000;
app.listen(port, () => {
  console.log(`DNS updater running on port ${port}`);
});

API Endpoints

GET / (Public)

Returns information about the service and available endpoints.

Response:

{
  "name": "RDP DNS Updater",
  "version": "1.0.0",
  "request_id": "9ABCDD4CC53F2BC1-RDP",
  "endpoints": [
    { "path": "/update", "method": "GET", "description": "Update DNS records with current IP (requires API key)" },
    { "path": "/health", "method": "GET", "description": "Service health check (no auth required)" },
    { "path": "/update-all", "method": "GET", "description": "Update all DNS records (requires API key)" }
  ],
  "status": "operational"
}

GET /update (Protected)

Updates the DNS records with the current public IP address. Requires an API key.

Authentication:

  • Header: rdp-key: <your-api-key>
  • Or Query Parameter: api_key=<your-api-key>

Response (Success):

{
  "status": "success",
  "ip": "76.76.21.21",
  "request_id": "9ABCDD4CC53F2BC1-RDP",
  "records": [
    {
      "id": "record1",
      "name": "dns.rdpdatacenter.in",
      "success": true,
      "status": 200
    }
  ]
}

Response (Error):

{
  "status": "failed",
  "request_id": "9ABCDD4CC53F2BC1-RDP",
  "error": "Error message details"
}

GET /health (Public)

Checks if the service is running properly.

Response:

{
  "status": "healthy",
  "request_id": "9ABCDD4CC53F2BC1-RDP",
  "timestamp": "2025-04-26T12:34:56.789Z"
}

GET /update-all (Protected)

Updates all configured DNS records. Requires an API key.

Authentication:

  • Same as /update endpoint

Response:

{
  "status": "success",
  "request_id": "9ABCDD4CC53F2BC1-RDP",
  "message": "All DNS records updated successfully"
}

Request IDs

Every API response includes a unique request ID in both the response headers (RDP-Request-ID) and the response body (request_id). These IDs can be used for debugging and tracking purposes.

Development

For local development with automatic reloading:

npm run dev

Docker

You can run the application in a Docker container using either Docker directly or Docker Compose.

Using Docker Compose (Recommended)

A docker-compose.yml file is provided for easy deployment:

# Build and start the container
docker-compose up -d

# View logs
docker-compose logs -f

# Stop the container
docker-compose down

Using Docker Directly

# Build the Docker image
docker build -t ip-update .

# Run the container
docker run -p 5555:5555 --env-file .env ip-update

Docker Configuration

The Docker setup includes:

  • Node.js slim image for a lightweight container
  • Proper caching of npm dependencies
  • Production mode settings
  • Health checks via the /health endpoint
  • Volume mounting for logs
  • Automatic container restart

Vercel Deployment

This project is also configured for deployment on Vercel. The vercel.json file includes the necessary configuration.

Contributing

Feel free to submit issues, feature requests, or pull requests. Contributions are welcome!

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

For any questions or issues, please contact [email protected].