hurp-launch
An opinionated launcher for hurp-based applications.
Features:
- calls
init()
anddestroy()
on your App instance - catches errors during boot and shutdown and immediately crashes the application
- listens for
uncaughtException
andunhandledRejection
events and immediately crashes application in such case - listens for
SIGINT
andSIGTERM
process events to trigger a graceful shutdown of the application
Installation
$ npm install hurp-launch
Usage
;;; ; launchmain, ;
There is no need to
.catch()
onlaunch
function as it will internally callprocess.exit(1)
on any errors
Logger
Logger instance must be compatible with that interface:
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>
;
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