Commit 865bdd43 authored by Matthew Gall's avatar Matthew Gall

Added base files for automatic deployment

parent d49ff2b1
NAME := worker-mirrors
.PHONY: deploy
deploy:
curl -X PUT "https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ORG_ID}/workers/scripts/${NAME}" -H "X-Auth-Email:${CLOUDFLARE_EMAIL}" -H "X-Auth-Key:${CLOUDFLARE_KEY}" -F '[email protected];type=application/javascript' -F 'metadata={"body_part": "script", "bindings": [{"name": "mirrors", "type": "kv_namespace", "namespace_id": "${CLOUDFLARE_KV_NAMESPACEID}"}]};type=application/json'
.PHONY: deploy-mirrors
deploy-mirrors:
curl "https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ORG_ID}/storage/kv/namespaces/${CLOUDFLARE_KV_NAMESPACEID}/values/mirrors" -X PUT -H "X-Auth-Email:${CLOUDFLARE_EMAIL}" -H "X-Auth-Key:${CLOUDFLARE_KEY}" --data @mirrors.json
\ No newline at end of file
{
"piwheels": {
"endpoint": "https://piwheels.com",
"user-agent": "mirrors.wales/mirrorbot (piwheels)"
}
}
\ No newline at end of file
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
function isInArray(value, array) {
return array.indexOf(value) > -1;
}
/**
* Fetch and log a request
* @param {Request} request
*/
async function handleRequest(request) {
path = new URL(request.url).pathname;
return new Response('Welcome to mirror.wales', {
headers: {
'Content-Type': 'text/plain'
}
})
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment