Small Typescript code which updates Cloudflare DNS records as configured in environment variable using the public IPv4 address of the local machine.
Environment file if defined must be present There are some environment variables which need to be defined before running the script for an successful update :
-
Mandatory :
- CF_API_TOKEN = Cloudflare API token generated by the user.
- DOMAIN = The domain name along with the TLD without any leading subdomain names. Example : example.com
-
Optional :
- SUBDOMAIN = Subdomain to be appended along with the DOMAIN environment variable.
Example : if SUBDOMAIN = "eg1" along with DOMAIN = "example.com" is configured in the environment variables, then the resolved DNS name whose IPv4 will be created/updated will be eg1.example.com
- SUBDOMAIN = Subdomain to be appended along with the DOMAIN environment variable.
Preferred runtime is Bun. The project was initialized in Bun.
Only 1 library is used : Official Cloudflare Typescript SDK for Node and compatible server side JS/TS runtimes.
To install dependencies:
bun installTo run:
bun run startThis project was created using bun init in bun v1.2.4. Bun is a fast all-in-one JavaScript runtime.