fastify 2.15.2 → 2.15.3
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/fastify.js +9 -2
- package/package.json +1 -1
- package/test/inject.test.js +15 -0
package/fastify.js
CHANGED
|
@@ -352,8 +352,15 @@ function build (options) {
|
|
|
352
352
|
else lightMyRequest(httpHandler, opts, cb)
|
|
353
353
|
})
|
|
354
354
|
} else {
|
|
355
|
-
return
|
|
356
|
-
.
|
|
355
|
+
return lightMyRequest((req, res) => {
|
|
356
|
+
this.ready(function (err) {
|
|
357
|
+
if (err) {
|
|
358
|
+
res.emit('error', err)
|
|
359
|
+
return
|
|
360
|
+
}
|
|
361
|
+
httpHandler(req, res)
|
|
362
|
+
})
|
|
363
|
+
}, opts)
|
|
357
364
|
}
|
|
358
365
|
}
|
|
359
366
|
|
package/package.json
CHANGED
package/test/inject.test.js
CHANGED
|
@@ -409,3 +409,18 @@ test('should throw error if callback specified and if ready errors', t => {
|
|
|
409
409
|
t.strictEqual(err, error)
|
|
410
410
|
})
|
|
411
411
|
})
|
|
412
|
+
|
|
413
|
+
test('should support builder-style injection with non-ready app', (t) => {
|
|
414
|
+
t.plan(3)
|
|
415
|
+
const fastify = Fastify()
|
|
416
|
+
const payload = { hello: 'world' }
|
|
417
|
+
|
|
418
|
+
fastify.get('/', (req, reply) => {
|
|
419
|
+
reply.send(payload)
|
|
420
|
+
})
|
|
421
|
+
fastify.inject().get('/').end().then((res) => {
|
|
422
|
+
t.deepEqual(payload, JSON.parse(res.payload))
|
|
423
|
+
t.strictEqual(res.statusCode, 200)
|
|
424
|
+
t.strictEqual(res.headers['content-length'], '17')
|
|
425
|
+
})
|
|
426
|
+
})
|