Last active
August 12, 2023 23:30
-
-
Save obfusk/fc5e7e4e129c0e4192d8fd6f7aa90f14 to your computer and use it in GitHub Desktop.
jsonata last-modified
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jsonata = require("jsonata"); | |
const axios = require("axios"); | |
const jsonPath = "$toMillis(`last-modified`, '[FNn,-3], [D] [MNn,-3] [Y] [H]:[m]:[s] GMT') > $millis() - 1000 * 60 * 60 * 24 * 7"; | |
const expectedValue = "true"; | |
let res = await axios.request({url: "https://f-droid.org/repo/index-v1.jar", method: "HEAD"}); | |
headers = res.headers; | |
let expression = jsonata(jsonPath); | |
let result = await expression.evaluate(headers); | |
if (result.toString() === expectedValue) { | |
console.log("yay!"); | |
} else { | |
throw new Error("oops"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment