-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: access handler name add properties to req route options (#4470)
* fix: 'Error' is not assignable to parameter of type 'null' * chore: add handler, schema and config to req.routeOptions * rollback not needed change * Update lib/request.js Co-authored-by: Manuel Spigolon <behemoth89@gmail.com> * chore: use deepFreeze Signed-off-by: cesarvspr <vinicius_spr@hotmail.com> * chore: use Object.defineProperty Signed-off-by: cesarvspr <vinicius_spr@hotmail.com> * chore: use defineProperties Signed-off-by: cesarvspr <vinicius_spr@hotmail.com> * chore: add tests Signed-off-by: cesarvspr <vinicius_spr@hotmail.com> * fix: test count exceeds plan Signed-off-by: cesarvspr <vinicius_spr@hotmail.com> * fix: test count exceeds plan Signed-off-by: cesarvspr <vinicius_spr@hotmail.com> * fix: add TODO Signed-off-by: cesarvspr <vinicius_spr@hotmail.com> * chore: review improvements * fix: proper warning codes * Update test/request.deprecated.test.js Co-authored-by: Manuel Spigolon <behemoth89@gmail.com> * Apply suggestions from code review * add documentation * add missing documentation * Update docs/Reference/Request.md Co-authored-by: Manuel Spigolon <behemoth89@gmail.com> --------- Signed-off-by: cesarvspr <vinicius_spr@hotmail.com> Co-authored-by: Manuel Spigolon <behemoth89@gmail.com> Co-authored-by: Frazer Smith <frazer.dev@outlook.com> Co-authored-by: Uzlopak <aras.abbasi@googlemail.com> Co-authored-by: Carlos Fuentes <me@metcoder.dev>
- Loading branch information
1 parent
7053ea7
commit 59050e5
Showing
5 changed files
with
77 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict' | ||
|
||
// Tests for some deprecated `request.*` keys. This file should be | ||
// removed when the deprecation is complete. | ||
|
||
process.removeAllListeners('warning') | ||
|
||
const test = require('tap').test | ||
const Fastify = require('../') | ||
|
||
test('Should expose router options via getters on request and reply', t => { | ||
t.plan(7) | ||
const fastify = Fastify() | ||
const expectedSchema = { | ||
params: { | ||
id: { type: 'integer' } | ||
} | ||
} | ||
|
||
fastify.get('/test/:id', { | ||
schema: expectedSchema | ||
}, (req, reply) => { | ||
t.equal(req.routeConfig.url, '/test/:id') | ||
t.equal(req.routeConfig.method, 'GET') | ||
t.same(req.routeSchema, expectedSchema) | ||
t.equal(req.routerPath, '/test/:id') | ||
t.equal(req.routerMethod, 'GET') | ||
reply.send() | ||
}) | ||
|
||
fastify.inject({ | ||
method: 'GET', | ||
url: '/test/123456789' | ||
}, (error, res) => { | ||
t.error(error) | ||
t.equal(res.statusCode, 200) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters