Skip to content

Commit 500c9a1

Browse files
committed
Migrate deprecation warnings to actual deprecation warnings
1 parent bc5df03 commit 500c9a1

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

Diff for: docs/Guides/Plugins-Guide.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,8 @@ use case, you can use the
493493

494494
```js
495495
const warning = require('process-warning')()
496-
warning.create('FastifyDeprecation', 'FST_ERROR_CODE', 'message')
497-
warning.emit('FST_ERROR_CODE')
496+
warning.create('MyPluginWarning', 'MP_ERROR_CODE', 'message')
497+
warning.emit('MP_ERROR_CODE')
498498
```
499499

500500
## Let's start!

Diff for: lib/warnings.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,35 @@ const warning = require('process-warning')()
77
* - FSTDEP005
88
*/
99

10-
warning.create('FastifyDeprecation', 'FSTDEP005', 'You are accessing the deprecated "request.connection" property. Use "request.socket" instead.')
10+
warning.createDeprecation('FSTDEP005', 'You are accessing the deprecated "request.connection" property. Use "request.socket" instead.')
1111

12-
warning.create('FastifyDeprecation', 'FSTDEP006', 'You are decorating Request/Reply with a reference type. This reference is shared amongst all requests. Use onRequest hook instead. Property: %s')
12+
warning.createDeprecation('FSTDEP006', 'You are decorating Request/Reply with a reference type. This reference is shared amongst all requests. Use onRequest hook instead. Property: %s')
1313

14-
warning.create('FastifyDeprecation', 'FSTDEP007', 'You are trying to set a HEAD route using "exposeHeadRoute" route flag when a sibling route is already set. See documentation for more info.')
14+
warning.createDeprecation('FSTDEP007', 'You are trying to set a HEAD route using "exposeHeadRoute" route flag when a sibling route is already set. See documentation for more info.')
1515

16-
warning.create('FastifyDeprecation', 'FSTDEP008', 'You are using route constraints via the route { version: "..." } option, use { constraints: { version: "..." } } option instead.')
16+
warning.createDeprecation('FSTDEP008', 'You are using route constraints via the route { version: "..." } option, use { constraints: { version: "..." } } option instead.')
1717

18-
warning.create('FastifyDeprecation', 'FSTDEP009', 'You are using a custom route versioning strategy via the server { versioning: "..." } option, use { constraints: { version: "..." } } option instead.')
18+
warning.createDeprecation('FSTDEP009', 'You are using a custom route versioning strategy via the server { versioning: "..." } option, use { constraints: { version: "..." } } option instead.')
1919

20-
warning.create('FastifyDeprecation', 'FSTDEP010', 'Modifying the "reply.sent" property is deprecated. Use the "reply.hijack()" method instead.')
20+
warning.createDeprecation('FSTDEP010', 'Modifying the "reply.sent" property is deprecated. Use the "reply.hijack()" method instead.')
2121

22-
warning.create('FastifyDeprecation', 'FSTDEP011', 'Variadic listen method is deprecated. Please use ".listen(optionsObject)" instead. The variadic signature will be removed in `fastify@5`.')
22+
warning.createDeprecation('FSTDEP011', 'Variadic listen method is deprecated. Please use ".listen(optionsObject)" instead. The variadic signature will be removed in `fastify@5`.')
2323

24-
warning.create('FastifyDeprecation', 'FSTDEP012', 'request.context property access is deprecated. Please use "request.routeOptions.config" or "request.routeOptions.schema" instead for accessing Route settings. The "request.context" will be removed in `fastify@5`.')
24+
warning.createDeprecation('FSTDEP012', 'request.context property access is deprecated. Please use "request.routeOptions.config" or "request.routeOptions.schema" instead for accessing Route settings. The "request.context" will be removed in `fastify@5`.')
2525

26-
warning.create('FastifyDeprecation', 'FSTDEP013', 'Direct return of "trailers" function is deprecated. Please use "callback" or "async-await" for return value. The support of direct return will removed in `fastify@5`.')
26+
warning.createDeprecation('FSTDEP013', 'Direct return of "trailers" function is deprecated. Please use "callback" or "async-await" for return value. The support of direct return will removed in `fastify@5`.')
2727

28-
warning.create('FastifyDeprecation', 'FSTDEP014', 'You are trying to set/access the default route. This property is deprecated. Please, use setNotFoundHandler if you want to custom a 404 handler or the wildcard (*) to match all routes.')
28+
warning.createDeprecation('FSTDEP014', 'You are trying to set/access the default route. This property is deprecated. Please, use setNotFoundHandler if you want to custom a 404 handler or the wildcard (*) to match all routes.')
2929

30-
warning.create('FastifyDeprecation', 'FSTDEP015', 'You are accessing the deprecated "request.routeSchema" property. Use "request.routeOptions.schema" instead. Property "req.routeSchema" will be removed in `fastify@5`.')
30+
warning.createDeprecation('FSTDEP015', 'You are accessing the deprecated "request.routeSchema" property. Use "request.routeOptions.schema" instead. Property "req.routeSchema" will be removed in `fastify@5`.')
3131

32-
warning.create('FastifyDeprecation', 'FSTDEP016', 'You are accessing the deprecated "request.routeConfig" property. Use "request.routeOptions.config" instead. Property "req.routeConfig" will be removed in `fastify@5`.')
32+
warning.createDeprecation('FSTDEP016', 'You are accessing the deprecated "request.routeConfig" property. Use "request.routeOptions.config" instead. Property "req.routeConfig" will be removed in `fastify@5`.')
3333

34-
warning.create('FastifyDeprecation', 'FSTDEP017', 'You are accessing the deprecated "request.routerPath" property. Use "request.routeOptions.url" instead. Property "req.routerPath" will be removed in `fastify@5`.')
34+
warning.createDeprecation('FSTDEP017', 'You are accessing the deprecated "request.routerPath" property. Use "request.routeOptions.url" instead. Property "req.routerPath" will be removed in `fastify@5`.')
3535

36-
warning.create('FastifyDeprecation', 'FSTDEP018', 'You are accessing the deprecated "request.routerMethod" property. Use "request.routeOptions.method" instead. Property "req.routerMethod" will be removed in `fastify@5`.')
36+
warning.createDeprecation('FSTDEP018', 'You are accessing the deprecated "request.routerMethod" property. Use "request.routeOptions.method" instead. Property "req.routerMethod" will be removed in `fastify@5`.')
3737

38-
warning.create('FastifyDeprecation', 'FSTDEP019', 'reply.context property access is deprecated. Please use "reply.routeOptions.config" or "reply.routeOptions.schema" instead for accessing Route settings. The "reply.context" will be removed in `fastify@5`.')
38+
warning.createDeprecation('FSTDEP019', 'reply.context property access is deprecated. Please use "reply.routeOptions.config" or "reply.routeOptions.schema" instead for accessing Route settings. The "reply.context" will be removed in `fastify@5`.')
3939

4040
warning.create('FastifyWarning', 'FSTWRN001', 'The %s schema for %s: %s is missing. This may indicate the schema is not well specified.', { unlimited: true })
4141

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198
"find-my-way": "^7.7.0",
199199
"light-my-request": "^5.11.0",
200200
"pino": "^8.16.0",
201-
"process-warning": "^2.2.0",
201+
"process-warning": "^2.3.0",
202202
"proxy-addr": "^2.0.7",
203203
"rfdc": "^1.3.0",
204204
"secure-json-parse": "^2.7.0",

Diff for: test/default-route.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test('setDefaultRoute should emit a deprecation warning', t => {
1818

1919
process.on('warning', onWarning)
2020
function onWarning (warning) {
21-
t.equal(warning.name, 'FastifyDeprecation')
21+
t.equal(warning.name, 'DeprecationWarning')
2222
t.equal(warning.code, 'FSTDEP014')
2323
}
2424

@@ -37,7 +37,7 @@ test('getDefaultRoute should emit a deprecation warning', t => {
3737

3838
process.on('warning', onWarning)
3939
function onWarning (warning) {
40-
t.equal(warning.name, 'FastifyDeprecation')
40+
t.equal(warning.name, 'DeprecationWarning')
4141
t.equal(warning.code, 'FSTDEP014')
4242
}
4343

Diff for: test/internals/reply.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1472,7 +1472,7 @@ test('should emit deprecation warning when trying to modify the reply.sent prope
14721472
process.removeAllListeners('warning')
14731473
process.on('warning', onWarning)
14741474
function onWarning (warning) {
1475-
t.equal(warning.name, 'FastifyDeprecation')
1475+
t.equal(warning.name, 'DeprecationWarning')
14761476
t.equal(warning.code, deprecationCode)
14771477
}
14781478

@@ -1500,7 +1500,7 @@ test('should emit deprecation warning when trying to use the reply.context.confi
15001500
process.removeAllListeners('warning')
15011501
process.on('warning', onWarning)
15021502
function onWarning (warning) {
1503-
t.equal(warning.name, 'FastifyDeprecation')
1503+
t.equal(warning.name, 'DeprecationWarning')
15041504
t.equal(warning.code, deprecationCode)
15051505
}
15061506

Diff for: test/reply-trailers.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ test('should emit deprecation warning when using direct return', t => {
200200

201201
process.on('warning', onWarning)
202202
function onWarning (warning) {
203-
t.equal(warning.name, 'FastifyDeprecation')
203+
t.equal(warning.name, 'DeprecationWarning')
204204
t.equal(warning.code, 'FSTDEP013')
205205
}
206206
t.teardown(() => process.removeListener('warning', onWarning))

0 commit comments

Comments
 (0)