mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-05-26 20:00:15 +00:00
Fixes TTL for domains + more constants
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const R = require('ramda');
|
||||
const { VALID_RECORD_TYPES, NC_DOMAIN } = require('../utils/constants');
|
||||
const { VALID_RECORD_TYPES, NC_DOMAIN, TTL } = require('../utils/constants');
|
||||
const { domainService: domain } = require('../utils/domain-service');
|
||||
const { getDomains } = require('../utils/domain');
|
||||
|
||||
@@ -13,6 +13,7 @@ const toHostList = R.chain(data => {
|
||||
HostName: data.name,
|
||||
RecordType: recordType,
|
||||
Address: url,
|
||||
TTL,
|
||||
}))
|
||||
, rs);
|
||||
|
||||
|
||||
+11
-1
@@ -1,4 +1,14 @@
|
||||
const path = require('path');
|
||||
require('dotenv').config({ path: path.resolve('.env.sandbox') });
|
||||
|
||||
const { NC_USER, NC_API_KEY, NC_DOMAIN } = process.env;
|
||||
|
||||
module.exports = {
|
||||
VALID_RECORD_TYPES: ['CNAME', 'A', 'ALIAS', 'URL'],
|
||||
NC_DOMAIN: 'booboo.xyz',
|
||||
NC_DOMAIN: NC_DOMAIN || 'booboo.xyz',
|
||||
NC_USER: NC_USER || 'test',
|
||||
NC_API_KEY: NC_API_KEY || 'fake_key',
|
||||
ENV: 'sandbox',
|
||||
TTL: 5*60,
|
||||
IP_ADDRESS: '100.100.100.100',
|
||||
};
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
const R = require('ramda');
|
||||
const Namecheap = require('@rqt/namecheap');
|
||||
const { NC_DOMAIN, NC_USER, NC_API_KEY, ENV, IP_ADDRESS } = require('../utils/constants');
|
||||
|
||||
const path = require('path');
|
||||
require('dotenv').config({ path: path.resolve('.env.sandbox') });
|
||||
|
||||
const IS_SANDBOX = true;
|
||||
const { NC_USER, NC_API_KEY, NC_DOMAIN } = process.env;
|
||||
const TTL = 5*60;
|
||||
const IS_SANDBOX = ENV === 'sandbox';
|
||||
|
||||
const getDomainService = ({ Namecheap }) => {
|
||||
const nc = new Namecheap({
|
||||
user: NC_USER,
|
||||
key: NC_API_KEY,
|
||||
ip: '103.226.85.9',
|
||||
ip: IP_ADDRESS,
|
||||
sandbox: IS_SANDBOX,
|
||||
});
|
||||
|
||||
|
||||
+11
-11
@@ -1,5 +1,5 @@
|
||||
const { toHostList } = require('../scripts/register-domains');
|
||||
const { NC_DOMAIN } = require('../utils/constants');
|
||||
const { NC_DOMAIN, TTL } = require('../utils/constants');
|
||||
|
||||
describe('toHostList', () => {
|
||||
it('should flatten domain data to list of hosts (without https)', () => {
|
||||
@@ -10,11 +10,11 @@ describe('toHostList', () => {
|
||||
]);
|
||||
|
||||
expect(res).toEqual([
|
||||
{ HostName: 'akshay', RecordType: 'CNAME', Address: 'phenax.github.io' },
|
||||
{ HostName: 'foobar', RecordType: 'CNAME', Address: 'v.io' },
|
||||
{ HostName: 'xx', RecordType: 'A', Address: '1.2.3.4' },
|
||||
{ HostName: 'xx', RecordType: 'A', Address: '5.6.3.2' },
|
||||
{ HostName: 'xx', RecordType: 'A', Address: '1.2.31.1' }
|
||||
{ HostName: 'akshay', RecordType: 'CNAME', Address: 'phenax.github.io', TTL },
|
||||
{ HostName: 'foobar', RecordType: 'CNAME', Address: 'v.io', TTL },
|
||||
{ HostName: 'xx', RecordType: 'A', Address: '1.2.3.4', TTL },
|
||||
{ HostName: 'xx', RecordType: 'A', Address: '5.6.3.2', TTL },
|
||||
{ HostName: 'xx', RecordType: 'A', Address: '1.2.31.1', TTL },
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -26,12 +26,12 @@ describe('toHostList', () => {
|
||||
]);
|
||||
|
||||
expect(res).toEqual([
|
||||
{ HostName: 'akshay', RecordType: 'CNAME', Address: 'phenax.github.io' },
|
||||
{ HostName: 'akshay', RecordType: 'CNAME', Address: 'phenax.github.io', TTL },
|
||||
{ HostName: 'akshay', RecordType: 'URL', Address: `https://akshay.${NC_DOMAIN}` },
|
||||
{ HostName: 'foobar', RecordType: 'CNAME', Address: 'v.io' },
|
||||
{ HostName: 'xx', RecordType: 'A', Address: '1.2.3.4' },
|
||||
{ HostName: 'xx', RecordType: 'A', Address: '5.6.3.2' },
|
||||
{ HostName: 'xx', RecordType: 'A', Address: '1.2.31.1' },
|
||||
{ HostName: 'foobar', RecordType: 'CNAME', Address: 'v.io', TTL },
|
||||
{ HostName: 'xx', RecordType: 'A', Address: '1.2.3.4', TTL },
|
||||
{ HostName: 'xx', RecordType: 'A', Address: '5.6.3.2', TTL },
|
||||
{ HostName: 'xx', RecordType: 'A', Address: '1.2.31.1', TTL },
|
||||
{ HostName: 'xx', RecordType: 'URL', Address: `https://xx.${NC_DOMAIN}` },
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user