First, upload some files to Cloudflare Images. For local development, clone this repository and install the dependencies:
git clone https://github.com/tycrek/eye.git && cd eye
npm i
You will also need to do this to publish the project to Cloudflare Workers.
eye uses Cloudflare Workers KV to avoid polling the Cloudflare Images API all the time. To use this, you must create a KV namespace and bind it to the worker. You can do this in the Workers dashboard.
eye expects the namespace to be called eye
. For publishing, ensure your project is also called eye
.
To get started, log into your Cloudflare account. You will need to grab two values:
ACCOUNT_ID
can be found on the right-hand side of the Images dashboard, under Developer Resources.API_KEY
must be created in the API Tokens page. Make sure you give your key read access toAccount.Cloudflare Images
.
Once you have your ACCOUNT_ID
and API_KEY
, visit your deployment in the browser at http://your.eye.domain/setup
. You will be prompted to enter these values. Once you do, eye will begin to populate the KV namespace with your images.
To run locally, run npm run dev
. This will launch the Wrangler dev server (press B
to open the browser).
To publish, run npm run publish
. This will build the project and publish it to Cloudflare Workers, under the project name eye
.
Returns the JSON info of the filename or ID provided.
Returns the image for the given image name and variant. If no variant is provided, the default public
variant is used.
The image
parameter can be either the filename or UUID of the image. File extensions are optional.
Expires the image cache manually. This is done automatically every 24 hours, but can be done manually if needed.
You may want to do this if you have updated an image and want to see the changes immediately. It is recommended to use the next route after this one.
Updates the image cache manually. This is done automatically every 24 hours, but can be done manually if needed.
You will have to expire the cache first, if it is not already expired.
This helps avoid issues with files that match these route names. Though this is unlikely, it is still possible.
- Cloudflare Workers - serverless hosting
- Hono.js - backend
- Pagery - frontend (landing & setup page)