Socket
Socket
Sign inDemoInstall

avvio

Package Overview
Dependencies
Maintainers
2
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

avvio - npm Package Compare versions

Comparing version 7.2.2 to 8.0.0

lib/errors.js

32

boot.js

@@ -6,2 +6,9 @@ 'use strict'

const inherits = require('util').inherits
const {
AVV_ERR_EXPOSE_ALREADY_DEFINED,
AVV_ERR_CALLBACK_NOT_FN,
AVV_ERR_PLUGIN_NOT_VALID,
AVV_ERR_ROOT_PLG_BOOTED,
AVV_ERR_READY_TIMEOUT
} = require('./lib/errors')
const TimeTree = require('./time-tree')

@@ -22,11 +29,11 @@ const Plugin = require('./plugin')

if (server[useKey]) {
throw new Error(useKey + '() is already defined, specify an expose option')
throw new AVV_ERR_EXPOSE_ALREADY_DEFINED(useKey)
}
if (server[afterKey]) {
throw new Error(afterKey + '() is already defined, specify an expose option')
throw new AVV_ERR_EXPOSE_ALREADY_DEFINED(afterKey)
}
if (server[readyKey]) {
throw new Error(readyKey + '() is already defined, specify an expose option')
throw new AVV_ERR_EXPOSE_ALREADY_DEFINED(readyKey)
}

@@ -52,3 +59,3 @@

if (func && typeof func !== 'function') {
throw new Error('not a function')
throw new AVV_ERR_CALLBACK_NOT_FN(readyKey, typeof func)
}

@@ -60,3 +67,3 @@ return instance.ready(func ? encapsulateThreeParam(func, this) : undefined)

if (typeof func !== 'function') {
throw new Error('not a function')
throw new AVV_ERR_CALLBACK_NOT_FN(onCloseKey, typeof func)
}

@@ -69,3 +76,3 @@ instance.onClose(encapsulateTwoParam(func, this))

if (func && typeof func !== 'function') {
throw new Error('not a function')
throw new AVV_ERR_CALLBACK_NOT_FN(closeKey, typeof func)
}

@@ -205,3 +212,3 @@

if (!(plugin && (typeof plugin === 'function' || typeof plugin.then === 'function'))) {
throw new Error('plugin must be a function or a promise')
throw new AVV_ERR_PLUGIN_NOT_VALID(typeof plugin)
}

@@ -243,3 +250,3 @@ return plugin

if (this.booted) {
throw new Error('root plugin has already booted')
throw new AVV_ERR_ROOT_PLG_BOOTED()
}

@@ -259,3 +266,3 @@

if (current.loaded) {
throw new Error(`Impossible to load "${obj.name}" plugin because the parent "${current.name}" was already loaded`)
throw new Error(obj.name, current.name)
}

@@ -310,3 +317,3 @@

if (typeof func !== 'function') {
throw new Error('not a function')
throw new AVV_ERR_CALLBACK_NOT_FN('close', typeof func)
}

@@ -336,3 +343,3 @@ } else {

if (typeof func !== 'function') {
throw new Error('not a function')
throw new AVV_ERR_CALLBACK_NOT_FN('ready', typeof func)
}

@@ -449,4 +456,3 @@ this._readyQ.push(func)

timer = null
const toutErr = new Error(`ERR_AVVIO_READY_TIMEOUT: plugin did not start in time: ${name}. You may have forgotten to call 'done' function or to resolve a Promise`)
toutErr.code = 'ERR_AVVIO_READY_TIMEOUT'
const toutErr = new AVV_ERR_READY_TIMEOUT(name)
toutErr.fn = func

@@ -453,0 +459,0 @@ this._error = toutErr

{
"name": "avvio",
"version": "7.2.2",
"version": "8.0.0",
"description": "Asynchronous bootstrapping of Node applications",

@@ -34,3 +34,3 @@ "main": "boot.js",

"devDependencies": {
"@types/node": "^15.0.0",
"@types/node": "^16.0.0",
"express": "^4.17.1",

@@ -37,0 +37,0 @@ "pre-commit": "^1.2.2",

@@ -8,3 +8,3 @@ 'use strict'

const debug = require('debug')('avvio')
const CODE_PLUGIN_TIMEOUT = 'ERR_AVVIO_PLUGIN_TIMEOUT'
const { AVV_ERR_READY_TIMEOUT } = require('./lib/errors')

@@ -124,4 +124,3 @@ function getName (func) {

timer = null
const err = new Error(`${CODE_PLUGIN_TIMEOUT}: plugin did not start in time: ${name}. You may have forgotten to call 'done' function or to resolve a Promise`)
err.code = CODE_PLUGIN_TIMEOUT
const err = new AVV_ERR_READY_TIMEOUT(name)
err.fn = func

@@ -128,0 +127,0 @@ done(err)

@@ -57,3 +57,3 @@ 'use strict'

} catch (err) {
t.equal(err.message, 'root plugin has already booted')
t.equal(err.message, 'Root plugin has already booted')
}

@@ -60,0 +60,0 @@ }, 500)

@@ -54,3 +54,3 @@ 'use strict'

} catch (err) {
t.equal(err.message, key + '() is already defined, specify an expose option')
t.equal(err.message, `'${key}' () is already defined, specify an expose option`)
}

