https://github.com/tinyhttp/ping
🏓 Response time checker middleware
https://github.com/tinyhttp/ping
express middleware nodejs perf performance ping ping-middleware tinyhttp
Last synced: 2 months ago
JSON representation
🏓 Response time checker middleware
- Host: GitHub
- URL: https://github.com/tinyhttp/ping
- Owner: tinyhttp
- License: mit
- Created: 2021-07-30T10:27:06.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-05-27T19:09:15.000Z (about 2 years ago)
- Last Synced: 2025-03-24T08:47:22.476Z (3 months ago)
- Topics: express, middleware, nodejs, perf, performance, ping, ping-middleware, tinyhttp
- Language: TypeScript
- Homepage:
- Size: 94.7 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# @tinyhttp/ping
[![npm][npm-img]][npm-url] [![GitHub Workflow Status][gh-actions-img]][github-actions] [![Coverage][cov-img]][cov-url]
> Inspired by [koa-response-time](https://github.com/koajs/response-time)
Response time checker for Node.js. Sets `X-Response-Time` header using `process.hrtime()`
## Install
```sh
pnpm i @tinyhttp/ping
```## API
```js
import { ping } from '@tinyhttp/ping'
```### Options
#### `round`
Round the ping time. Default is set to true.
## Example
```js
import { ping } from '@tinyhttp/ping'
import { createServer } from 'http'
import path from 'path'createServer(async (req, res) => {
ping()(req, res)
res.end('Hello World')
}).listen(3000)
```[npm-url]: https://npmjs.com/package/@tinyhttp/ping
[github-actions]: https://github.com/tinyhttp/ping/actions
[gh-actions-img]: https://img.shields.io/github/actions/workflow/status/tinyhttp/ping/ci.yml?branch=master&style=for-the-badge&logo=github&label=&color=hotpink
[cov-img]: https://img.shields.io/coveralls/github/tinyhttp/ping?style=for-the-badge&color=hotpink
[cov-url]: https://coveralls.io/github/tinyhttp/ping
[npm-img]: https://img.shields.io/npm/dt/@tinyhttp/ping?style=for-the-badge&color=hotpink