# express-server-ping

> Express middleware to check server status and ping remotely

Latest version **1.0.0** (published 2022-02-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install express-server-ping
pnpm add express-server-ping
yarn add express-server-ping
bun add express-server-ping
```

## 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.0 |
| Published | 2022-02-23 |
| First published | 2022-02-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Emily |
| Maintainers | imemily |

## Links

- npm: https://www.npmjs.com/package/express-server-ping
- Repository: https://github.com/botkalista/express-server-ping
- Homepage: https://github.com/botkalista/express-server-ping#readme
- Issues: https://github.com/botkalista/express-server-ping/issues
- npm.io page: https://npm.io/package/express-server-ping

## Recent versions

- 1.0.0 (latest) — 2022-02-23

## README

# Express Server Ping

Basic  middleware that creates an endpoint to check if the server is running and it's ping.

### Params

- Default param for Method is GET
- Default param for Path is /status

## Install

```sh
$ npm install express-server-status
```

## Usage

To use it with default settings

```js
const serverStatus = require("express-server-ping");

//  create the endpoint on GET /status
app.use(serverStatus());
```

To use it on a custom path

```js
const serverStatus = require("express-server-ping");

//  create the endpoint on GET /custom_endpoint
app.use(serverStatus({path:'/custom_endpoint'}));
```

## `Response`

The created endpoint will send a response with a json like this `{time: 000}` where the value is the timestamp when the server received the request.
So to check the ping you can do:

> Code from examples/example.js

```js
fetch('https://127.0.0.1/status').then(res => res.json()).then(data => {
    const now = Date.now();
    const roundtriptime = now - data.time;
    console.log(`Server is up | ${roundtriptime} ms`);
}).catch(ex => {
    console.log(`Server is down`);
}).finally(() => {
    server.close();
});
```

## License
MIT ©

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