Correct minor typos, missing await

This commit is contained in:
Gabriel Simmer 2024-08-20 11:26:33 +01:00
parent 51c346bc4b
commit 91160fcb46
Signed by: arch
SSH key fingerprint: SHA256:m3OEcdtrnBpMX+2BDGh/byv3hrCekCLzDYMdvGEKPPQ

View file

@ -127,7 +127,7 @@ async function newSnapshot(request, env, ctx) {
} = Object.fromEntries(body) } = Object.fromEntries(body)
// Don't bother uploading to R2 if the hashes match. // Don't bother uploading to R2 if the hashes match.
let latest = kv.get(`${SNAPSHOT_PREFIX}LATEST`); let latest = await kv.get(`${SNAPSHOT_PREFIX}LATEST`);
if (latest != hash) { if (latest != hash) {
await bucket.put(`${hash}.png`, file); await bucket.put(`${hash}.png`, file);
let webhooks = kv.list(WEBHOOK_KEYS); let webhooks = kv.list(WEBHOOK_KEYS);
@ -145,7 +145,7 @@ async function newSnapshot(request, env, ctx) {
})); }));
} }
await kv.put("${SNAPSHOT_PREFIX}LATEST", hash, { await kv.put(`${SNAPSHOT_PREFIX}LATEST`, hash, {
metadata: { date: date } metadata: { date: date }
}); });
// Keep for 1 year. // Keep for 1 year.
@ -181,7 +181,6 @@ ROUTER
.get("/latest.json", withCache, snapshot) .get("/latest.json", withCache, snapshot)
.get("/list.json", withCache, snapshotList) .get("/list.json", withCache, snapshotList)
.post("/new", withAuth, newSnapshot) .post("/new", withAuth, newSnapshot)
.get("/favicon.ico", favicon)
// .get("/migrate", withAuth, migrateKeys) // .get("/migrate", withAuth, migrateKeys)
.get("*", withCache, specificSnapshot) .get("*", withCache, specificSnapshot)
@ -192,7 +191,7 @@ export default {
.then(json) .then(json)
.catch(error), .catch(error),
async queue(batch, env) { async queue(batch, env) {
const { versionId, versionTag, versionTimestamp } = env.CF_VERSION_METADATA; const { tag } = env.CF_VERSION_METADATA;
for (const msg of batch.messages) { for (const msg of batch.messages) {
let content = msg.body; let content = msg.body;
@ -218,7 +217,7 @@ export default {
body: JSON.stringify(payload), body: JSON.stringify(payload),
headers: { headers: {
"X-Source": "Cloudflare-Workers", "X-Source": "Cloudflare-Workers",
"User-Agent": `DAILY-SERVO ${versionId}`, "User-Agent": `DAILY-SERVO ${tag}`,
"Content-Type": content_type, "Content-Type": content_type,
...(content.auth != "" && { "Authorization": env[content.auth] }) ...(content.auth != "" && { "Authorization": env[content.auth] })
}, },