An open API service indexing awesome lists of open source software.

https://github.com/acearchive/files-worker

A serverless function which hosts artifact files for Ace Archive
https://github.com/acearchive/files-worker

cloudflare-workers serverless

Last synced: about 1 year ago
JSON representation

A serverless function which hosts artifact files for Ace Archive

Awesome Lists containing this project

README

          

# files-worker

This repo is a [Cloudflare Worker](https://developers.cloudflare.com/workers/)
that serves artifact files hosted on Ace Archive from [Cloudflare
R2](https://developers.cloudflare.com/r2).

Artifact metadata is stored in a [Cloudflare
D1](https://developers.cloudflare.com/d1) SQLite database. This worker handles
incoming `GET` and `HEAD` requests to `https://files.acearchive.lgbt`, reads the
metadata for the artifact from the database, and then serves the file contents
from R2.

This worker handles requests of the form:

```
https://files.acearchive.lgbt/artifacts//
```

The artifact metadata in the database is populated by
[acearchive/artifact-submit-action](https://github.com/acearchive/artifact-submit-action).
Requesting this metadata in this worker is necessary because objects in R2 are
keyed by their hash (more specifically a
[multihash](https://multiformats.io/multihash/)), so we need to get the hash of
the file first.

HTTP range requests and conditional requests are supported, and `ETag` and
`Last-Modified` headers are returned for caching.

R2 [bucket locks](https://developers.cloudflare.com/r2/buckets/bucket-locks/)
are used to ensure that files written to R2 cannot be overwritten or deleted.
However, the Cloudflare [Terraform
provider](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs)
does not seem to support this API as of time of writing, so this step was taken
manually.