Aktueller Stand

This commit is contained in:
2026-01-22 19:05:45 +01:00
parent 85dee61a4d
commit e280e4eadb
1967 changed files with 397327 additions and 74093 deletions

View File

@@ -17,8 +17,8 @@ on:
jobs:
test:
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v4.2.1
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v5.0.0
with:
lint: true
license-check: true
node-versions: '["14", "16", "18", "20", "21", "22"]'
node-versions: '["20", "22"]'

8
backend/node_modules/avvio/.taprc generated vendored
View File

@@ -1,7 +1,3 @@
ts: false
jsx: false
flow: false
check-coverage: false
allow-incomplete-coverage: true
files:
- test/**/*test.js
- test/**/*test.js

28
backend/node_modules/avvio/README.md generated vendored
View File

@@ -83,7 +83,6 @@ async function third (instance, opts) {
* <a href="#override"><code>instance.<b>override()</b></code></a>
* <a href="#onClose"><code>instance.<b>onClose()</b></code></a>
* <a href="#close"><code>instance.<b>close()</b></code></a>
* <a href="#express"><code>avvio.<b>express()</b></code></a>
* <a href="#toJSON"><code>avvio.<b>toJSON()</b></code></a>
* <a href="#prettyPrint"><code>avvio.<b>prettyPrint()</b></code></a>
@@ -152,8 +151,6 @@ Loads one or more functions asynchronously.
The function **must** have the signature: `instance, options, done`
However, if the function returns a `Promise` (i.e. `async`), the above function signature is not required.
Plugin example:
```js
function plugin (server, opts, done) {
@@ -162,8 +159,11 @@ function plugin (server, opts, done) {
app.use(plugin)
```
`done` should be called only once, when your plugin is ready to go. Additional
calls to `done` are ignored.
`done` should be called only once, when your plugin is ready to go. Additional calls to `done` are ignored.
If your plugin is ready to go immediately after the function is evaluated, you can omit `done` from the signature.
If the function returns a `Promise` (i.e. `async`), the above function signature is not required.
`use` returns a thenable wrapped instance on which `use` is called, to support a chainable API that can also be awaited.
@@ -444,24 +444,6 @@ also start the boot sequence.
Start the boot sequence, if it was not started yet.
Returns the `app` instance.
-------------------------------------------------------
<a name="express"></a>
### avvio.express(app)
Same as:
```js
const app = express()
const avvio = require('avvio')
avvio(app, {
expose: {
use: 'load'
}
})
```
-------------------------------------------------------
<a name="override"></a>

7
backend/node_modules/avvio/boot.js generated vendored
View File

@@ -605,10 +605,3 @@ function encapsulateThreeParam (func, that) {
}
module.exports = Boot
module.exports.express = function (app) {
return Boot(app, {
expose: {
use: 'load'
}
})
}

View File

@@ -130,6 +130,8 @@ Plugin.prototype.exec = function (server, callback) {
maybePromiseLike.then(
() => process.nextTick(done),
(e) => process.nextTick(done, e))
} else if (func.length < 3) {
done()
}
}

View File

@@ -1,2 +0,0 @@
# Set default behavior to automatically convert line endings
* text=auto eol=lf

View File

@@ -1,13 +0,0 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
open-pull-requests-limit: 10
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10

View File

@@ -1,23 +0,0 @@
name: CI
on:
push:
branches:
- main
- master
- next
- 'v*'
paths-ignore:
- 'docs/**'
- '*.md'
pull_request:
paths-ignore:
- 'docs/**'
- '*.md'
jobs:
test:
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3
with:
license-check: true
lint: true

View File

@@ -1,2 +0,0 @@
files:
- test/**/*.test.js

View File

