Skip to content

Commit 471808a

Browse files
committed
Add docs site
1 parent d458b0e commit 471808a

File tree

11 files changed

+2713
-2
lines changed

11 files changed

+2713
-2
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
"@std/path": "jsr:@std/path@^1.1.2",
1515
"zod": "npm:zod@^4.1.4"
1616
},
17-
"exclude": ["npm"]
17+
"exclude": ["npm", "docs"]
1818
}

docs/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
.vitepress/cache/
3+
.vitepress/dist/

docs/.vitepress/config.mts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { defineConfig } from "vitepress";
2+
3+
export default defineConfig({
4+
title: "Foundatio FetchClient",
5+
description:
6+
"A tiny, typed wrapper around fetch with caching, middleware, rate limiting, and great DX.",
7+
base: "/",
8+
ignoreDeadLinks: true,
9+
head: [
10+
["link", {
11+
rel: "icon",
12+
href:
13+
"https://raw.githubusercontent.com/FoundatioFx/Foundatio/main/media/foundatio-icon.png",
14+
type: "image/png",
15+
}],
16+
["meta", { name: "theme-color", content: "#3c8772" }],
17+
],
18+
themeConfig: {
19+
logo: {
20+
light:
21+
"https://raw.githubusercontent.com/FoundatioFx/Foundatio/master/media/foundatio.svg",
22+
dark:
23+
"https://raw.githubusercontent.com/FoundatioFx/Foundatio/master/media/foundatio-dark-bg.svg",
24+
},
25+
siteTitle: "FetchClient",
26+
nav: [
27+
{ text: "Guide", link: "/guide/what-is-fetchclient" },
28+
{ text: "GitHub", link: "https://github.com/FoundatioFx/FetchClient" },
29+
],
30+
sidebar: {
31+
"/guide/": [
32+
{
33+
text: "Introduction",
34+
items: [
35+
{
36+
text: "What is FetchClient?",
37+
link: "/guide/what-is-fetchclient",
38+
},
39+
{ text: "Getting Started", link: "/guide/getting-started" },
40+
{ text: "Features", link: "/guide/features" },
41+
],
42+
},
43+
],
44+
},
45+
socialLinks: [
46+
{ icon: "github", link: "https://github.com/FoundatioFx/FetchClient" },
47+
{ icon: "discord", link: "https://discord.gg/6HxgFCx" },
48+
],
49+
footer: {
50+
message: "Released under the MIT License.",
51+
copyright: "Copyright © 2025 Foundatio",
52+
},
53+
editLink: {
54+
pattern:
55+
"https://github.com/FoundatioFx/FetchClient/edit/main/docs/:path",
56+
},
57+
search: {
58+
provider: "local",
59+
},
60+
},
61+
markdown: {
62+
lineNumbers: false,
63+
},
64+
});

docs/.vitepress/config.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { defineConfig } from "vitepress";
2+
3+
export default defineConfig({
4+
title: "Foundatio FetchClient",
5+
description:
6+
"A tiny, typed wrapper around fetch with caching, middleware, rate limiting, and great DX.",
7+
base: "/",
8+
ignoreDeadLinks: true,
9+
head: [
10+
["link", {
11+
rel: "icon",
12+
href:
13+
"https://raw.githubusercontent.com/FoundatioFx/Foundatio/main/media/foundatio-icon.png",
14+
type: "image/png",
15+
}],
16+
["meta", { name: "theme-color", content: "#3c8772" }],
17+
],
18+
themeConfig: {
19+
logo: {
20+
light:
21+
"https://raw.githubusercontent.com/FoundatioFx/Foundatio/master/media/foundatio.svg",
22+
dark:
23+
"https://raw.githubusercontent.com/FoundatioFx/Foundatio/master/media/foundatio-dark-bg.svg",
24+
},
25+
siteTitle: "FetchClient",
26+
nav: [
27+
{ text: "Guide", link: "/guide/what-is-fetchclient" },
28+
{ text: "GitHub", link: "https://github.com/FoundatioFx/FetchClient" },
29+
],
30+
sidebar: {
31+
"/guide/": [
32+
{
33+
text: "Introduction",
34+
items: [
35+
{
36+
text: "What is FetchClient?",
37+
link: "/guide/what-is-fetchclient",
38+
},
39+
{ text: "Getting Started", link: "/guide/getting-started" },
40+
{ text: "Features", link: "/guide/features" },
41+
],
42+
},
43+
],
44+
},
45+
socialLinks: [
46+
{ icon: "github", link: "https://github.com/FoundatioFx/FetchClient" },
47+
{ icon: "discord", link: "https://discord.gg/6HxgFCx" },
48+
],
49+
footer: {
50+
message: "Released under the MIT License.",
51+
copyright: "Copyright © 2025 Foundatio",
52+
},
53+
editLink: {
54+
pattern:
55+
"https://github.com/FoundatioFx/FetchClient/edit/main/docs/:path",
56+
},
57+
search: {
58+
provider: "local",
59+
},
60+
},
61+
markdown: {
62+
lineNumbers: false,
63+
},
64+
});

