mirror of
https://github.com/Nezumi-2711/cloudflare-gateway-pihole-scripts.git
synced 2026-09-22 13:38:37 +00:00
removed hardcoded strings and added constants
This commit is contained in:
@@ -19,3 +19,15 @@ export const API_HOST = "https://api.cloudflare.com/client/v4";
|
||||
export const DRY_RUN = !!parseInt(process.env.DRY_RUN, 10);
|
||||
|
||||
export const FAST_MODE = !!parseInt(process.env.FAST_MODE, 10);
|
||||
|
||||
export const PROCESSING_FILENAME = {
|
||||
ALLOWLIST: "allowlist.txt",
|
||||
BLOCKLIST: "blocklist.txt",
|
||||
OLD_ALLOWLIST: "whitelist.csv",
|
||||
OLD_BLOCKLIST: "input.csv",
|
||||
};
|
||||
|
||||
export const LIST_TYPE = {
|
||||
ALLOWLIST: "allowlist",
|
||||
BLOCKLIST: "blocklist",
|
||||
};
|
||||
|
||||
+8
-3
@@ -1,9 +1,14 @@
|
||||
import { ACCOUNT_EMAIL, ACCOUNT_ID, API_HOST, API_TOKEN } from "./constants.js";
|
||||
|
||||
if (!globalThis.fetch) {
|
||||
console.warn("\nIMPORTANT: Your Node.js version doesn't have native fetch support and may not be supported in the future. Please update to v18 or later.\n")
|
||||
console.warn(
|
||||
"\nIMPORTANT: Your Node.js version doesn't have native fetch support and may not be supported in the future. Please update to v18 or later.\n"
|
||||
);
|
||||
// Advise what to do if running in GitHub Actions
|
||||
if (process.env.GITHUB_WORKSPACE) console.warn("Since you're running in GitHub Actions, you should update your Actions workflow configuration to use Node v18 or higher.")
|
||||
if (process.env.GITHUB_WORKSPACE)
|
||||
console.warn(
|
||||
"Since you're running in GitHub Actions, you should update your Actions workflow configuration to use Node v18 or higher."
|
||||
);
|
||||
// Import node-fetch since there's no native fetch in this environment
|
||||
globalThis.fetch = (await import("node-fetch")).default;
|
||||
}
|
||||
@@ -48,7 +53,7 @@ export const requestGateway = (path, options) =>
|
||||
/**
|
||||
* Normalizes a domain.
|
||||
* @param {string} value The value to be normalized.
|
||||
* @param {boolean} isAllowlisting Whether the value is to be whitelisted.
|
||||
* @param {boolean} isAllowlisting Whether the value is to be allowlisted.
|
||||
* @returns {string}
|
||||
*/
|
||||
export const normalizeDomain = (value, isAllowlisting) => {
|
||||
|
||||
Reference in New Issue
Block a user