https://github.com/acearchive/api-worker
A serverless function which handles API requests for Ace Archive
https://github.com/acearchive/api-worker
cloudflare-workers rest-api serverless
Last synced: about 1 year ago
JSON representation
A serverless function which handles API requests for Ace Archive
- Host: GitHub
- URL: https://github.com/acearchive/api-worker
- Owner: acearchive
- License: mit
- Created: 2022-10-04T06:46:17.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-02-27T07:37:35.000Z (about 1 year ago)
- Last Synced: 2025-02-27T10:27:47.589Z (about 1 year ago)
- Topics: cloudflare-workers, rest-api, serverless
- Language: TypeScript
- Homepage:
- Size: 510 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# api-worker
This repo is a [Cloudflare Worker](https://developers.cloudflare.com/workers/)
that serves the Ace Archive API using data from the [Cloudflare
D1](https://developers.cloudflare.com/d1) SQLite database.
See [the website](https://acearchive.lgbt/docs/contributing/api/) for more
information.
## Pagination cursor encryption
Pagination cursors are encrypted, for a few reasons:
1. We can trivially detect an invalid cursor argument without any complex logic
or querying the upstream data source.
2. The contents of the cursor are opaque to the user, which prevents them from
trying to interpret or parse it.
3. The cursor we return is always different for every request. This prevents the
user from relying on the contents of the cursor being deterministic.
The encryption key is stored in a worker secret called `CURSOR_ENCRYPTION_KEY`.
You can generate a key in the browser JS console like this:
```javascript
const key = await crypto.subtle.generateKey({ name: "AES-GCM", length: 128 }, true, ["encrypt", "decrypt"])
const jwk = JSON.stringify(await crypto.subtle.exportKey("jwk", key));
console.log(jwk);
```