Cloudflare worker for the cache service of the compatibility list of Vita3K
- npm
- node
- A GitHub access token, you can get one here
- You only need to check the public_repo checkbox for it to work, no other box is needed
-
Create a D1 database in cloudflare (dw, its free :D)
- You can name it whatever you want
-
Change the configuration (
wrangler.toml)- database_name: Here goes the name of the database
- database_id: Put here the database id you copied from the step above
-
npm installto install wrangler CLI dependency -
Once thats done, you can choose to run it either locally or on a cloudflare worker
- Even if the worker itself runs on your computer, the database doesnt
- Create a file named
.dev.varswith the following contentACCESS_TOKEN=YOURTOKENHERE- REPLACE
YOURTOKENHEREWITH THE GITHUB ACCESS TOKEN YOU GOT FROM EARLIER
- run
npx wrangler dev --test-scheduled
- run
npx wrangler deploy - It will ask you permission to use wranlger on cloudflare, click allow
- Now go to Settings > Variables > Enviroment Variables
- Click on Edit Variables and add a new secret called
ACCESS_TOKEN, and have the value be your github access token
- Click on Edit Variables and add a new secret called
- Now once you add the enviroment variable a deploy will happen, you will have an URL to the worker and test things out, list will update every minute
-
If you also want to change the passwords of the
setupandclearendpoints, add another key-value pair belowACCESS_TOKENwith keyPASSWORDand the value being the password you want to set, the endpoints have a default password of"meow"
- All endpoints are asuming the url is
vita3k-api.pedro.moe
- Returns pong
- Example:
- Command:
curl -sL vita3k-api.pedro.moe/ping
- Returns:
"Pong!"
-
Returns a list of the available lists
-
Example:
- Command:
curl -sL vita3k-api.pedro.moe/lists
- Returns
[ { "name": "commercial", // Name of the list "githubName": "Vita3K/compatibility", // Github owner/repo of the issue list "timestamp": 1697056024, // UNIX time of the last changes "labels": [ // The labels that games should be marked with "Playable", "Ingame +", "Ingame -" ... ] }, { "name": "homebrew", "githubName": "Vita3K/homebrew-compatibility", "timestamp": 1697056024 ... }, ... ]
- Note: if
timestampis0, that means the list was cleared and is scheduled to being repopulated in the next minute
- Arguments
:type= list name, same as thenameproperty in lists
- Returns the list itself, and the last update time in UNIX time
- Example:
- Command
curl -sL vita3k-api.pedro.moe/list/commercial
- Returns
{ "date": 1697056810, // The date at which this list has been last changed (UNIX Time) "list": [ { "name": "VVVVVV", "titleId": "PCSB00810", "status": "Playable", "color": "0E8A16", // hex color for the background "issueId": 1 // issue ID in the repository }, { "name": "Duke Nukem 3D: Megaton Edition", "titleId": "PCSB00437", "status": "Playable", "color": "0E8A16", "issueId": 2 }, { "name": "Downwell", "titleId": "PCSB00952", "status": "Playable", "color": "0E8A16", "issueId": 3 } ] }
- Note: if
dateis0, that means the list was cleared and is scheduled to being repopulated in the next minute
- Body (JSON)
passwordThe password for the endpoint
- Clears all the lists, for repopulation in the next cron job, also sets the lists timestamp to 0
- Example:
- Command
curl -X POST 'http://vita3k-api.pedro.moe/clear' \ --header "Content-Type: application/json" \ --data '{"password":"meow"}'
- Returns the D1 returned object with the stats of the query (changed rows, deleted rows, latency, etc)
- Body (JSON)
passwordThe password for the endpoint
- Deletes all the tables and recreates them for when the schema/inserts changes
- Example:
- Command
curl -X POST 'http://vita3k-api.pedro.moe/setup' \ --header "Content-Type: application/json" \ --data '{"password":"meow"}'
- Returns
Ok!if the DB got recreated correctly