docs/guide/features.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Features
2+
3+
- Typed responses for JSON APIs
4+
- Functional helpers and class-based client
5+
- Caching with TTL and invalidation
6+
- Middleware pipeline
7+
- Rate limiting per domain
8+
- Timeouts and AbortSignal support
9+
- Problem Details error handling
10+
- Auth helpers (Bearer token)
11+
- Base URL and loading state
12+
13+
See the README for richer examples.

docs/guide/getting-started.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Getting Started
2+
3+
## Install
4+
5+
```bash
6+
npm install @foundatiofx/fetchclient
7+
```
8+
9+
## Quick Usage
10+
11+
### Typed Response
12+
13+
```ts
14+
import { FetchClient } from "@foundatiofx/fetchclient";
15+
16+
type Products = { products: Array<{ id: number; name: string }> };
17+
18+
const client = new FetchClient();
19+
const response = await client.getJSON<Products>(
20+
`https://dummyjson.com/products/search?q=iphone&limit=10`,
21+
);
22+
23+
const products = response.data;
24+
```
25+
26+
### Functional API
27+
28+
```ts
29+
import { getJSON, postJSON } from "@foundatiofx/fetchclient";
30+
31+
type Product = { id: number; title: string };
32+
33+
const { data: created } = await postJSON<Product>(
34+
"https://dummyjson.com/products/add",
35+
{ name: "iPhone 13" },
36+
);
37+
38+
const { data: product } = await getJSON<Product>(
39+
`https://dummyjson.com/products/${created!.id}`,
40+
);
41+
```
42+
43+
### Middleware
44+
45+
```ts
46+
import { FetchClient, useMiddleware } from "@foundatiofx/fetchclient";
47+
48+
useMiddleware(async (ctx, next) => {
49+
console.log("starting request");
50+
await next();
51+
console.log("completed request");
52+
});
53+
54+
const client = new FetchClient();
55+
await client.getJSON(`https://dummyjson.com/products/search?q=iphone`);
56+
```

docs/guide/what-is-fetchclient.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# What is FetchClient?
2+
3+
FetchClient is a tiny library that makes working with `fetch` delightful. It
4+
provides:
5+
6+
- Typed JSON helpers: `getJSON`, `postJSON`, etc.
7+
- A `FetchClient` class with middleware support
8+
- Caching with TTL and programmatic invalidation
9+
- Rate limiting per domain
10+
- Timeouts and AbortSignal support
11+
- Helpful error handling with Problem Details
12+
13+
Use just the functions for small scripts, or the client for full apps.

docs/index.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
layout: home
3+
hero:
4+
name: Foundatio FetchClient
5+
text: Typed, ergonomic fetch for JS/TS
6+
tagline: JSON helpers, caching, middleware, rate limiting, and great DX
7+
image:
8+
src: https://raw.githubusercontent.com/FoundatioFx/Foundatio/main/media/foundatio-icon.png
9+
alt: Foundatio
10+
actions:
11+
- theme: brand
12+
text: Get Started
13+
link: /guide/getting-started
14+
- theme: alt
15+
text: View on GitHub
16+
link: https://github.com/FoundatioFx/FetchClient
17+
features:
18+
- icon:
19+
title: Typed Responses
20+
details: Full TypeScript support for strongly-typed JSON results.
21+
- icon: 🧩
22+
title: Middleware & Caching
23+
details: Compose middleware and cache responses with TTL.
24+
- icon: 🎯
25+
title: Rate Limits & Timeouts
26+
details: Built-in rate limiting, timeouts, and robust error handling.
27+
---
28+
29+
## Quick Example
30+
31+
```ts
32+
import { FetchClient } from "@foundatiofx/fetchclient";
33+
34+
type Products = { products: Array<{ id: number; name: string }> };
35+
36+
const client = new FetchClient();
37+
const res = await client.getJSON<Products>(
38+
`https://dummyjson.com/products/search?q=iphone&limit=10`,
39+
);
40+
41+
console.log(res.data?.products.length);
42+
```

0 commit comments

Comments
 (0)