fastify 3.9.2 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GOVERNANCE.md +1 -1
- package/README.md +12 -8
- package/SECURITY.md +3 -3
- package/docs/ContentTypeParser.md +1 -1
- package/docs/Ecosystem.md +16 -6
- package/docs/Encapsulation.md +5 -2
- package/docs/Fluent-Schema.md +4 -4
- package/docs/Getting-Started.md +1 -1
- package/docs/Hooks.md +28 -1
- package/docs/Lifecycle.md +8 -1
- package/docs/Middleware.md +5 -4
- package/docs/Reply.md +13 -4
- package/docs/Routes.md +4 -3
- package/docs/Server.md +78 -4
- package/docs/Serverless.md +23 -51
- package/docs/TypeScript.md +35 -18
- package/docs/Validation-and-Serialization.md +4 -4
- package/docs/Write-Plugin.md +4 -4
- package/examples/hooks-benchmark.js +12 -12
- package/examples/hooks.js +16 -16
- package/examples/plugin.js +2 -2
- package/examples/route-prefix.js +4 -4
- package/fastify.d.ts +16 -1
- package/fastify.js +33 -16
- package/isolate-0x426d1e0-1227-v8.log +4019 -0
- package/isolate-0x4d4c7e0-1988-v8.log +4081 -0
- package/lib/errors.js +6 -0
- package/lib/headRoute.js +31 -0
- package/lib/pluginOverride.js +5 -5
- package/lib/pluginUtils.js +7 -6
- package/lib/reply.js +14 -2
- package/lib/reqIdGenFactory.js +5 -0
- package/lib/request.js +1 -1
- package/lib/route.js +66 -41
- package/lib/schema-compilers.js +5 -3
- package/lib/schema-controller.js +106 -0
- package/lib/schemas.js +14 -24
- package/lib/server.js +1 -0
- package/lib/symbols.js +1 -3
- package/lib/warnings.js +2 -0
- package/lib/wrapThenable.js +2 -1
- package/package.json +25 -21
- package/test/404s.test.js +120 -120
- package/test/500s.test.js +8 -8
- package/test/async-await.test.js +29 -1
- package/test/close.test.js +8 -8
- package/test/context-config.test.js +52 -0
- package/test/custom-parser.test.js +8 -8
- package/test/decorator.test.js +49 -49
- package/test/default-route.test.js +43 -0
- package/test/fastify-instance.test.js +2 -2
- package/test/fluent-schema.test.js +3 -3
- package/test/handler-context.test.js +2 -2
- package/test/hooks-async.test.js +3 -3
- package/test/hooks.on-ready.test.js +12 -12
- package/test/hooks.test.js +75 -32
- package/test/http2/closing.test.js +23 -1
- package/test/inject.test.js +6 -6
- package/test/input-validation.js +2 -2
- package/test/internals/hookRunner.test.js +50 -50
- package/test/internals/reply.test.js +47 -22
- package/test/internals/request.test.js +3 -9
- package/test/internals/version.test.js +2 -2
- package/test/logger.test.js +30 -30
- package/test/middleware.test.js +4 -4
- package/test/plugin.helper.js +2 -2
- package/test/plugin.test.js +154 -99
- package/test/register.test.js +11 -11
- package/test/request-error.test.js +2 -2
- package/test/route-hooks.test.js +24 -24
- package/test/route-prefix.test.js +81 -52
- package/test/route.test.js +568 -0
- package/test/schema-feature.test.js +168 -38
- package/test/schema-serialization.test.js +4 -4
- package/test/schema-special-usage.test.js +136 -0
- package/test/schema-validation.test.js +7 -7
- package/test/skip-reply-send.test.js +315 -0
- package/test/stream.test.js +6 -6
- package/test/throw.test.js +4 -4
- package/test/types/instance.test-d.ts +5 -3
- package/test/types/plugin.test-d.ts +7 -7
- package/test/types/reply.test-d.ts +1 -0
- package/test/types/schema.test-d.ts +15 -0
- package/test/validation-error-handling.test.js +5 -5
- package/test/versioned-routes.test.js +1 -1
- package/types/content-type-parser.d.ts +1 -1
- package/types/instance.d.ts +6 -3
- package/types/plugin.d.ts +1 -1
- package/types/reply.d.ts +1 -0
- package/types/route.d.ts +8 -2
- package/types/schema.d.ts +3 -0
- package/test/skip-reply-send.js +0 -98
package/test/skip-reply-send.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { test } = require('tap')
|
|
4
|
-
const split = require('split2')
|
|
5
|
-
const Fastify = require('..')
|
|
6
|
-
|
|
7
|
-
test('skip automatic reply.send() with reply.sent = true and a body', (t) => {
|
|
8
|
-
const stream = split(JSON.parse)
|
|
9
|
-
const app = Fastify({
|
|
10
|
-
logger: {
|
|
11
|
-
stream: stream
|
|
12
|
-
}
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
stream.on('data', (line) => {
|
|
16
|
-
t.notEqual(line.level, 40) // there are no errors
|
|
17
|
-
t.notEqual(line.level, 50) // there are no errors
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
app.get('/', (req, reply) => {
|
|
21
|
-
reply.sent = true
|
|
22
|
-
reply.raw.end('hello world')
|
|
23
|
-
|
|
24
|
-
return Promise.resolve('this will be skipped')
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
return app.inject({
|
|
28
|
-
method: 'GET',
|
|
29
|
-
url: '/'
|
|
30
|
-
}).then((res) => {
|
|
31
|
-
t.equal(res.statusCode, 200)
|
|
32
|
-
t.equal(res.body, 'hello world')
|
|
33
|
-
})
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
test('skip automatic reply.send() with reply.sent = true and no body', (t) => {
|
|
37
|
-
const stream = split(JSON.parse)
|
|
38
|
-
const app = Fastify({
|
|
39
|
-
logger: {
|
|
40
|
-
stream: stream
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
stream.on('data', (line) => {
|
|
45
|
-
t.notEqual(line.level, 40) // there are no error
|
|
46
|
-
t.notEqual(line.level, 50) // there are no error
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
app.get('/', (req, reply) => {
|
|
50
|
-
reply.sent = true
|
|
51
|
-
reply.raw.end('hello world')
|
|
52
|
-
|
|
53
|
-
return Promise.resolve()
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
return app.inject({
|
|
57
|
-
method: 'GET',
|
|
58
|
-
url: '/'
|
|
59
|
-
}).then((res) => {
|
|
60
|
-
t.equal(res.statusCode, 200)
|
|
61
|
-
t.equal(res.body, 'hello world')
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
test('skip automatic reply.send() with reply.sent = true and an error', (t) => {
|
|
66
|
-
const stream = split(JSON.parse)
|
|
67
|
-
const app = Fastify({
|
|
68
|
-
logger: {
|
|
69
|
-
stream: stream
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
let errorSeen = false
|
|
74
|
-
|
|
75
|
-
stream.on('data', (line) => {
|
|
76
|
-
if (line.level === 50) {
|
|
77
|
-
errorSeen = true
|
|
78
|
-
t.equal(line.err.message, 'kaboom')
|
|
79
|
-
t.equal(line.msg, 'Promise errored, but reply.sent = true was set')
|
|
80
|
-
}
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
app.get('/', (req, reply) => {
|
|
84
|
-
reply.sent = true
|
|
85
|
-
reply.raw.end('hello world')
|
|
86
|
-
|
|
87
|
-
return Promise.reject(new Error('kaboom'))
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
return app.inject({
|
|
91
|
-
method: 'GET',
|
|
92
|
-
url: '/'
|
|
93
|
-
}).then((res) => {
|
|
94
|
-
t.equal(errorSeen, true)
|
|
95
|
-
t.equal(res.statusCode, 200)
|
|
96
|
-
t.equal(res.body, 'hello world')
|
|
97
|
-
})
|
|
98
|
-
})
|