# hemera-plugin

> This is a plugin helper for hemera

Latest version **2.0.2** (published 2019-10-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install hemera-plugin
pnpm add hemera-plugin
yarn add hemera-plugin
bun add hemera-plugin
```

## 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 | 2.0.2 |
| Published | 2019-10-20 |
| First published | 2017-06-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 808 |
| Author | Dustin Deus |
| Maintainers | starptech |

## Links

- npm: https://www.npmjs.com/package/hemera-plugin
- Repository: git@github.com:hemerajs/hemera
- npm.io page: https://npm.io/package/hemera-plugin

## Dependencies (1)

- [semver](https://npm.io/package/semver.md) 5.5.x

## Recent versions

- 2.0.2 (latest) — 2019-10-20
- 2.0.1 — 2019-04-07
- 2.0.0 — 2019-02-16
- 1.3.3 — 2018-11-04
- 1.3.2 — 2018-10-06
- 1.3.1 — 2018-10-03
- 1.3.0 — 2018-04-10
- 1.2.0 — 2018-04-10
- 1.1.1 — 2018-03-19
- 1.1.0 — 2018-03-19
- 1.0.0 — 2018-03-11
- 0.1.2 — 2018-03-08
- 0.1.1 — 2017-12-27
- 0.1.0 — 2017-12-19
- 0.0.17 — 2017-10-08
- … 16 more at https://npm.io/package/hemera-plugin/versions

## README

# Hemera-plugin package

[![npm](https://img.shields.io/npm/v/hemera-plugin.svg?maxAge=3600)](https://www.npmjs.com/package/hemera-plugin)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](#badge)

`hemera-plugin` is a plugin helper for [Hemera](https://github.com/hemerajs/hemera).

## Usage

`hemera-plugin` can do some things for you:

* Check the bare-minimum version of Hemera
* Provide consistent interface to register plugins even when the api is changed
* Pass metadata to intialize your plugin with correct dependencies, default options and name.

```js
const hp = require('hemera-plugin')

module.exports = hp(function(hemera, opts, next) {
  next()
})
```

If you need to set a bare-minimum version of Hemera for your plugin, just add the [semver](http://semver.org/) range that you need:

```js
const hp = require('hemera-plugin')

module.exports = hp(function(hemera, opts, next) {
  next()
}, '0.x')
```

You can check [here](https://github.com/npm/node-semver#ranges) how to define a `semver` range.

## Async / Await

```js
const hp = require('hemera-plugin')

module.exports = hp(async function(hemera, opts) {
  // your plugin code
}, '0.x')
```

You can also pass some metadata that will be handled by Hemera, such as the dependencies, default options and the name of your plugin.

```js
const hp = require('hemera-plugin')

function plugin(hemera, opts, next) {
  // your plugin code
  next()
}

module.exports = hp(plugin, {
  hemera: '0.x', // bare-minimum version of Hemera
  name: 'my-plugin', // name of your plugin, will be used e.g for logging purposes
  scoped: false, // when false no hemera plugin is created. This is useful if you want to extend the core but don't need a seperate plugin scope.
  options: { host: 'localhost', port: 8003 }, // default options for your plugin
  // Plugin dependencies
  decorators: ['joi'],
  dependencies: ['plugin2']
})
```

### Credits

[fastify-plugin](https://github.com/fastify/fastify-plugin)

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