@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2020 Fastify
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,62 +0,0 @@
# @fastify/error
![CI](https://github.com/fastify/fastify-error/workflows/CI/badge.svg)
[![NPM version](https://img.shields.io/npm/v/@fastify/error.svg?style=flat)](https://www.npmjs.com/package/@fastify/error)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
A small utility, used by Fastify itself, for generating consistent error objects across your codebase and plugins.
### Install
```
npm i @fastify/error
```
### Usage
The module exports a function that you can use for consistent error objects, it takes 4 parameters:
```
createError(code, message [, statusCode [, Base]])
```
- `code` (`string`, required) - The error code, you can access it later with `error.code`. For consistency, we recommend prefixing plugin error codes with `FST_`
- `message` (`string`, required) - The error message. You can also use interpolated strings for formatting the message.
- `statusCode` (`number`, optional) - The status code that Fastify will use if the error is sent via HTTP.
- `Base` (`ErrorConstructor`, optional) - The base error object that will be used. (eg `TypeError`, `RangeError`)
```js
const createError = require('@fastify/error')
const CustomError = createError('ERROR_CODE', 'Hello')
console.log(new CustomError()) // error.message => 'Hello'
```
How to use an interpolated string:
```js
const createError = require('@fastify/error')
const CustomError = createError('ERROR_CODE', 'Hello %s')
console.log(new CustomError('world')) // error.message => 'Hello world'
```
How to add cause:
```js
const createError = require('@fastify/error')
const CustomError = createError('ERROR_CODE', 'Hello %s')
console.log(new CustomError('world', {cause: new Error('cause')}))
// error.message => 'Hello world'
// error.cause => Error('cause')
```
### TypeScript
It is possible to limit your error constructor with a generic type using TypeScript:
```ts
const CustomError = createError<[string]>('ERROR_CODE', 'Hello %s')
new CustomError('world')
//@ts-expect-error
new CustomError(1)
```
## License
Licensed under [MIT](./LICENSE).

View File

@@ -1,9 +0,0 @@
'use strict'
const benchmark = require('benchmark')
const createError = require('..')
new benchmark.Suite()
.add('create FastifyError', function () { createError('CODE', 'Not available') }, { minSamples: 100 })
.on('cycle', function onCycle (event) { console.log(String(event.target)) })
.run({ async: false })

View File

@@ -1,18 +0,0 @@
'use strict'
const benchmark = require('benchmark')
const createError = require('..')
const FastifyError = createError('CODE', 'Not available')
const FastifyError1 = createError('CODE', 'Not %s available')
const FastifyError2 = createError('CODE', 'Not %s available %s')
const cause = new Error('cause')
new benchmark.Suite()
.add('instantiate Error', function () { new Error() }, { minSamples: 100 }) // eslint-disable-line no-new
.add('instantiate FastifyError', function () { new FastifyError() }, { minSamples: 100 }) // eslint-disable-line no-new
.add('instantiate FastifyError arg 1', function () { new FastifyError1('q') }, { minSamples: 100 }) // eslint-disable-line no-new
.add('instantiate FastifyError arg 2', function () { new FastifyError2('qq', 'ss') }, { minSamples: 100 }) // eslint-disable-line no-new
.add('instantiate FastifyError cause', function () { new FastifyError2({ cause }) }, { minSamples: 100 }) // eslint-disable-line no-new
.on('cycle', function onCycle (event) { console.log(String(event.target)) })
.run({ async: false })

View File

@@ -1,13 +0,0 @@
'use strict'
const benchmark = require('benchmark')
const createError = require('..')
const FastifyError = createError('CODE', 'Not available')
Error.stackTraceLimit = 0
new benchmark.Suite()
.add('no-stack instantiate Error', function () { new Error() }, { minSamples: 100 }) // eslint-disable-line no-new
.add('no-stack instantiate FastifyError', function () { new FastifyError() }, { minSamples: 100 }) // eslint-disable-line no-new
.on('cycle', function onCycle (event) { console.log(String(event.target)) })
.run({ async: false })

View File

@@ -1,11 +0,0 @@
'use strict'
const benchmark = require('benchmark')
const createError = require('..')
const FastifyError = createError('CODE', 'Not available')
new benchmark.Suite()
.add('FastifyError toString', function () { new FastifyError().toString() }, { minSamples: 100 })
.on('cycle', function onCycle (event) { console.log(String(event.target)) })
.run({ async: false })

View File

@@ -1,53 +0,0 @@
'use strict'
const { format } = require('node:util')
function toString () {
return `${this.name} [${this.code}]: ${this.message}`
}
function createError (code, message, statusCode = 500, Base = Error) {
if (!code) throw new Error('Fastify error code must not be empty')
if (!message) throw new Error('Fastify error message must not be empty')
code = code.toUpperCase()
!statusCode && (statusCode = undefined)
function FastifyError (...args) {
if (!new.target) {
return new FastifyError(...args)
}
this.code = code
this.name = 'FastifyError'
this.statusCode = statusCode
const lastElement = args.length - 1
if (lastElement !== -1 && args[lastElement] && typeof args[lastElement] === 'object' && 'cause' in args[lastElement]) {
this.cause = args.pop().cause
}
this.message = format(message, ...args)
Error.stackTraceLimit !== 0 && Error.captureStackTrace(this, FastifyError)
}
FastifyError.prototype = Object.create(Base.prototype, {
constructor: {
value: FastifyError,
enumerable: false,
writable: true,
configurable: true
}
})
FastifyError.prototype[Symbol.toStringTag] = 'Error'
FastifyError.prototype.toString = toString
return FastifyError
}
module.exports = createError
module.exports.default = createError
module.exports.createError = createError

View File

@@ -1,45 +0,0 @@
{
"name": "@fastify/error",
"version": "3.4.1",
"description": "A small utility, used by Fastify itself, for generating consistent error objects across your codebase and plugins.",
"main": "index.js",
"type": "commonjs",
"types": "types/index.d.ts",
"scripts": {
"lint": "standard",
"lint:fix": "standard --fix",
"test": "npm run test:unit && npm run test:typescript",
"test:unit": "tap",
"test:typescript": "tsd"
},
"repository": {
"type": "git",
"url": "git+https://github.com/fastify/fastify-error.git"
},
"keywords": [
"fastify",
"error",
"utility",
"plugin"
],
"author": "Tomas Della Vedova",
"license": "MIT",
"bugs": {
"url": "https://github.com/fastify/fastify-error/issues"
},
"homepage": "https://github.com/fastify/fastify-error#readme",
"devDependencies": {
"benchmark": "^2.1.4",
"standard": "^17.0.0",
"tap": "^16.0.0",
"tsd": "^0.29.0"
},
"tsd": {
"compilerOptions": {
"esModuleInterop": true
}
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -1,184 +0,0 @@
'use strict'
const { test } = require('tap')
const createError = require('..')
test('Create error with zero parameter', t => {
t.plan(6)
const NewError = createError('CODE', 'Not available')
const err = new NewError()
t.ok(err instanceof Error)
t.equal(err.name, 'FastifyError')
t.equal(err.message, 'Not available')
t.equal(err.code, 'CODE')
t.equal(err.statusCode, 500)
t.ok(err.stack)
})
test('Create error with 1 parameter', t => {
t.plan(6)
const NewError = createError('CODE', 'hey %s')
const err = new NewError('alice')
t.ok(err instanceof Error)
t.equal(err.name, 'FastifyError')
t.equal(err.message, 'hey alice')
t.equal(err.code, 'CODE')
t.equal(err.statusCode, 500)
t.ok(err.stack)
})
test('Create error with 1 parameter set to undefined', t => {
t.plan(1)
const NewError = createError('CODE', 'hey %s')
const err = new NewError(undefined)
t.equal(err.message, 'hey undefined')
})
test('Create error with 2 parameters', (t) => {
t.plan(6)
const NewError = createError('CODE', 'hey %s, I like your %s')
const err = new NewError('alice', 'attitude')
t.ok(err instanceof Error)
t.equal(err.name, 'FastifyError')
t.equal(err.message, 'hey alice, I like your attitude')
t.equal(err.code, 'CODE')
t.equal(err.statusCode, 500)
t.ok(err.stack)
})
test('Create error with 2 parameters set to undefined', t => {
t.plan(1)
const NewError = createError('CODE', 'hey %s, I like your %s')
const err = new NewError(undefined, undefined)
t.equal(err.message, 'hey undefined, I like your undefined')
})
test('Create error with 3 parameters', t => {
t.plan(6)
const NewError = createError('CODE', 'hey %s, I like your %s %s')
const err = new NewError('alice', 'attitude', 'see you')
t.ok(err instanceof Error)
t.equal(err.name, 'FastifyError')
t.equal(err.message, 'hey alice, I like your attitude see you')
t.equal(err.code, 'CODE')
t.equal(err.statusCode, 500)
t.ok(err.stack)
})
test('Create error with 3 parameters set to undefined', t => {
t.plan(4)
const NewError = createError('CODE', 'hey %s, I like your %s %s')
const err = new NewError(undefined, undefined, undefined)
t.equal(err.message, 'hey undefined, I like your undefined undefined')
t.equal(err.code, 'CODE')
t.equal(err.statusCode, 500)
t.ok(err.stack)
})
test('Create error with 4 parameters set to undefined', t => {
t.plan(4)
const NewError = createError('CODE', 'hey %s, I like your %s %s and %s')
const err = new NewError(undefined, undefined, undefined, undefined)
t.equal(err.message, 'hey undefined, I like your undefined undefined and undefined')
t.equal(err.code, 'CODE')
t.equal(err.statusCode, 500)
t.ok(err.stack)
})
test('Create error with no statusCode property', t => {
t.plan(6)
const NewError = createError('CODE', 'hey %s', 0)
const err = new NewError('dude')
t.ok(err instanceof Error)
t.equal(err.name, 'FastifyError')
t.equal(err.message, 'hey dude')
t.equal(err.code, 'CODE')
t.equal(err.statusCode, undefined)
t.ok(err.stack)
})
test('Should throw when error code has no fastify code', t => {
t.plan(1)
t.throws(() => createError(), new Error('Fastify error code must not be empty'))
})
test('Should throw when error code has no message', t => {
t.plan(1)
t.throws(() => createError('code'), new Error('Fastify error message must not be empty'))
})
test('Create error with different base', t => {
t.plan(7)
const NewError = createError('CODE', 'hey %s', 500, TypeError)
const err = new NewError('dude')
t.ok(err instanceof Error)
t.ok(err instanceof TypeError)
t.equal(err.name, 'FastifyError')
t.equal(err.message, 'hey dude')
t.equal(err.code, 'CODE')
t.equal(err.statusCode, 500)
t.ok(err.stack)
})
test('FastifyError.toString returns code', t => {
t.plan(1)
const NewError = createError('CODE', 'foo')
const err = new NewError()
t.equal(err.toString(), 'FastifyError [CODE]: foo')
})
test('Create the error without the new keyword', t => {
t.plan(6)
const NewError = createError('CODE', 'Not available')
const err = NewError()
t.ok(err instanceof Error)
t.equal(err.name, 'FastifyError')
t.equal(err.message, 'Not available')
t.equal(err.code, 'CODE')
t.equal(err.statusCode, 500)
t.ok(err.stack)
})
test('Create an error with cause', t => {
t.plan(2)
const cause = new Error('HEY')
const NewError = createError('CODE', 'Not available')
const err = NewError({ cause })
t.ok(err instanceof Error)
t.equal(err.cause, cause)
})
test('Create an error with cause and message', t => {
t.plan(2)
const cause = new Error('HEY')
const NewError = createError('CODE', 'Not available: %s')
const err = NewError('foo', { cause })
t.ok(err instanceof Error)
t.equal(err.cause, cause)
})
test('Create an error with last argument null', t => {
t.plan(2)
const cause = new Error('HEY')
const NewError = createError('CODE', 'Not available')
const err = NewError({ cause }, null)
t.ok(err instanceof Error)
t.notOk(err.cause)
})

View File

@@ -1,44 +0,0 @@
declare function createError<C extends string, SC extends number, Arg extends unknown[] = [any?, any?, any?]> (
code: C,
message: string,
statusCode: SC,
Base?: ErrorConstructor
): createError.FastifyErrorConstructor<{ code: C, statusCode: SC }, Arg>
declare function createError<C extends string, Arg extends unknown[] = [any?, any?, any?]> (
code: C,
message: string,
statusCode?: number,
Base?: ErrorConstructor
): createError.FastifyErrorConstructor<{ code: C }, Arg>
declare function createError<Arg extends unknown[] = [any?, any?, any?]> (
code: string,
message: string,
statusCode?: number,
Base?: ErrorConstructor
): createError.FastifyErrorConstructor<{ code: string }, Arg>
type CreateError = typeof createError
declare namespace createError {
export interface FastifyError extends Error {
code: string
name: string
statusCode?: number
}
export interface FastifyErrorConstructor<
E extends { code: string, statusCode?: number } = { code: string, statusCode?: number },
T extends unknown[] = [any?, any?, any?]
> {
new(...arg: T): FastifyError & E
(...arg: T): FastifyError & E
readonly prototype: FastifyError & E
}
export const createError: CreateError
export { createError as default }
}
export = createError

View File

@@ -1,72 +0,0 @@
import createError, { FastifyError, FastifyErrorConstructor } from '..'
import { expectType, expectError } from 'tsd'
const CustomError = createError('ERROR_CODE', 'message')
expectType<FastifyErrorConstructor<{ code: 'ERROR_CODE' }>>(CustomError)
const err = new CustomError()
expectType<FastifyError & { code: 'ERROR_CODE' }>(err)
expectType<'ERROR_CODE'>(err.code)
expectType<string>(err.message)
expectType<number | undefined>(err.statusCode)
const CustomTypedError = createError('OTHER_CODE', 'message', 400)
expectType<FastifyErrorConstructor<{ code: 'OTHER_CODE', statusCode: 400 }>>(CustomTypedError)
const typed = new CustomTypedError()
expectType<FastifyError & { code: 'OTHER_CODE', statusCode: 400 }>(typed)
expectType<'OTHER_CODE'>(typed.code)
expectType<string>(typed.message)
expectType<400>(typed.statusCode)
/* eslint-disable no-new */
const CustomTypedArgError = createError<[string]>('OTHER_CODE', 'expect %s message', 400)
CustomTypedArgError('a')
expectError(CustomTypedArgError('a', 'b'))
expectError(new CustomTypedArgError('a', 'b'))
expectError(CustomTypedArgError(1))
expectError(new CustomTypedArgError(1))
const CustomTypedArgError2 = createError<string, number, [string]>('OTHER_CODE', 'expect %s message', 400)
CustomTypedArgError2('a')
expectError(CustomTypedArgError2('a', 'b'))
expectError(new CustomTypedArgError2('a', 'b'))
expectError(CustomTypedArgError2(1))
expectError(new CustomTypedArgError2(1))
const CustomTypedArgError3 = createError<string, number, [string, string]>('OTHER_CODE', 'expect %s message but got %s', 400)
expectError(CustomTypedArgError3('a'))
CustomTypedArgError3('a', 'b')
new CustomTypedArgError3('a', 'b')
expectError(CustomTypedArgError3(1))
expectError(new CustomTypedArgError3(1))
expectError(new CustomTypedArgError3(1, 2))
expectError(new CustomTypedArgError3('1', 2))
expectError(new CustomTypedArgError3(1, '2'))
const CustomTypedArgError4 = createError<string, number, [string, string]>('OTHER_CODE', 'expect %s message but got %s', 400)
expectError(CustomTypedArgError4('a'))
CustomTypedArgError4('a', 'b')
new CustomTypedArgError4('a', 'b')
expectError(CustomTypedArgError4(1))
expectError(new CustomTypedArgError4(1))
expectError(new CustomTypedArgError4(1, 2))
expectError(new CustomTypedArgError4('1', 2))
expectError(new CustomTypedArgError4(1, '2'))
const CustomTypedArgError5 = createError<[string, string, string, string]>('OTHER_CODE', 'expect %s message but got %s. Please contact %s by emailing to %s', 400)
expectError(CustomTypedArgError5('a'))
expectError(new CustomTypedArgError5('a', 'b'))
expectError(new CustomTypedArgError5('a', 'b', 'c'))
CustomTypedArgError5('a', 'b', 'c', 'd')
expectError(new CustomTypedArgError5('a', 'b', 'c', 'd', 'e'))
const CustomTypedArgError6 = createError<string, number, [string, string, string, string]>('OTHER_CODE', 'expect %s message but got %s. Please contact %s by emailing to %s', 400)
expectError(CustomTypedArgError6('a'))
expectError(new CustomTypedArgError6('a', 'b'))
expectError(new CustomTypedArgError6('a', 'b', 'c'))
CustomTypedArgError6('a', 'b', 'c', 'd')
expectError(new CustomTypedArgError6('a', 'b', 'c', 'd', 'e'))
const CustomErrorWithErrorConstructor = createError('ERROR_CODE', 'message', 500, TypeError)
expectType<FastifyErrorConstructor<{ code: 'ERROR_CODE', statusCode: 500 }>>(CustomErrorWithErrorConstructor)
CustomErrorWithErrorConstructor({cause: new Error('Error')})

View File

@@ -1,6 +1,6 @@
{
"name": "avvio",
"version": "8.4.0",
"version": "9.1.0",
"description": "Asynchronous bootstrapping of Node applications",
"main": "boot.js",
"type": "commonjs",
@@ -38,15 +38,14 @@
},
"homepage": "https://github.com/fastify/avvio#readme",
"devDependencies": {
"@fastify/pre-commit": "^2.0.2",
"@types/node": "^20.1.0",
"express": "^4.17.1",
"standard": "^17.0.0",
"tap": "^16.0.0",
"typescript": "^5.0.2"
"@fastify/pre-commit": "^2.1.0",
"@types/node": "^22.0.0",
"standard": "^17.1.0",
"tap": "^18.7.1",
"typescript": "^5.4.2"
},
"dependencies": {
"@fastify/error": "^3.3.0",
"@fastify/error": "^4.0.0",
"fastq": "^1.17.1"
}
}

View File

@@ -1,52 +0,0 @@
'use strict'
const { test } = require('tap')
const express = require('express')
const http = require('node:http')
const boot = require('..')
test('express support', (t) => {
const app = express()
boot.express(app)
// It does:
//
// boot(app, {
// expose: {
// use: 'load'
// }
// })
t.plan(2)
let loaded = false
let server
app.load(function (app, opts, done) {
loaded = true
app.use(function (req, res) {
res.end('hello world')
})
done()
})
app.after((cb) => {
t.ok(loaded, 'plugin loaded')
server = app.listen(0, cb)
t.teardown(server.close.bind(server))
})
app.ready(() => {
http.get(`http://localhost:${server.address().port}`).on('response', function (res) {
let data = ''
res.on('data', function (chunk) {
data += chunk
})
res.on('end', function () {
t.equal(data, 'hello world')
})
})
})
})

View File

@@ -1,6 +1,6 @@
'use strict'
const { test, mock } = require('tap')
const { test, mockRequire } = require('tap')
const { kThenifyDoNotWrap } = require('../../lib/symbols')
test('thenify', (t) => {
@@ -9,7 +9,7 @@ test('thenify', (t) => {
t.test('return undefined if booted', (t) => {
t.plan(2)
const { thenify } = mock('../../lib/thenify', {
const { thenify } = mockRequire('../../lib/thenify', {
'../../lib/debug': {
debug: (message) => { t.equal(message, 'thenify returning undefined because we are already booted') }
}
@@ -33,7 +33,7 @@ test('thenify', (t) => {
t.test('return PromiseConstructorLike if kThenifyDoNotWrap is false', (t) => {
t.plan(3)
const { thenify } = mock('../../lib/thenify', {
const { thenify } = mockRequire('../../lib/thenify', {
'../../lib/debug': {
debug: (message) => { t.equal(message, 'thenify') }
}
@@ -49,7 +49,7 @@ test('thenify', (t) => {
t.test('return PromiseConstructorLike', (t) => {
t.plan(3)
const { thenify } = mock('../../lib/thenify', {
const { thenify } = mockRequire('../../lib/thenify', {
'../../lib/debug': {
debug: (message) => { t.equal(message, 'thenify') }
}

View File

@@ -31,6 +31,17 @@ test('catch an error when loading a plugin with sync function', (t) => {
})
})
test('successfully load a plugin with sync function without done as a parameter', (t) => {
t.plan(1)
const app = boot({})
const plugin = new Plugin(fastq(app, app._loadPluginNextTick, 1), function (instance, opts) { }, false, 0)
app._loadPlugin(plugin, function (err) {
t.equal(err, undefined)
})
})
test('successfully load a plugin with async function', (t) => {
t.plan(1)
const app = boot({})

18
backend/node_modules/avvio/test/no-done.test.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
'use strict'
const { test } = require('tap')
const boot = require('..')
test('not taking done does not throw error.', (t) => {
t.plan(2)
const app = boot()
app.use(noDone).ready((err) => {
t.notOk(err, 'no error')
})
function noDone (s, opts) {
t.pass('did not throw')
}
})