diff --git a/package.json b/package.json index 65048ec..3e2079c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodename-core", - "version": "0.2.0", + "version": "0.3.0", "main": "lib/index.js", "types": "lib/index.d.ts", "author": "Fabian Stamm ", diff --git a/src/core.ts b/src/core.ts index ddd66c2..dfb48cf 100644 --- a/src/core.ts +++ b/src/core.ts @@ -26,7 +26,7 @@ export interface Plugin { * The lower the value, the higher priority. * It is recommended to make this value changeable over the cosntructor options field. */ - Priority: number + priority: number init(core: DnsCore): Promise } @@ -82,12 +82,12 @@ export interface StoragePlugin extends Plugin { /** * Here you can define wich record types this storage plugin is capable of. */ - RecordTypes: RecordTypes[] + record_types: RecordTypes[] /** * Disables record caching for this Storage */ - NoCache: boolean; + no_cache: boolean; /** * Returns if storage plugin is responsible for this domain. @@ -138,13 +138,13 @@ export class StorageManager { } private presort() { - this._storages = this._storages.sort((e1, e2) => e1.Priority - e2.Priority) + this._storages = this._storages.sort((e1, e2) => e1.priority - e2.priority) this._sorted = {} for (let key in RecordTypes) { let key_n = Number(key) if (key_n !== Number.NaN) { //The _storages list is sorted with priority. - this._sorted[key_n] = this._storages.filter(e => e.RecordTypes.find(t => t === key_n) !== undefined) + this._sorted[key_n] = this._storages.filter(e => e.record_types.find(t => t === key_n) !== undefined) } } } @@ -169,10 +169,10 @@ export class StorageManager { let nocache = false; for (let storage of storages) { - nocache = storage.NoCache || nocache; + nocache = storage.no_cache || nocache; records = await storage.getRecords(domain, hostname, type) if (records) { - if (storage.NoCache) this._cache.addRecords(domain, hostname, type, records, records.length <= 0 ? 3600 : records[0].ttl) + if (storage.no_cache) this._cache.addRecords(domain, hostname, type, records, records.length <= 0 ? 3600 : records[0].ttl) return records; } } @@ -197,7 +197,7 @@ export interface QuestionPlugin extends Plugin { /** * This field defines wich question types this plugin is capable of handling. */ - QuestionTypes: RecordTypes[]; + question_types: RecordTypes[]; init(core: DnsCore): Promise /** @@ -219,12 +219,12 @@ export class QuestionManager { } private sort() { - this._questions = this._questions.sort((e1, e2) => e1.Priority - e2.Priority); + this._questions = this._questions.sort((e1, e2) => e1.priority - e2.priority); this._sorted = {}; for (let key in RecordTypes) { let key_n = Number(key) if (key_n !== Number.NaN) { - this._sorted[key_n] = this._questions.filter(e => e.QuestionTypes.find(t => t === key_n) !== undefined) + this._sorted[key_n] = this._questions.filter(e => e.question_types.find(t => t === key_n) !== undefined) } } }