GithubHelp home page GithubHelp logo

diegoh / koa-healthcheck-routers Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 1.2 MB

Routers for shallow and deep healthchecks for koa and @koa/router

License: MIT License

JavaScript 0.38% TypeScript 99.62%

koa-healthcheck-routers's Introduction

@diegoh/koa-healthcheck-routers

Build License: MIT Package Version

This module exports 2 @koa/router routers.

1. Deep Checks

Provides a router with a single GET route (defaults to /healthcheck). Requires an array of URLs to check as configuration.

It checks each of the URLs provided. A 200 OK response means the service can connect to all services.

If any of the services fails to respond, or returns any status code other than 2xx, the response for this endpoint will be 500 Internal Server Error.

The details of the erros can be found in the response body.

2. Shallow Checks

Cheap check for the service itself, it does not check any underlying services. Similarly, a 200 status code means the service is up.

Example

import * as Koa from 'koa';

import { DeepRouter, ShallowRouter } from '@diegoh/koa-healthcheck-routers';

const urls = [
  new URL('http://localhost:11111/healthcheck'),
  new URL('http://localhost:22222/healthcheck'),
  new URL('http://localhost:33333/healthcheck')
];

const app = new Koa();
const healthcheck = new DeepRouter(urls);
const heartbeat = new ShallowRouter();

app.use(healthcheck.routes());
app.use(healthcheck.allowedMethods());
app.use(heartbeat.routes());
app.use(heartbeat.allowedMethods());

app.listen(3000);

Development

  1. Create a new branch from main with a name relevant to the changes you're making. git branch -b my-new-feature-description
  2. Push the branch and open a Pull Request.
  3. Request a code review, make sure all tests pass.
  4. Commits will be Squash merged into the mainline to keep things tidy.

Testing

Unit

npm run test:unit

Coverage

npm run test:coverage

Integration

npm run test:integration

Lint

npm run lint or npm run lint:fix

koa-healthcheck-routers's People

Contributors

dependabot-preview[bot] avatar diegoh avatar

Stargazers

 avatar

Watchers

 avatar  avatar

koa-healthcheck-routers's Issues

[Security] Workflow publish-public.yml is using vulnerable action actions/checkout

The workflow publish-public.yml is referencing action actions/checkout using references v1. However this reference is missing the commit a6747255bd19d7a757dbdda8c654a9f84db19839 which may contain fix to the some vulnerability.
The vulnerability fix that is missing by actions version could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider to update the reference to the action.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.