# koa2-heartbeat

> koa2 心跳检查中间件

Latest version **1.0.1** (published 2018-01-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install koa2-heartbeat
pnpm add koa2-heartbeat
yarn add koa2-heartbeat
bun add koa2-heartbeat
```

## 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.0.1 |
| Published | 2018-01-23 |
| First published | 2018-01-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | qianlongoo |

## Links

- npm: https://www.npmjs.com/package/koa2-heartbeat
- Repository: https://github.com/qianlongo/koa2-heartbeat
- Homepage: https://github.com/qianlongo/koa2-heartbeat#readme
- Issues: https://github.com/qianlongo/koa2-heartbeat/issues
- npm.io page: https://npm.io/package/koa2-heartbeat

## Recent versions

- 1.0.1 (latest) — 2018-01-23
- 1.0.0 — 2018-01-23

## README

## koa2-heartbeat

> koa2 心跳检查中间件

## 需求背景

> 对于node服务，我们希望有一个与业务无关的路由，可以检查该服务是否”正常运转“，比如访问`http://localhost:3000/heart/check`,返回`heart check passed !!!`

## 使用

**koa2-heartbeat中间件提供两个参数**

1. beatReg

表示要访问的该路由的匹配规则。默认是`/^\/heart\/check/`,也就是以为`/heart/check`开头

2. beatMsg

表示命中上述路由之后，返回的消息内容，默认是`heart check passed !!!`


``` javascript

const Koa = require('koa')
const heartbeat = require('koa2-heartbeat')
const app = new Koa()
const PORT = 3000

// 1. 默认用法
app.use(heartBeat())
// 2. 添加自己的规则
app.use(heartBeat(/^\/health\/check/, 'health check passed !!!'))

app.listen(PORT, () => {
  console.log(`app start at: ${PORT}`)
})


```

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