Make project defaults reusable

This commit is contained in:
Your Name
2026-08-03 15:50:45 +05:00
parent 2358e9d660
commit 6ae61b0302
11 changed files with 116 additions and 29 deletions
+6 -2
View File
@@ -1,8 +1,12 @@
import {createHmac} from "node:crypto";
import {readFileSync} from "node:fs";
const baseUrl = "https://f-n8.ru";
const [keyId, secret] = readFileSync("/root/ghost-admin-api-key", "utf8").trim().split(":");
const baseUrl = (process.env.GHOST_URL || "").replace(/\/$/, "");
const keyFile = process.env.GHOST_ADMIN_KEY_FILE || "";
if (!baseUrl || !keyFile) {
throw new Error("GHOST_URL and GHOST_ADMIN_KEY_FILE are required");
}
const [keyId, secret] = readFileSync(keyFile, "utf8").trim().split(":");
const encode = (value) => Buffer.from(JSON.stringify(value)).toString("base64url");
const now = Math.floor(Date.now() / 1000);
const unsigned = `${encode({alg: "HS256", typ: "JWT", kid: keyId})}.${encode({iat: now, exp: now + 300, aud: "/admin/"})}`;