Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ts-zone-file

kristianfjones67ISC3.4.5TypeScript support: included

This module is designed for manaing a BIND name server.

BIND, BIND9, BIND Zone, DNS, zone file, zone-file

readme

TS-Zone-file

This module is designed for manaing a BIND name server.

Written in typescript and compiled to pure javascript. No extrernal dependencies Full Examples can be found in the git repo.

It takes inspiration from zone-file

Usage

Parsing zonefile

Loading

import { parseZoneFile } from 'ts-zone-file';
import { readFile } from 'fs-extras'
const file = await readFile('/zones/example.com');
const zone = await parseZoneFile(file.toString())

Appending

import { parseZoneFile } from 'ts-zone-file';
import { readFile, writeFile } from 'fs-extras'
const file = await readFile('/zones/example.com');
const zone = await parseZoneFile(zoneFileString.toString())
zone.a.push({ host: 'www', value: '1.1.1.1' })
const zoneString = await generateZoneFile(zone)
await writeFile('./example.com', zoneString)

Creating Zonefile Text

import { generateZoneFile } from 'ts-zone-file';
import { writeFile } from 'fs-extras'
const string = await generateZoneFile(zone);
await writeFile('/zones/example.com', string)

Parse named.conf

import { parseBINDConfig } from 'ts-zone-file';
import { readFile } from 'fs-extras'
const file = await readFile('/named.conf');
const zone = await parseBINDConfig(file.toString())

Generate named.conf

import { generateConfig } from 'ts-zone-file';
import { writeFile } from 'fs-extras'
const string = await generateConfig(SAMPLE2OBJ)
await writeFile('/named.conf', string)