/cf-worker

Multi-purpose Cloudflare Worker

Primary LanguageTypeScriptMIT LicenseMIT

cf-worker

Multi-purpose Cloudflare Worker


Github: github.com/whinee/cf-worker

REST API: w.wya.workers.dev

Important

This project is a work in progress, use at your own risk.

This is literally broken!

Usage

TODO

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • git

    To check that you have git installed, in your preferred terminal, run the following command:
    git --version

    If it doesn't throw an error, then you're good to go!

  • npm

    To check that you have npm installed, in your preferred terminal, run the following command:
    npm version

    If it doesn't throw an error, then you're good to go!

Setup

  • Sign up for Cloudflare Workers account.

  • In your preferred terminal, run the following command:

    git clone https://github.com/whinee/cf-worker.git
    cd kv
    npm i -g @cloudflare/wrangler
    echo y | wrangler login

    This will open a browser window.

  • Focus on the browser by hovering the cursor over the said window and clicking on it. A prompt like the following should appear:

    Read all the terms and agree to it by clicking the blue "Allow" button.

    Upon agreeing, after waiting for a moment, the following should appear:

  • Go at Cloudflare Workers Dashboard, and click the dropdown button next to the "Workers" button in the sidebar as shown below:

    It should reveal three more items as show below:

    Click "KV". You should be greeted by the following:

    Click the "Create namespace" button. A popup should greet you as shown below:

    Input the name of the namespace in the "namespace name" field. For this tutorial, we will use the name "test". Click "add". Now, you should see that the namespace "test" is now listed on the table as shown on the following image:

    Hover on the id of the said namespace and you should see a copy icon like shown below:

    Click the icon.

  • Go back to your terminal and run the following command:

    wrangler secret put USER
    wrangler secret put PASS

    For the first prompt, enter the user for the kv. For the second one, the password of the user.

  • Open your text editor of choice and open wrangler.toml, and edit the following lines:

    kv_namespaces = [
    { binding = "KV", id = "dc63071e609747e6b9ad86969bb76ed3", preview_id = "dc63071e609747e6b9ad86969bb76ed3" }
    ]
    

    Change the id to the one you copied earlier. Save the file. Now, you're done!

    You could run the following command to serve the project locally:

    wrangler dev

    Or run the following command to publish it to your own subdomain:

    wrangler publish

License

Copyright for portions of project cf-worker are held by [Github Account ashley williams Owner, 2018] as part of project worker-template and [Github Account HaxSam Owner, 2022] as part of project kv-storage-api.

All other copyright for project cf-worker are held by [Github Account whinee Owner, 2022].

Check the LICENSE for more details.

Credits

MIT Logo

Massachusetts Institute of Technology (vectorized by Mysid, modified by whinee), Public domain, via Wikimedia Commons

Icons

Exclamation Mark, Code Fork, Star, Group, Code, and Discord icons by Icons8

NOTE: If a reference or source material is not attributed properly or not at all, please kindly message me at Discord: whi_ne#5135 or create a pull request so I can properly give credit to their respective authors.