Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gquittet/graceful-server

Tiny (~5k), KISS, dependency-free Node.JS library to make your API more graceful
https://github.com/gquittet/graceful-server

docker dockerfile expressjs fastify graceful graceful-server health-check kiss kubernetes liveness nodejs probes readiness server tiny

Last synced: 2 days ago
JSON representation

Tiny (~5k), KISS, dependency-free Node.JS library to make your API more graceful

Awesome Lists containing this project

README

        


🚀 Graceful Server 🐢



GitHub package.json version


JavaScript Style Guide


npm type definitions


License


npmjs download


Donate with PayPal


Tiny (~5k), KISS, dependency-free Node.JS library to make your Rest API graceful.

---

- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [NPM](#npm)
- [PNPM](#pnpm)
- [YARN](#yarn)
- [Endpoint](#endpoint)
- [/live](#live)
- [/ready](#ready)
- [Example](#example)
- [API Doc](#api-doc)
- [Integration with Docker](#integration-with-docker)
- [Integration with Kubernetes](#integration-with-kubernetes)
- [Thanks](#thanks)
- [Sponsors](#sponsors)
- [Donate](#donate)

## Features

✔ It's listening system events to gracefully close your API on interruption.

✔ It facilitates the disconnect of data sources on shutdown.

✔ It facilitates the use of liveness and readiness.

✔ It manages the connections of your API.

✔ It avoid boilerplate codes.

✔ Kubernetes compliant.

✔ Dependency-free.

✔ KISS code base.

## Requirements

✔ NodeJS >= 18.0

## Installation

### NPM

```
npm install --save @gquittet/graceful-server
```

### PNPM

```
pnpm add @gquittet/graceful-server
```

### YARN

```
yarn add @gquittet/graceful-server
```

## Endpoint

Below you can find the default endpoint but you can setup or disable them. To do that, check out the [Options](#options) part.

### /live

The endpoint responds:

- `200` status code with the uptime of the server in second.

```json
{ "uptime": 42 }
```

Used to configure liveness probe.

### /ready

The endpoint responds:

- `200` status code if the server is ready.

```json
{ "status": "ready" }
```

- `503` status code with an empty response if the server is not ready (started, shutting down, etc).

## Example

See: [EXAMPLE.md](./docs/EXAMPLE.md)

## API Doc

See: [API.md](./docs/API.md)

## Integration with Docker

See: [DOCKER.md](./docs/DOCKER.md)

## Integration with Kubernetes

See: [KUBERNETES.md](./docs/KUBERNETES.md)

## Thanks

★ [Terminus](https://github.com/godaddy/terminus)

★ [Lightship](https://github.com/gajus/lightship)

★ [Stoppable](https://github.com/hunterloftis/stoppable)

★ [Bret Fisher](https://github.com/BretFisher) for his great articles and videos

★ [IBM documentation](https://cloud.ibm.com/docs/node?topic=nodejs-node-healthcheck)

★ [Node HTTP documentation](https://nodejs.org/api/http.html)

★ [Cloud Health](https://github.com/CloudNativeJS/cloud-health)

★ [Cloud Health Connect](https://github.com/CloudNativeJS/cloud-health-connect)

## Sponsors

![JetBrains Logo](assets/sponsors/jetbrains.svg)

## Donate

[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=JN3XLTQCX3NR8&source=url)

If you like my job, don't hesitate to contribute to this project! ❤️