middie
Advanced tools
Comparing version 6.0.0 to 6.1.0
@@ -80,3 +80,3 @@ 'use strict' | ||
if (res.finished === true) { | ||
if (res.finished === true || res.writableEnded === true) { | ||
that.req = null | ||
@@ -83,0 +83,0 @@ that.res = null |
'use strict' | ||
const fp = require('fastify-plugin') | ||
const symbols = require('fastify/lib/symbols') | ||
const Middie = require('./engine') | ||
@@ -20,3 +19,3 @@ const kMiddlewares = Symbol('fastify-middie-middlewares') | ||
if (typeof path === 'string') { | ||
const prefix = this[symbols.kRoutePrefix] | ||
const prefix = this.prefix | ||
path = prefix + (path === '/' && prefix.length > 0 ? '' : path) | ||
@@ -23,0 +22,0 @@ } |
{ | ||
"name": "middie", | ||
"version": "6.0.0", | ||
"version": "6.1.0", | ||
"description": "Middleware engine for Fastify", | ||
@@ -42,6 +42,6 @@ "main": "index.js", | ||
"simple-get": "^4.0.0", | ||
"standard": "^16.0.1", | ||
"tap": "^15.0.1", | ||
"tsd": "^0.19.0", | ||
"typescript": "4.5.4" | ||
"standard": "^17.0.0", | ||
"tap": "^16.0.0", | ||
"tsd": "^0.20.0", | ||
"typescript": "4.6.4" | ||
}, | ||
@@ -48,0 +48,0 @@ "dependencies": { |
@@ -72,3 +72,3 @@ # middie | ||
__Every registered middleware will be run during the `onRequest` hook phase__, so the registration order is important. | ||
Take a look at the [Lifecycle](https://www.fastify.io/docs/latest/Lifecycle/) documentation page to understand better how every request is executed. | ||
Take a look at the [Lifecycle](https://www.fastify.io/docs/latest/Reference/Lifecycle/) documentation page to understand better how every request is executed. | ||
@@ -100,3 +100,3 @@ ```js | ||
*Note you can access `req.body` from the `preValidation` lifecycle step onwards. Take a look at the [Lifecycle](https://www.fastify.io/docs/latest/Lifecycle/) documentation page to see the order of the steps.* | ||
*Note you can access `req.body` from the `preValidation` lifecycle step onwards. Take a look at the [Lifecycle](https://www.fastify.io/docs/latest/Reference/Lifecycle/) documentation page to see the order of the steps.* | ||
@@ -103,0 +103,0 @@ ```js |
@@ -470,3 +470,3 @@ 'use strict' | ||
test('if the function calls res.end the iterator should stop', t => { | ||
test('if the function calls res.end the iterator should stop / 1 (with deprecated finished flag)', t => { | ||
t.plan(1) | ||
@@ -499,1 +499,23 @@ | ||
}) | ||
test('if the function calls res.end the iterator should stop / 2', t => { | ||
t.plan(0) | ||
const instance = middie(function () { | ||
t.fail('we should not be here') | ||
}) | ||
const req = new http.IncomingMessage(null) | ||
req.url = '/test' | ||
const res = new http.ServerResponse(req) | ||
instance | ||
.use(function (req, res, next) { | ||
res.end('bye') | ||
next() | ||
}) | ||
.use(function (req, res, next) { | ||
t.fail('we should not be here') | ||
}) | ||
instance.run(req, res) | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
61544
1926