Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

hurp-launch

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hurp-launch

Launcher for hurp-based applications

latest
Source
npmnpm
Version
2.0.1
Version published
Maintainers
1
Created
Source

hurp-launch

npm

An opinionated launcher for hurp-based applications.

Features:

  • calls init() and destroy() on your App instance
  • catches errors during boot and shutdown and immediately crashes the application
  • listens for uncaughtException and unhandledRejection events and immediately crashes application in such case
  • listens for SIGINT and SIGTERM process events to trigger a graceful shutdown of the application

Installation

$ npm install hurp-launch

Usage

import pino from 'pino';
import { launch } from 'hurp-launch';
import { App } from './app';

const log = pino();

async function main() {
  return new App({ log });
}

launch(main, { log });

There is no need to .catch() on launch function as it will internally call process.exit(1) on any errors

Logger

Logger instance must be compatible with that interface:

interface Log {
  info(message: string): void;
  fatal(obj: { err: Error }, message: string): void;
}

This approach is inspired by Bunyan. You can use a compatible logger like pino directly or write a simple wrapper around any other you like.

API

async launch(main: Main, options: Options): Promise<void>

import { launch } from 'hurp-launch';

Executes main function and launches the application instance it returned.

main - async function that return an App instance
options - object containing options
options.log - logger instance compatible with interface described above

Keywords

hurp

FAQs

Package last updated on 29 Mar 2020

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