3.0.2 • Published 17 days ago

cloudflare-ddns-sync v3.0.2

Weekly downloads
3
License
ISC
Repository
github
Last release
17 days ago

npm.io npm version Downloads CLI

Overview

Cloudflare-DDNS-Sync is a simple module that updates Cloudflare DNS records.

For a more detailed overview, have a look at the Documentation

You may also have a look at the official CLI version of Cloudflare-DDNS-Sync.

How do I set this project up?

Prerequisites

  • Node
  • Cloudflare Account

Installation

To install Cloudflare-DDNS-Sync simply run:

npm install cloudflare-ddns-sync

in your project folder.

Usage

Hint: If a record is not existing, CDS will automatically create it when syncing.

Javascript Example

const Cddnss = require('cloudflare-ddns-sync').default;

// either email and key or token
const cddnss = new Cddnss({
  email: 'your@email.com',
  key: '<your-cloudflare-api-key>',
  token: '<your-cloudflare-api-token>',
});

const records = [
  {
    name: 'test-1.domain.com',
    type: 'A', // optional
    proxied: true, // optional
    ttl: 1, // optional
    priority: 0, // optional
    content: '1.2.3.4', // optional
  },
  {
    name: 'test-2.domain.com',
  },
];

cddnss.syncRecords(records).then((result) => {
  console.log(result);
});

Typescript Example

import Cddnss, {Record, RecordData} from 'cloudflare-ddns-sync';

// either email and key or token
const cddnss = new Cddnss({
  email: 'your@email.com',
  key: '<your-cloudflare-api-key>',
  token: '<your-cloudflare-api-token>',
});

const records: Array<Record> = [
  {
    name: 'test-1.yourdomain.com',
    type: 'A', // optional
    proxied: true, // optional
    ttl: 1, // optional
    priority: 0, // optional
    content: '1.2.3.4', // optional
  },
  {
    name: 'test-2.yourdomain.com',
  },
];

cddnss.syncRecords(records).then((result: Array<RecordData>) => {
  console.log(result);
});

Cron Expression Syntax

Cron expressions have the following syntax:

* * * * * *
┬ ┬ ┬ ┬ ┬ ┬
│ │ │ │ │ │
│ │ │ │ │ └──── weekday (0-7, sunday is 0 or 7)
│ │ │ │ └────── month (1-12)
│ │ │ └──────── day (1-31)
│ │ └────────── hour (0-23)
│ └──────────── minute (0-59)
└────────────── second (0-59) [optional]

Methods

For a more detailed view, have a look at the Documentation

Get Your Cloudflare API Key

  • Go to Cloudflare
  • Log In
  • In the upper right corner: click on the user icon
  • Go to "My Profile"
  • In the "API Tokens"-Section: click on the "View"-Button of the Global Key
  • Enter your password and fill the captcha
  • Copy the API Key

Tests

In order to run the tests there are two ways to do so

Use test-data.json

  • Open the test-data.json which can be found under src/tests/test-service/
  • Configure the email, cloudflare api key and the domain
  • Run npm test

Use npm test Only

  • Run npm test -- --email="your@email.com" --key="your_cloudflare_api_key" --domain="yourdomain.com"
4.0.0-beta.2

17 days ago

4.0.0-beta.1

1 month ago

3.0.2

1 month ago

3.0.1

4 months ago

2.0.6

1 year ago

3.0.0

1 year ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.3

3 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

5 years ago

1.5.4

6 years ago

1.5.3-readme

6 years ago

1.5.3

6 years ago

1.5.2

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.0

6 years ago

1.3.4

6 years ago

1.3.3-a

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago