Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const os = require("os");
|
||||
|
||||
const tomlPath = path.join(os.homedir(), "AppData", "Roaming", "xdg.config", ".wrangler", "config", "default.toml");
|
||||
const toml = fs.readFileSync(tomlPath, "utf8");
|
||||
const match = toml.match(/oauth_token\s*=\s*"([^"]+)"/);
|
||||
if (!match) {
|
||||
console.error("no token found");
|
||||
process.exit(1);
|
||||
}
|
||||
const token = match[1];
|
||||
const accountId = "6a638c3c2047a3ce064af7e4febb0ead";
|
||||
const project = "personalweb";
|
||||
const domain = "www.zhouhaoze.com";
|
||||
|
||||
fetch(`https://api.cloudflare.com/client/v4/accounts/${accountId}/pages/projects/${project}/domains`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ name: domain }),
|
||||
})
|
||||
.then((r) => r.json())
|
||||
.then((j) => {
|
||||
console.log(JSON.stringify(j, null, 2));
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -1,30 +0,0 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const os = require("os");
|
||||
|
||||
const tomlPath = path.join(os.homedir(), "AppData", "Roaming", "xdg.config", ".wrangler", "config", "default.toml");
|
||||
const toml = fs.readFileSync(tomlPath, "utf8");
|
||||
const match = toml.match(/oauth_token\s*=\s*"([^"]+)"/);
|
||||
const token = match[1];
|
||||
const zoneId = "5ed3652548a0e8c430910c4090b02357";
|
||||
|
||||
fetch(`https://api.cloudflare.com/client/v4/zones/${zoneId}/dns_records`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
type: "CNAME",
|
||||
name: "www",
|
||||
content: "personalweb-bkl.pages.dev",
|
||||
proxied: true,
|
||||
ttl: 1,
|
||||
}),
|
||||
})
|
||||
.then((r) => r.json())
|
||||
.then((j) => console.log(JSON.stringify(j, null, 2)))
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
});
|
||||
+2
-1
@@ -2,7 +2,8 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<link rel="icon" type="image/png" href="/favicon.png" />
|
||||
<link rel="apple-touch-icon" href="/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="color-scheme" content="light dark" />
|
||||
<title>Haoze Zhou</title>
|
||||
|
||||
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 9.3 KiB |
Reference in New Issue
Block a user