Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@iad-os/irene-kills-es

Package Overview
Dependencies
Maintainers
4
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iad-os/irene-kills-es

Yes ... only if necessary, but ... Irene Kills!

  • 0.0.7-alpha
  • latest
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

IK-logo

Welcome to @iad-os/irene-kills 👋

Version License: Apache--2.0

Yes ... only if necessary, but ... Irene Kills!

Table of content

-----------------------------------------------------

📝 About The Project

Irene Kills is a library written in TypeScript that allows you to easily manage the application life-cycle. We created this library to build applications that respect cloud native principles and to find a standard and tested way to manage the life cycle of our microservices.

IK - goals It allows you to create applications that are resilient, able to detect changes in the system, detect errors and react accordingly, for example by killing itself or going into a sick state.

Ensures that when the application is in a "healthy" state it is actually ready to respond. If an error occurs in the system that could affect the operation of the application, the application will notice the change and change its status.

-----------------------------------------------------

Prerequisites

  • node >= 16.13 <17

-----------------------------------------------------

Install

npm install @iad-os/irene-kills

-----------------------------------------------------

Usage

Instantiate and configure examples:

import { IreneKills } from '@iad-os/irene-kills';
import { introspectCredentials } from '../main-auth';
import * as dbService from '../main-db';
import * as apiService from '../main-http';
import log from '../config/log';

const irene = new IreneKills({ logger: log({ tags: ['ik'] }) });

irene.resource<{ logger: ReturnType<typeof log> }>('database', {
  value: { logger: log({ tags: ['db'] }) },
  need: async ({ value: { logger } }) => {
    logger.info('⏳ initialize db connection');
    await dbService.start();
    return { logger };
  },
  check: async ({ value: { logger } }) => {
    try {
      await dbService.checkDb();
      logger.info('✅ OK check db connection');
      return true;
    } catch (err) {
      logger.error({ error: err }, '💥 KO check db connection');
      return false;
    }
  },

  on: {
    healthcheck: async () => {
      await dbService.checkDb();
      return { healthy: true, kill: false };
    },
  },
});

irene.resource('http', {
  activate: async () => {
    try {
      await apiService.start();
      log({ tags: ['server'] }).info('✅ Application started');
      return { kill: false, healthy: true };
    } catch (err) {
      return { kill: true, healthy: false };
    }
  },
});

irene.resource<{ logger: ReturnType<typeof log> }>('oidc', {
  value: { logger: log({ tags: ['odic'] }) },
  check: async ({ value: { logger } }) => {
    try {
      await introspectCredentials();
      logger.info(`✅ OK Credentials`);
      return true;
    } catch (error) {
      logger.error(error, `💥 KO Credentials`);
      return false;
    }
  },
});

export default irene;

Wake up Irene in main.ts:

irene
  .wakeUp()
  .finally(() =>
    log({ tags: ['wakeup', 'application', 'status'] }).info(
      `⚙️  APPLICATION STATUS -> ${irene.mood()}`
    )
  );

Current application status:

irene.mood()

Trigger healthcheck:

irene.healthcheck();

For more examples check under __test__ folder.

-----------------------------------------------------

Run tests

npm run test

-----------------------------------------------------

Author

👤 Daniele Fiungo daniele.fiungo@iad2.it

-----------------------------------------------------

Contributors

Show your support

Give a ⭐️ if this project helped you!

-----------------------------------------------------

License

Licensed under the APLv2. See the LICENSE file for details.

Made with ❤️ by IAD

FAQs

Package last updated on 31 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc