Skip to content

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

License

Notifications You must be signed in to change notification settings

gquittet/graceful-server

Repository files navigation

πŸš€ 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

βœ” 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 part.

/live

The endpoint responds:

  • 200 status code with the uptime of the server in second.
{ "uptime": 42 }

Used to configure liveness probe.

/ready

The endpoint responds:

  • 200 status code if the server is ready.
{ "status": "ready" }
  • 503 status code with an empty response if the server is not ready (started, shutting down, etc).

Example

See: EXAMPLE.md

API Doc

See: API.md

Integration with Docker

See: DOCKER.md

Integration with Kubernetes

See: KUBERNETES.md

Thanks

β˜… Terminus

β˜… Lightship

β˜… Stoppable

β˜… Bret Fisher for his great articles and videos

β˜… IBM documentation

β˜… Node HTTP documentation

β˜… Cloud Health

β˜… Cloud Health Connect

Sponsors

JetBrains Logo

Donate

Donate

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