# venturer

> ```bash # yarn yarn add venturer

Latest version **0.1.0** (published 2021-02-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install venturer
pnpm add venturer
yarn add venturer
bun add venturer
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2021-02-10 |
| First published | 2021-02-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 2 |
| Unpacked size | 222.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Tobias Herber |
| Maintainers | tobihrbr |

## Links

- npm: https://www.npmjs.com/package/venturer
- npm.io page: https://npm.io/package/venturer

## Dependencies (2)

- [ky](https://npm.io/package/ky.md) 0.25.0
- [ky-universal](https://npm.io/package/ky-universal.md) 0.8.2

## Recent versions

- 0.1.0 (latest) — 2021-02-10

## README

<p align="center">
  <img src="https://i.imgur.com/dpdqxMa.png" width="200px">
</p>

<h1 align="center">
  Venturer
</h1>

<p align="center">
  Simple utilities for building SDKs and API clients. ✈🚀
</p>

## Install

```bash
# yarn
yarn add venturer

# npm
npm install --save venturer 
```

## Parameters

Venturer's `paramUrl` function makes it easy to handle rest-style path parameters.

Parameters must be wrapped in curly brackets, eg. `{userId}`. 
You can set the parameter using the string within the brackets, in this case `userId`.

A url can have as many parameters as you want.

```typescript
import { paramUrl } from 'venturer';

let url = paramUrl('/users/{userId}/post/{postId}');

url({ userId: '123', postId: 'abc' });
// > /users/123/post/abc
```

## Request

Venturer includes an easy-to-use request client based on [ky](https://github.com/sindresorhus/ky).

### Default client

The default client allows you to make simple request without setting up anything.

```typescript
import { request } from 'venturer';

// get
request.get('https://example.com', {
  // ky options
});

// delete
request.delete('https://example.com', {
  // ky options
});

// post
request.post('https://example.com', {
  // request body
}, {
  // ky options
});

// put
request.put('https://example.com', {
  // request body
}, {
  // ky options
});

// patch
request.patch('https://example.com', {
  // request body
}, {
  // ky options
});
```

### Custom client

A custom client allows you to set options for all request, like a url-prefix or auth token.

Custom clients have the same api as the default client.

```typescript
import { createClient } from 'venturer';

let client = createClient('https://api.example.com', {
  authorization: '<auth token>'
});

client.get('/user/123');
// makes a request to `https://api.example.com/user/123`
```

### Authentication

Venturer has built-in support for header-based authentication. By default it uses bearer auth.

```typescript
request.get('https://example.com', {
  authorization: '<auth token>'
});
// will set the `authorization` header to `bearer <auth token>`
```

You can optionally override the authorization header/scheme.

```typescript
request.get('https://example.com', {
  authorization: '<auth token>',
  authorizationHeader: 'auth',
  authorizationScheme: 'token'
});
// will set the `auth` header to `token <auth token>`
```

---
_Source: https://npm.io/package/venturer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
