Skip to content

Commit

Permalink
dns records
Browse files Browse the repository at this point in the history
  • Loading branch information
Mqxx committed Mar 5, 2024
1 parent ffa2ee5 commit ee5553f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/record/dns_record.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { DNSRecordType } from './dns_record_type.ts';

export interface DNSRecord {
type : DNSRecordType,
name : string,
address : string,
proxy? : boolean,
ttl? : number,
comment? : string
}
1 change: 1 addition & 0 deletions src/record/dns_record_type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type DNSRecordType = 'A' | 'AAAA' | 'CNAME'
1 change: 0 additions & 1 deletion src/record/record_type.ts

This file was deleted.

19 changes: 18 additions & 1 deletion src/url/parse_url_parametrs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
import { URLParameters } from './url_parameters.ts';
import { DNSRecord } from '../record/dns_record.ts'

export function parseUrlParameters(parameters : URLSearchParams) : URLParameters {
const token = parameters.get('token');
const zoneId = parameters.get('zoneId');
const records = parameters.get('records');

if (!token) {
throw new Error('Missing parameter: "token"')
}
if (!zoneId) {
throw new Error('Missing parameter: "zoneId"')
}
if (!records) {
throw new Error('Missing parameter: "records"')
}

return {

token,
zoneId,
records: JSON.parse(records) as DNSRecord[]
}
}
7 changes: 2 additions & 5 deletions src/url/url_parameters.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { RecordType } from '../record/record_type.ts';
import { DNSRecord } from '../record/dns_record.ts';

export interface URLParameters {
token : string,
zoneId : string,
type : RecordType,
ipv4 : string,
ipv6 : string,

records : DNSRecord[]
}

0 comments on commit ee5553f

Please sign in to comment.