# @devswoop/hermes

> API route manager for the browser

Latest version **1.2.0** (published 2019-03-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install @devswoop/hermes
pnpm add @devswoop/hermes
yarn add @devswoop/hermes
bun add @devswoop/hermes
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2019-03-04 |
| First published | 2019-02-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | devSwoop |
| Maintainers | devswoop |

## Links

- npm: https://www.npmjs.com/package/@devswoop/hermes
- Repository: https://github.com/devSwoop/Hermes
- Homepage: https://github.com/devSwoop/Hermes#readme
- Issues: https://github.com/devSwoop/Hermes/issues
- npm.io page: https://npm.io/package/@devswoop/hermes

## Recent versions

- 1.2.0 (latest) — 2019-03-04
- 1.1.0 — 2019-03-03
- 1.0.4 — 2019-02-26
- 1.0.3 — 2019-02-26
- 1.0.2 — 2019-02-26
- 1.0.1 — 2019-02-24
- 1.0.0 — 2019-02-24

## README

# Hermes

Simple, centralized and promised API routes manager for the browser.

```js
import Hermes from 'Hermes'

Hermes.init({
  baseUrl: 'serverHostname',
  port: 3000
}, [
  {
    name: 'userLogin',
    method: 'post',
    path: 'login'
  }
])

// POST http://localhost:3000/login
Hermes.run('userLogin', {
  data: {
    mail: 'mail@example.com',
    password: 'secretPassword'
  }
}
.then(data => {
  // ...
})
.catch(error => {
  // ...
})
```

You can also add middlewares like that, these will requests without errors

```js
Hermes.listener(data => new Promise((resolve, reject) => {
  // You can edit the data
  data.date = Date.now()
  resolve(data)
}))
```

You can do the same with errors

```js
Hermes.catch(data => new Promise((resolve, reject) => {
  if (data.message === 'You are not authenticated') {
    window.location.reload()
  } else {
    reject(data)
  }
}))
```

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