From 8c4fef2ba961aba954fac8b0ab7b42fd670c288b Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Sat, 18 Sep 2021 13:43:58 -0700 Subject: [PATCH] Add UUID worker --- package.json | 3 ++- uuid/index.js | 3 +++ uuid/package.json | 19 +++++++++++++++++++ uuid/wrangler.toml.example | 5 +++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 uuid/index.js create mode 100644 uuid/package.json create mode 100644 uuid/wrangler.toml.example diff --git a/package.json b/package.json index 468272e..db369bd 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "cors", "pwned", "qr", - "ip" + "ip", + "uuid" ] } diff --git a/uuid/index.js b/uuid/index.js new file mode 100644 index 0000000..fa0eb51 --- /dev/null +++ b/uuid/index.js @@ -0,0 +1,3 @@ +addEventListener('fetch', event => { + event.respondWith(new Response(crypto.randomUUID())); +}) diff --git a/uuid/package.json b/uuid/package.json new file mode 100644 index 0000000..5524005 --- /dev/null +++ b/uuid/package.json @@ -0,0 +1,19 @@ +{ + "name": "uuid", + "version": "0.1.0", + "description": "Cloudflare Worker which returns a random version 4 UUID.", + "private": true, + "main": "index.js", + "scripts": { + "login": "wrangler login", + "preview": "wrangler preview", + "build": "wrangler build", + "publish": "wrangler publish" + }, + "author": "Ardis Lu", + "license": "ISC", + "repository": { + "type": "git", + "url": "https://github.com/ardislu/cloudflare-workers.git" + } +} diff --git a/uuid/wrangler.toml.example b/uuid/wrangler.toml.example new file mode 100644 index 0000000..0f5ecb7 --- /dev/null +++ b/uuid/wrangler.toml.example @@ -0,0 +1,5 @@ +name = 'uuid' +type = 'javascript' +account_id = '' +workers_dev = true +route = 'example.com/*' -- 2.47.3