Skip to content

Commit

Permalink
uuhhh... conflicts!
Browse files Browse the repository at this point in the history
  • Loading branch information
Niceygy committed Jun 13, 2024
2 parents a96a452 + f2645a0 commit 36c8803
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# WorkerDownloadRecorder
## A simple cloudflare worker, that records download numbers & page views.
### Install:
- Clone repo
- Install dependencies
- Run `wrangler deploy`
- Attach a two KVs to this worker, `WDR` & `WVR` for download records & page views respectively.
- Download the worker.js
- Create a [new worker.](https://developers.cloudflare.com/workers/get-started/guide/#get-started-in-the-dashboard)
- Select "Edit in browser" or "edit".
- Paste the code from worker.js into the edit box, and deploy
- Attach a two KVs to this worker, `WDR` & `WVR` for download records & page views respectively. (These can be found under the variables tab)
- Add a variable named `url` with a discord webhook.

### Usage (Downloads):
- Change your download links to `https://Your.Worker.workers.dev/reder?url=`GH_Username/Repo?file=Release_Number/File_Name.ext<br>
- Change your download links to `https://Your.Worker.workers.dev/reder?url=GH_Username/Repo?file=Release_Number/File_Name.ext` <br>
- Change GH_Username, Repo, Release_Number & File_Name.ext <br>
E.G: download.niceygy.worker.dev/reder?url=niceygylive/niceygylive.xyz?file=1.2.1/setup.exe
- It will record the download, then redirect the user to github.com/GH_Username/Repo/releases/Release_Number/File_Name.ext
(E.G: `download.niceygy.worker.dev/reder?url=niceygylive/niceygylive.xyz?file=1.2.1/setup.exe`)
- It will record the download, then redirect the user to `github.com/GH_Username/Repo/releases/Release_Number/File_Name.ext`

### Usage (Page Views):
- Add `<link href="https://Your.Worker.workers.dev?page=/path/to/page" rel="prerender" />` to any of your pages. This will send a single request to the worker on page load, which then records it.
Expand All @@ -19,4 +21,4 @@ E.G: `https://Your.Worker.workers.dev?page=/downloads/download-recorder`

### Usage (Discord webhook):
- Add a env variable `url` with your discord webhook url.
- Add a cron trigger to the worker, to send the stats to the webhook.
- Add a cron trigger to the worker, to send the stats to the webhook.
15 changes: 15 additions & 0 deletions src/worker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 36c8803

Please sign in to comment.