Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions domains/anexlbk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"owner": {
"username": "anexlbk",
"email": "anaslachmi@gmail.com"
},
"records": {
"CNAME": "anexlbk.github.io"
}
}
4 changes: 2 additions & 2 deletions domains/pranjal.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"owner": {
"username": "Pranjal-SB",
"email": "psbhatnagar.in@gmal.com"
"email": "psbhatnagar.in@gmail.com"
},
"records": {
"CNAME": "pranjal-sb.github.io"
"URL": "https://psbhatnagar.in"
}
}
9 changes: 9 additions & 0 deletions domains/will.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"owner": {
"username": "wdhdev",
"email": "william@is-a.dev"
},
"records": {
"URL": "https://wharrison.com.au"
}
}
69 changes: 31 additions & 38 deletions util/raw-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,48 @@ const path = require("path");

const directoryPath = path.join(__dirname, "../domains");
const outputDir = path.join(__dirname, "../raw-api");
const domainsOutputDir = path.join(outputDir, "v2", "domains");

if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, { recursive: true });
}
if (!fs.existsSync(domainsOutputDir)) {
fs.mkdirSync(domainsOutputDir, { recursive: true });
}

const internal = require(path.join(__dirname, "internal.json"));
const reserved = require(path.join(__dirname, "reserved.json"));

const v2 = [];

function writeDomainFile(entry) {
fs.writeFileSync(
path.join(domainsOutputDir, `${entry.subdomain}.json`),
JSON.stringify(entry)
);
}

for (const subdomain of internal) {
const commonData = {
const entry = {
domain: `${subdomain}.is-a.dev`,
subdomain: subdomain,
owner: {
username: "is-a-dev"
}
};

const records = {
CNAME: "internal.is-a.dev"
};

v2.push({
...commonData,
records: records,
owner: { username: "is-a-dev" },
records: { CNAME: "internal.is-a.dev" },
internal: true
});
};
v2.push(entry);
writeDomainFile(entry);
}

for (const subdomain of reserved) {
const commonData = {
const entry = {
domain: `${subdomain}.is-a.dev`,
subdomain: subdomain,
owner: {
username: "is-a-dev"
}
};

const records = {
URL: "https://is-a.dev/reserved"
};

v2.push({
...commonData,
records: records,
owner: { username: "is-a-dev" },
records: { URL: "https://is-a.dev/reserved" },
reserved: true
});
};
v2.push(entry);
writeDomainFile(entry);
}

fs.readdir(directoryPath, function (err, files) {
Expand All @@ -67,31 +61,30 @@ fs.readdir(directoryPath, function (err, files) {
const item = JSON.parse(data);
const name = path.parse(file).name;

item.domain = name + ".is-a.dev";
item.domain = `${name}.is-a.dev`;
item.subdomain = name;

delete item.owner.email;

let itemV2 = {
const itemV2 = {
domain: item.domain,
subdomain: item.subdomain,
owner: item.owner,
records: item.records
};

if (item.redirect_config) itemV2.redirect_config = item.redirect_config;

if (item.proxied) itemV2.proxied = item.proxied;

v2.push(itemV2);
writeDomainFile(itemV2);

processedCount++;
if (processedCount === files.length) {
v2.sort((a, b) => a.domain.localeCompare(b.subdomain));

fs.writeFile("raw-api/v2.json", JSON.stringify(v2), (err) => {
if (err) throw err;
});
fs.writeFile(
path.join(outputDir, "v2.json"),
JSON.stringify(v2),
(err) => { if (err) throw err; }
);
}
});
});
Expand Down
Loading