@@ -57,0 +57,0 @@ })

@@ -7,3 +7,3 @@ 'use strict'

const message = (code, name) => `${code}: plugin did not start in time: ${name}. You may have forgotten to call 'done' function or to resolve a Promise`
const message = (name) => `Plugin did not start in time: '${name}'. You may have forgotten to call 'done' function or to resolve a Promise`

@@ -22,4 +22,4 @@ test('timeout without calling next - callbacks', (t) => {

t.equal(err.fn, one)
t.equal(err.message, message('ERR_AVVIO_PLUGIN_TIMEOUT', 'one'))
t.equal(err.code, 'ERR_AVVIO_PLUGIN_TIMEOUT')
t.equal(err.message, message('one'))
t.equal(err.code, 'AVV_ERR_READY_TIMEOUT')
})

@@ -42,4 +42,4 @@ })

t.equal(err.fn, two)
t.equal(err.message, message('ERR_AVVIO_PLUGIN_TIMEOUT', 'two'))
t.equal(err.code, 'ERR_AVVIO_PLUGIN_TIMEOUT')
t.equal(err.message, message('two'))
t.equal(err.code, 'AVV_ERR_READY_TIMEOUT')
})

@@ -56,4 +56,4 @@ })

t.ok(err)
t.equal(err.message, message('ERR_AVVIO_PLUGIN_TIMEOUT', require.resolve('./fixtures/plugin-no-next')))
t.equal(err.code, 'ERR_AVVIO_PLUGIN_TIMEOUT')
t.equal(err.message, message(require.resolve('./fixtures/plugin-no-next')))
t.equal(err.code, 'AVV_ERR_READY_TIMEOUT')
})

@@ -73,4 +73,4 @@ })

t.ok(err)
t.equal(err.message, message('ERR_AVVIO_PLUGIN_TIMEOUT', 'function (app, opts, next) { -- // do not call next on purpose - code as name'))
t.equal(err.code, 'ERR_AVVIO_PLUGIN_TIMEOUT')
t.equal(err.message, message('function (app, opts, next) { -- // do not call next on purpose - code as name'))
t.equal(err.code, 'AVV_ERR_READY_TIMEOUT')
})

@@ -155,4 +155,4 @@ })

t.ok(err)
t.equal(err.message, message('ERR_AVVIO_READY_TIMEOUT', 'onReadyWithoutDone'))
t.equal(err.code, 'ERR_AVVIO_READY_TIMEOUT')
t.equal(err.message, message('onReadyWithoutDone'))
t.equal(err.code, 'AVV_ERR_READY_TIMEOUT')
// don't rethrow the error

@@ -175,4 +175,4 @@ })

t.ok(err)
t.equal(err.message, message('ERR_AVVIO_READY_TIMEOUT', 'onReadyWithoutDone'))
t.equal(err.code, 'ERR_AVVIO_READY_TIMEOUT')
t.equal(err.message, message('onReadyWithoutDone'))
t.equal(err.code, 'AVV_ERR_READY_TIMEOUT')
done(err)

@@ -199,4 +199,4 @@ })

t.ok(err)
t.equal(err.message, message('ERR_AVVIO_READY_TIMEOUT', 'onReadyWithoutDone'))
t.equal(err.code, 'ERR_AVVIO_READY_TIMEOUT')
t.equal(err.message, message('onReadyWithoutDone'))
t.equal(err.code, 'AVV_ERR_READY_TIMEOUT')
done(err)

@@ -203,0 +203,0 @@ })

Sorry, the diff of this file is not supported yet

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