mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-08 22:48:46 +00:00
revalidate config changes, check on focus changes
This commit is contained in:
parent
5f0c1ec70a
commit
c980c70798
3 changed files with 96 additions and 1 deletions
27
src/pages/api/hash.js
Normal file
27
src/pages/api/hash.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { join } from "path";
|
||||
import { createHash } from "crypto";
|
||||
import { readFileSync } from "fs";
|
||||
|
||||
import checkAndCopyConfig from "utils/config/config";
|
||||
|
||||
const configs = ["docker.yaml", "settings.yaml", "services.yaml", "bookmarks.yaml"];
|
||||
|
||||
function hash(buffer) {
|
||||
const hashSum = createHash("sha256");
|
||||
hashSum.update(buffer);
|
||||
return hashSum.digest("hex");
|
||||
}
|
||||
|
||||
export default async function handler(req, res) {
|
||||
const hashes = configs.map((config) => {
|
||||
checkAndCopyConfig(config);
|
||||
const configYaml = join(process.cwd(), "config", config);
|
||||
return hash(readFileSync(configYaml, "utf8"));
|
||||
});
|
||||
|
||||
const combinedHash = hash(hashes.join(""));
|
||||
|
||||
res.send({
|
||||
hash: combinedHash,
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue