open-index/open-npm huggingface dataset:
npm package: @malijs/apikey
Description: Api key authorization metadata middleware for Mali
Author: Bojan D.
Latest version: 0.2.0

# @malijs/apikey

Mali API key metadata authorization middleware

[![npm version](https://img.shields.io/npm/v/@malijs/apikey.svg?style=flat-square)](https://www.npmjs.com/package/@malijs/apikey)
[![build status](https://img.shields.io/travis/malijs/apikey/master.svg?style=flat-square)](https://travis-ci.org/malijs/apikey)

## API

<a name="module_@malijs/apikey"></a>

### @malijs/apikey
Mali API key authorization metadata middleware.
If the call has metadata with "authorization" string property with "apikey <key>" then specified function is called


| Param | Type | Description |
| --- | --- | --- |
| options | <code>Options</code> |  |
| options.keyField | <code>String</code> | Optional key field within the authorization value to look for. Default: <code>"apikey"</code> |
| options.error | <code>String</code> \| <code>Object</code> \| <code>function</code> | optional Error creation options.                                                If <code>String</code> the message for Error to throw in case                                                authorization is not present.                                                If <code>Object</code> the error options with <code>message</code>,                                                <code>code</code>, and <code>metadata</code> properties. See <code>create-grpc-error</code>                                                module.                                                If <code>Function</code> a function with signature <code>(ctx)</code>                                                called to create an error. Must return an <code>Error</code> instanse.                                                Default: <code>"Not Authorized"</code> |
| fn | <code>function</code> | The middleware function to execute with signature <code>(key, ctx, next)</code> |

**Example**  
```js
const apikey = require('@malijs/apikey')

app.use(apikey(async (key, ctx, next) => {
  console.log(key)
  await next()
})
```
## License

  Apache-2.0
npm package: @malijs/bearer
Description: Bearer token authorization metadata middleware for Mali
Author: Bojan D.
Latest version: 0.2.0

# @malijs/bearer

Mali bearer token metadata authorization middleware

[![npm version](https://img.shields.io/npm/v/@malijs/bearer.svg?style=flat-square)](https://www.npmjs.com/package/@malijs/bearer)
[![build status](https://img.shields.io/travis/malijs/bearer/master.svg?style=flat-square)](https://travis-ci.org/malijs/bearer)

## API

<a name="module_@malijs/bearer"></a>

### @malijs/bearer
Mali bearer authorization metadata middleware.
If the call has metadata with "authorization" string property with "Bearer <token>" then specified function is called


| Param | Type | Description |
| --- | --- | --- |
| options | <code>Options</code> |  |
| options.error | <code>String</code> \| <code>Object</code> \| <code>function</code> | optional Error creation options.                                                If <code>String</code> the message for Error to throw in case                                                authorization is not present.                                                If <code>Object</code> the error options with <code>message</code>,                                                <code>code</code>, and <code>metadata</code> properties. See <code>create-grpc-error</code>                                                module.                                                If <code>Function</code> a function with signature <code>(ctx)</code>                                                called to create an error. Must return an <code>Error</code> instanse.                                                Default: <code>"Not Authorized"</code> |
| fn | <code>function</code> | The middleware function to execute with signature <code>(token, ctx, next)</code> |

**Example**  
```js
const bearer = require('@malijs/bearer')

app.use(bearer(async (token, ctx, next) => {
  console.log(token)
  await next()
})
```
## License

  Apache-2.0
npm package: @malijs/call-types
Description: Call types for Mali
Author: Bojan D.
Latest version: 0.4.0

<a name="module_@malijs/call-types"></a>

### @malijs/call-types
**Example**  
```js
const CallType = require('@malijs/call-types')
console.log(CallType.DUPLEX)
```
**Example** *(Within Mali call handler)*  
```js
if(ctx.type === CallType.UNARY) {
  console.log('Unary call')
}
```

* [@malijs/call-types](#module_@malijs/call-types)
    * [.UNARY](#module_@malijs/call-types.UNARY)
    * [.REQUEST_STREAM](#module_@malijs/call-types.REQUEST_STREAM)
    * [.RESPONSE_STREAM](#module_@malijs/call-types.RESPONSE_STREAM)
    * [.DUPLEX](#module_@malijs/call-types.DUPLEX)

<a name="module_@malijs/call-types.UNARY"></a>

#### @malijs/call-types.UNARY
Unary call

**Kind**: static property of [<code>@malijs/call-types</code>](#module_@malijs/call-types)  
<a name="module_@malijs/call-types.REQUEST_STREAM"></a>

#### @malijs/call-types.REQUEST\_STREAM
Request is a stream

**Kind**: static property of [<code>@malijs/call-types</code>](#module_@malijs/call-types)  
<a name="module_@malijs/call-types.RESPONSE_STREAM"></a>

#### @malijs/call-types.RESPONSE\_STREAM
Response is a stream

**Kind**: static property of [<code>@malijs/call-types</code>](#module_@malijs/call-types)  
<a name="module_@malijs/call-types.DUPLEX"></a>

#### @malijs/call-types.DUPLEX
Duplex call where both request and response are streams

**Kind**: static property of [<code>@malijs/call-types</code>](#module_@malijs/call-types)