Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
fveracoechea committed Aug 16, 2024
1 parent 0f83241 commit 0e9b541
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 39 deletions.
1 change: 0 additions & 1 deletion README.md

This file was deleted.

64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# 🌩️ Fetchtastic

Small wrapper around fetch designed to perform more predictable and type-safe
network requests, with **zero** dependencies.

[![GitHub issues](https://img.shields.io/github/issues-raw/fveracoechea/fetchtastic?color=blue)](https://github.com/fveracoechea/fetchtastic/issues)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/fveracoechea/fetchtastic)](https://github.com/fveracoechea/fetchtastic/pulse)
[![bundle.js](https://deno.bundlejs.com/?q=fetchtastic&badge)](https://bundlejs.com/?q=fetchtastic)
[![npm](https://img.shields.io/npm/v/fetchtastic?color=blue)](https://www.npmjs.com/package/fetchtastic)
[![npm](https://img.shields.io/npm/dm/fetchtastic.svg?color=blue)](https://www.npmjs.com/package/fetchtastic)

|| Features | |
| --- | ----------- | ------------------------------------------------------- |
| 🪶 | Lightweight | Less than 3kB gzipped |
| 🧩 | Composable | Safely reuse previous configurations |
| 😀 | Intuitive | Clean and easy to use API |
| 🛡️ | Type safe | Strongly typed, written in TypeScript |
| 🛠️ | Isomorphic | Compatible with modern `browsers`, `Node.js` and `Deno` |
|| Well Tested | Covered by unit tests |

## 📖 Documentation

Visit
[fveracoechea.github.io/fetchtastic](https://fveracoechea.github.io/fetchtastic/)
to view the full documentation.

## ⚡Getting Started

```sh
npm install fetchtastic
```

**Fetchtastic** is built on standard web APIs and runs everywhere fetch is
available.

- Modern browsers
- Node.js >= v18
- Deno
- Service Workers
- Netlify Edge Functions
- Vercel Edge Functions
- and more...

### Basic usage

```typescript
const api = fetchtastic('https://jsonplaceholder.typicode.com')
.setOptions({ cache: 'default', mode: 'cors' })
.appendHeader('Content-Type', 'application/json');

const blogPosts = await api
.get('/posts')
.setSearchParams({ page: 1, per_page: 12 })
.json();

await api.url('/albums').post({ title: 'My New Album' }).resolve();
```

## 🕹️ Contributing

Contributions are welcome and highly appreciated. However, before you jump right
into it, we would like you to review our
[Contribution Guidelines](https://github.com/fveracoechea/fetchtastic/blob/main/CONTRIBUTING.md)
to make sure you have a smooth experience.
34 changes: 17 additions & 17 deletions docs/docs/core-concepts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@ You'll learn how to configure your network requests to ensure they are
predictable and type-safe, explore the various methods available for handling
responses, and understand how to effectively catch and manage errors.

## Fluent Interface Design

**Fetchtastic** combines its features through a fluent interface API design,
enabling you to chain methods together in a clear and concise manner. This
design allows you to configure your requests step-by-step, with each method call
returning the modified instance, making it easy to build and customize requests
without needing separate setup steps.

```typescript
const posts = await fetchtastic('https://jsonplaceholder.typicode.com')
.get('/posts')
.setSearchParams({ page: 1, first: 12 })
.appendHeader('Content-Type', 'application/json')
.notFound(() => Response.json({ message: 'Record not found' }))
.json();
```

## Request configuration

in **Fetchtastic**, it refers to the set of options and methods available to
Expand Down Expand Up @@ -162,20 +179,3 @@ the resulting data.
- [ blob ](/docs/api/classes/Fetchtastic#blob)
- [ formData ](/docs/api/classes/Fetchtastic#formdata)
- [ text ](/docs/api/classes/Fetchtastic#text)

## Fluent Interface Design

**Fetchtastic** combines its features through a fluent interface API design,
enabling you to chain methods together in a clear and concise manner. This
design allows you to configure your requests step-by-step, with each method call
returning the modified instance, making it easy to build and customize requests
without needing separate setup steps.

```typescript
const posts = await fetchtastic('https://jsonplaceholder.typicode.com')
.get('/posts')
.setSearchParams({ page: 1, first: 12 })
.appendHeader('Content-Type', 'application/json')
.notFound(() => Response.json({ message: 'Record not found' }))
.json();
```
32 changes: 12 additions & 20 deletions lib/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 🌩️ Fetchtastic

Small wrapper around fetch designed to perform more predictable and type-safe
network requests.
network requests, with **zero** dependencies.

[![GitHub issues](https://img.shields.io/github/issues-raw/fveracoechea/fetchtastic?color=blue)](https://github.com/fveracoechea/fetchtastic/issues)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/fveracoechea/fetchtastic)](https://github.com/fveracoechea/fetchtastic/pulse)
Expand All @@ -20,34 +20,26 @@ network requests.

## 📖 Documentation

Visit [fetchtastic-docs.vercel.app](https://fveracoechea.github.io/fetchtastic/)
Visit
[fveracoechea.github.io/fetchtastic](https://fveracoechea.github.io/fetchtastic/)
to view the full documentation.

## ⚡Getting Started

npm

```sh
npm install fetchtastic
```

pnpm

```sh
pnpm add fetchtastic
```

yarn
**Fetchtastic** is built on standard web APIs and runs everywhere fetch is
available.

```sh
yarn add fetchtastic
```

deno

```typescript
import { fetchtastic } from 'https://deno.land/x/fetchtastic/lib/mod.ts';
```
- Modern browsers
- Node.js >= v18
- Deno
- Service Workers
- Netlify Edge Functions
- Vercel Edge Functions
- and more...

### Basic usage

Expand Down
1 change: 0 additions & 1 deletion lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"@typescript-eslint/parser": "^7.7.1",
"babel-jest": "^29.7.0",
"eslint": "^8",
"eslint-config": "*",
"eslint-config-prettier": "^9.1.0",
"jest": "^29.7.0",
"prettier": "3.2.5",
Expand Down

0 comments on commit 0e9b541

Please sign in to comment.