/fastify-register-timeout

Register fastify plugin with a timeout

Primary LanguageJavaScriptMIT LicenseMIT

fastify-register-timeout

Greenkeeper badge Build Status JavaScript Style Guide

Register fastify plugin with a timeout

NB: this plugin is going to DEPRECATED because it suggests a bad approach.

Install

npm i --save fastify-register-timeout

Usage

Registering this plugin

fastify.register(require('fastify-register-timeout'), {
  timeout: 5000 // ms
})

to use like this

fastfiy.registerWithTimeout(require('some-async-plugin'))

NB: in case of timeout, an exception is thrown with the function name as message. This is mean that the anonymous function should not be used here!

Why

There're two reason for this plugin:

  • in some case you need to know if your external dependencies are reachable before starting your server.
  • during the test, you need to know which plugin fails