# @rzymek/codegen-api-client

> Opinionated uniform configuration for openapi generated fetch-typescript client

Latest version **1.0.3** (published 2022-10-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rzymek/codegen-api-client
pnpm add @rzymek/codegen-api-client
yarn add @rzymek/codegen-api-client
bun add @rzymek/codegen-api-client
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2022-10-01 |
| First published | 2022-06-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Krzysztof Rzymkowski ttps://github.com/rzymek |
| Maintainers | rzymek |

## Links

- npm: https://www.npmjs.com/package/@rzymek/codegen-api-client
- Repository: https://github.com/rzymek/codegen-api-client
- Homepage: https://github.com/rzymek/codegen-api-client#readme
- Issues: https://github.com/rzymek/codegen-api-client/issues
- npm.io page: https://npm.io/package/@rzymek/codegen-api-client

## Recent versions

- 1.0.3 (latest) — 2022-10-01
- 1.0.2 — 2022-09-18
- 1.0.1 — 2022-06-03
- 1.0.0 — 2022-06-03

## README

[![.github/workflows/publish.yml](https://github.com/rzymek/codegen-api-client/actions/workflows/publish.yml/badge.svg)](https://github.com/rzymek/codegen-api-client/actions/workflows/publish.yml)

# Optionated uniform configuration for openapi codegen client

Configure all services generated with openapi codegen fetch-typescript template.

Assumtions:
* Content type is `application/json`
* Authentication is Bearer token via header

## Install

```bash
yarn add @rzymek/codegen-api-client
```

## Setup
```typescript
import { Configuration } from "api-client/src";
import * as apis from "api-client/src/apis";
import { configureApiClient } from "@rzymek/codegen-api-client";

const api = configureApiClient(apis, Configuration, {
  baseUrl: 'http://api.web.app', 
  bearerToken: async () => globalState.bearerToken,
  onErrorResponse(errorJson) {
      if(errorJson.parameterViolations?.length) {
          thro new ApiValidationError();;
      }
  },
  throwError(msg, error) {
      showNotification(msg);
      throw new Error(msg);
  }
  onNetworking(networking) { updateGlobalState({ networking }) }
});
```

## Usage

```typescript
const result = api.SampleResourceApi.list()
```

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