# puck

> lightweight cross-terminal onion-middleware network io engine

Latest version **1.1.9** (published 2016-07-14) · MIT license · 0 weekly downloads

## Install

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

## 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.1.9 |
| Published | 2016-07-14 |
| First published | 2014-11-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | i@playman.me |
| Maintainers | playman |

## Links

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

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^4.13.1
- [fetch-jsonp](https://npm.io/package/fetch-jsonp.md) ^1.0.0
- [whatwg-fetch](https://npm.io/package/whatwg-fetch.md) ^1.0.0

## Recent versions

- 1.1.9 (latest) — 2016-07-14
- 1.1.8 — 2016-07-14
- 1.1.7 — 2016-07-14
- 1.1.6 — 2016-07-14
- 1.1.5 — 2016-07-14
- 1.1.4 — 2016-07-12
- 1.1.3 — 2016-07-11
- 1.1.2 — 2016-07-11
- 1.1.1 — 2016-07-09
- 1.1.0 — 2016-07-07
- 1.0.3 — 2016-07-07
- 1.0.2 — 2016-07-06
- 1.0.1 — 2016-07-06
- 1.0.0 — 2016-07-06
- 0.0.1 — 2014-11-10

## README

# About
puck is a library for any terminal request and response. which aims to be a lightweight, cross-terminal,
onion-middleware network-io engine

# Features
- cross terminal and lightweight api
- base on Fetch and Promise api
- onion-middleware system

# Installation
```js
   npm install puck
```

# Api

## Static property

### Puck.version
return Puck library version

### Puck.middlewares
return middlewares list

### Puck.applyMiddlewares([midwares])
load midwares

## new Puck(options)
- `debug`{boolean} : debug mode
- `env`{string} : run dev

## Instance Api

### use(middleware)
async functions (Babel required)
```js
    puck.use(async (ctx,next){
        // req process
        await next();
        // res process
    });

```

### request(url,options)
- `method`{string} : request method,default is `GET`
- `jsonp`{boolean}: jsonp request
- `headers`{object} : request headers object
- `body` : request body, Support`string`,`formdata`,
- `credentials`{string} : Sending cookies,optional `same-origin` or `include`
- `type`{string}: response body content-type.optional `json` ,`html`,`text`,`blob`

### Convenience methods
- **get**
puck.get(url)

- **post**
puck.post(url,options)

- **put**
puck.put(url,options)

- **delete**
puck.delete(url)


## Example
```js
const puck = new Puck();
puck.use(async (ctx,next){
    ctx.req.url = 'xxx';
    await next();
    // res process
});

puck.get('/xxx/yyy')
    .then()
    .catch()
```

## License
MIT

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