-
-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(api): add swr caching to metadata api (#801)
* chore: upgrade wrangler deps * feat: add swr caching to metadata * Create lovely-fishes-design.md * docs: update metadata api documentation * docs: update hard rate limit value * docs: fix unescaped html string * docs: minor formatting fixes * docs: update examples with actual links * refactor: throw using statuserror
- Loading branch information
Showing
23 changed files
with
1,353 additions
and
846 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"download-api": patch | ||
"api": patch | ||
--- | ||
|
||
This adds SWR caching to the metadata API with 1-hour TTLs to the original source for faster performance and more up-to-date metadata. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Fontsource API | ||
|
||
This API uses Cloudflare Workers, KV and R2 to serve the API and CDN. We also use a custom proxy provided by [jsDelivr](https://www.jsdelivr.com/) to cache all R2 requests on the edge to also reduce costs. | ||
|
||
Learn more about the API at [fontsource.org](https://fontsource.org/docs/api/introduction). | ||
|
||
### Workers | ||
|
||
- [download](./download) - An unbound worker that populates the R2 bucket with the latest fonts. | ||
- [metadata](./metadata) - The API worker that serves the KV metadata for the fonts. | ||
|
||
### Development | ||
|
||
To run the API locally, you will need to install Node 18+ and `pnpm`. | ||
|
||
```bash | ||
pnpm install | ||
``` | ||
|
||
Each directory represents a different worker that is deployed to Cloudflare. To run a worker locally, you can use the following command: | ||
|
||
```bash | ||
pnpm run dev | ||
``` | ||
|
||
As different workers are binded to each other, they may connect to the live service. Thus you will need to run `pnpm run dev` in each relevant directory to use the local workers dev registry. | ||
|
||
### Testing | ||
|
||
To run the tests, you can use the following command in each directory: | ||
|
||
```bash | ||
pnpm run test | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.