mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-10-17 10:14:32 +00:00
Fixes TTL for domains + more constants
This commit is contained in:
1 parent
b3059611c0
commit
e3f11eea43
4 files changed
+27
-20
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
const R = require('ramda');
|
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 { domainService: domain } = require('../utils/domain-service');
|
||||||
const { getDomains } = require('../utils/domain');
|
const { getDomains } = require('../utils/domain');
|
||||||
|
|
||||||
@@ -13,6 +13,7 @@ const toHostList = R.chain(data => {
|
|||||||
HostName: data.name,
|
HostName: data.name,
|
||||||
RecordType: recordType,
|
RecordType: recordType,
|
||||||
Address: url,
|
Address: url,
|
||||||
|
TTL,
|
||||||
}))
|
}))
|
||||||
, rs);
|
, 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 = {
|
module.exports = {
|
||||||
VALID_RECORD_TYPES: ['CNAME', 'A', 'ALIAS', 'URL'],
|
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 R = require('ramda');
|
||||||
const Namecheap = require('@rqt/namecheap');
|
const Namecheap = require('@rqt/namecheap');
|
||||||
|
const { NC_DOMAIN, NC_USER, NC_API_KEY, ENV, IP_ADDRESS } = require('../utils/constants');
|
||||||
|
|
||||||
const path = require('path');
|
const IS_SANDBOX = ENV === 'sandbox';
|
||||||
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 getDomainService = ({ Namecheap }) => {
|
const getDomainService = ({ Namecheap }) => {
|
||||||
const nc = new Namecheap({
|
const nc = new Namecheap({
|
||||||
user: NC_USER,
|
user: NC_USER,
|
||||||
key: NC_API_KEY,
|
key: NC_API_KEY,
|
||||||
ip: '103.226.85.9',
|
ip: IP_ADDRESS,
|
||||||
sandbox: IS_SANDBOX,
|
sandbox: IS_SANDBOX,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+11
-11
@@ -1,5 +1,5 @@
|
|||||||
const { toHostList } = require('../scripts/register-domains');
|
const { toHostList } = require('../scripts/register-domains');
|
||||||
const { NC_DOMAIN } = require('../utils/constants');
|
const { NC_DOMAIN, TTL } = require('../utils/constants');
|
||||||
|
|
||||||
describe('toHostList', () => {
|
describe('toHostList', () => {
|
||||||
it('should flatten domain data to list of hosts (without https)', () => {
|
it('should flatten domain data to list of hosts (without https)', () => {
|
||||||
@@ -10,11 +10,11 @@ describe('toHostList', () => {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
expect(res).toEqual([
|
expect(res).toEqual([
|
||||||
{ HostName: 'akshay', RecordType: 'CNAME', Address: 'phenax.github.io' },
|
{ HostName: 'akshay', RecordType: 'CNAME', Address: 'phenax.github.io', TTL },
|
||||||
{ HostName: 'foobar', RecordType: 'CNAME', Address: 'v.io' },
|
{ HostName: 'foobar', RecordType: 'CNAME', Address: 'v.io', TTL },
|
||||||
{ HostName: 'xx', RecordType: 'A', Address: '1.2.3.4' },
|
{ HostName: 'xx', RecordType: 'A', Address: '1.2.3.4', TTL },
|
||||||
{ HostName: 'xx', RecordType: 'A', Address: '5.6.3.2' },
|
{ HostName: 'xx', RecordType: 'A', Address: '5.6.3.2', TTL },
|
||||||
{ HostName: 'xx', RecordType: 'A', Address: '1.2.31.1' }
|
{ HostName: 'xx', RecordType: 'A', Address: '1.2.31.1', TTL },
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -26,12 +26,12 @@ describe('toHostList', () => {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
expect(res).toEqual([
|
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: 'akshay', RecordType: 'URL', Address: `https://akshay.${NC_DOMAIN}` },
|
||||||
{ HostName: 'foobar', RecordType: 'CNAME', Address: 'v.io' },
|
{ HostName: 'foobar', RecordType: 'CNAME', Address: 'v.io', TTL },
|
||||||
{ HostName: 'xx', RecordType: 'A', Address: '1.2.3.4' },
|
{ HostName: 'xx', RecordType: 'A', Address: '1.2.3.4', TTL },
|
||||||
{ HostName: 'xx', RecordType: 'A', Address: '5.6.3.2' },
|
{ HostName: 'xx', RecordType: 'A', Address: '5.6.3.2', TTL },
|
||||||
{ HostName: 'xx', RecordType: 'A', Address: '1.2.31.1' },
|
{ HostName: 'xx', RecordType: 'A', Address: '1.2.31.1', TTL },
|
||||||
{ HostName: 'xx', RecordType: 'URL', Address: `https://xx.${NC_DOMAIN}` },
|
{ HostName: 'xx', RecordType: 'URL', Address: `https://xx.${NC_DOMAIN}` },
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user