fastify
Advanced tools
Comparing version 4.5.3 to 4.6.0
@@ -78,2 +78,5 @@ <h1 align="center">Fastify</h1> | ||
support for Fastify. | ||
- [`@fastify/nextjs`](https://github.com/fastify/fastify-nextjs) React | ||
server-side rendering support for Fastify with | ||
[Next](https://github.com/zeit/next.js/). | ||
- [`@fastify/oauth2`](https://github.com/fastify/fastify-oauth2) Wrap around | ||
@@ -86,2 +89,7 @@ [`simple-oauth2`](https://github.com/lelylan/simple-oauth2). | ||
overhead rate limiter for your routes. | ||
- [`@fastify/redis`](https://github.com/fastify/fastify-redis) Fastify Redis | ||
connection plugin, with which you can share the same Redis connection across | ||
every part of your server. | ||
- [`@fastify/reply-from`](https://github.com/fastify/fastify-reply-from) Plugin | ||
to forward the current HTTP request to another server. | ||
- [`@fastify/request-context`](https://github.com/fastify/fastify-request-context) | ||
@@ -94,10 +102,2 @@ Request-scoped storage, based on | ||
A simple plugin that enables response validation for Fastify. | ||
- [`@fastify/nextjs`](https://github.com/fastify/fastify-nextjs) React | ||
server-side rendering support for Fastify with | ||
[Next](https://github.com/zeit/next.js/). | ||
- [`@fastify/redis`](https://github.com/fastify/fastify-redis) Fastify Redis | ||
connection plugin, with which you can share the same Redis connection across | ||
every part of your server. | ||
- [`@fastify/reply-from`](https://github.com/fastify/fastify-reply-from) Plugin | ||
to forward the current HTTP request to another server. | ||
- [`@fastify/routes`](https://github.com/fastify/fastify-routes) Plugin that | ||
@@ -152,2 +152,9 @@ provides a `Map` of routes. | ||
easy, developer-friendly OpenAPI 3.1 specs + doc explorer based on your routes. | ||
- [`@ethicdevs/fastify-custom-session`](https://github.com/EthicDevs/fastify-custom-session) | ||
A plugin that let you use session and decide only where to load/save from/to. Has | ||
great TypeScript support + built-in adapters for common ORMs/databases (Firebase, | ||
Prisma Client, Postgres (wip), InMemory) and you can easily make your own adapter! | ||
- [`@ethicdevs/fastify-git-server`](https://github.com/EthicDevs/fastify-git-server) | ||
A plugin to easily create git server and make one/many Git repositories available | ||
for clone/fetch/push through the standard `git` (over http) commands. | ||
- [`@gquittet/graceful-server`](https://github.com/gquittet/graceful-server) | ||
@@ -223,2 +230,8 @@ Tiny (~5k), Fast, KISS, and dependency-free Node.JS library to make your | ||
directory. | ||
- [`fastify-aws-sns`](https://github.com/gzileni/fastify-aws-sns) Fastify plugin | ||
for AWS Simple Notification Service (AWS SNS) that coordinates and manages | ||
the delivery or sending of messages to subscribing endpoints or clients. | ||
- [`fastify-aws-timestream`](https://github.com/gzileni/fastify-aws-timestream) | ||
Fastify plugin for managing databases, tables, and querying and creating | ||
scheduled queries with AWS Timestream. | ||
- [`fastify-axios`](https://github.com/davidedantonio/fastify-axios) Plugin to | ||
@@ -582,2 +595,4 @@ send HTTP requests via [axios](https://github.com/axios/axios). | ||
Fastify. | ||
- [`pubsub-http-handler`](https://github.com/cobraz/pubsub-http-handler) A Fastify | ||
plugin to easily create Google Cloud PubSub endpoints. | ||
- [`sequelize-fastify`](https://github.com/hsynlms/sequelize-fastify) A simple | ||
@@ -584,0 +599,0 @@ and lightweight Sequelize plugin for Fastify. |
@@ -13,8 +13,7 @@ # V4 Migration Guide | ||
When an error is thrown in a async error handler function, | ||
the upper-level error handler is executed if set. | ||
If there is not a upper-level error handler, the default will | ||
be executed as it was previously. | ||
When an error is thrown in an async error handler function, the upper-level | ||
error handler is executed if set. If there is no upper-level error handler, | ||
the default will be executed as it was previously: | ||
``` | ||
```js | ||
import Fastify from 'fastify' | ||
@@ -44,19 +43,22 @@ | ||
### Deprecation of `app.use()` ([#3506](https://github.com/fastify/fastify/pull/3506)) | ||
### Removed `app.use()` ([#3506](https://github.com/fastify/fastify/pull/3506)) | ||
Starting this version of Fastify, we have deprecated the use of `app.use()`. We | ||
have decided not to support the use of middlewares. Both | ||
[`@fastify/middie`](https://github.com/fastify/middie) and | ||
[`@fastify/express`](https://github.com/fastify/fastify-express) will still be | ||
there and maintained. Use Fastify's [hooks](../Reference/Hooks.md) instead. | ||
With v4 of Fastify, `app.use()` has been removed and the use of middleware is | ||
no longer supported. | ||
If you need to use middleware, use | ||
[`@fastify/middie`](https://github.com/fastify/middie) or | ||
[`@fastify/express`](https://github.com/fastify/fastify-express), which will | ||
continue to be maintained. | ||
However, it is strongly recommended that you migrate to Fastify's [hooks](../Reference/Hooks.md). | ||
### `reply.res` moved to `reply.raw` | ||
If you previously used the `reply.res` attribute to access the underlying Request | ||
object you'll instead need to depend on `reply.raw`. | ||
object you will now need to use `reply.raw`. | ||
### Need to `return reply` to signal a "fork" of the promise chain | ||
In some situations, like when a response is sent asynchronously or when you're | ||
just not explicitly returning a response, you'll need to return the `reply` | ||
In some situations, like when a response is sent asynchronously or when you are | ||
not explicitly returning a response, you will now need to return the `reply` | ||
argument from your router handler. | ||
@@ -66,50 +68,97 @@ | ||
Starting from v4, all the `GET` routes will create a sibling `HEAD` route. | ||
You can revert this behaviour by setting the server's option `exposeHeadRoutes` | ||
to `false`. | ||
Starting with v4, every `GET` route will create a sibling `HEAD` route. | ||
You can revert this behavior by setting `exposeHeadRoutes: false` in the server options. | ||
### Synchronous route definitions | ||
### Synchronous route definitions ([#2954](https://github.com/fastify/fastify/pull/2954)) | ||
The route registration has been made synchronous from v4. | ||
This change was done to provide better error reporting for route definition. | ||
As a result if you specify an `onRoute` hook in a plugin you should either: | ||
To improve error reporting in route definitions, route registration is now synchronous. | ||
As a result, if you specify an `onRoute` hook in a plugin you should now either: | ||
* wrap your routes in a plugin (recommended) | ||
For example, refactor this: | ||
```js | ||
fastify.register((instance, opts, done) => { | ||
instance.addHook('onRoute', (routeOptions) => { | ||
const { path, method } = routeOptions; | ||
console.log({ path, method }); | ||
done(); | ||
}); | ||
}); | ||
fastify.get('/', (request, reply) => { reply.send('hello') }); | ||
``` | ||
Into this: | ||
```js | ||
fastify.register((instance, opts, done) => { | ||
instance.addHook('onRoute', (routeOptions) => { | ||
const { path, method } = routeOptions; | ||
console.log({ path, method }); | ||
done(); | ||
}); | ||
}); | ||
fastify.register((instance, opts, done) => { | ||
instance.get('/', (request, reply) => { reply.send('hello') }); | ||
done(); | ||
}); | ||
``` | ||
* use `await register(...)` | ||
For example refactor this: | ||
``` | ||
fastify.register((instance, opts, done) => { | ||
instance.addHook('onRoute', (routeOptions) => { | ||
const { path, method } = routeOptions; | ||
console.log({ path, method }); | ||
For example, refactor this: | ||
```js | ||
fastify.register((instance, opts, done) => { | ||
instance.addHook('onRoute', (routeOptions) => { | ||
const { path, method } = routeOptions; | ||
console.log({ path, method }); | ||
}); | ||
done(); | ||
}); | ||
done(); | ||
}); | ||
``` | ||
Into this: | ||
``` | ||
await fastify.register((instance, opts, done) => { | ||
instance.addHook('onRoute', (routeOptions) => { | ||
const { path, method } = routeOptions; | ||
console.log({ path, method }); | ||
``` | ||
Into this: | ||
```js | ||
await fastify.register((instance, opts) => { | ||
instance.addHook('onRoute', (routeOptions) => { | ||
const { path, method } = routeOptions; | ||
console.log({ path, method }); | ||
}); | ||
done(); | ||
}); | ||
done(); | ||
}); | ||
``` | ||
``` | ||
## Non Breaking Changes | ||
## Non-Breaking Changes | ||
### Change of schema for multiple types | ||
### Deprecation of variadic `.listen()` signature | ||
The [variadic signature](https://en.wikipedia.org/wiki/Variadic_function) of the | ||
`fastify.listen()` method is now deprecated. | ||
Since Fastify v4 has upgraded to Ajv v8. The "type" keywords with multiple types | ||
(other than with "null") are prohibited. Read more | ||
['here'](https://ajv.js.org/strict-mode.html#strict-types) | ||
Prior to this release, the following invocations of this method were valid: | ||
You may encounter a console warning such as | ||
- `fastify.listen(8000)` | ||
- `fastify.listen(8000, ‘127.0.0.1’)` | ||
- `fastify.listen(8000, ‘127.0.0.1’, 511)` | ||
- `fastify.listen(8000, (err) => { if (err) throw err })` | ||
- `fastify.listen({ port: 8000 }, (err) => { if (err) throw err })` | ||
``` | ||
With Fastify v4, only the following invocations are valid: | ||
- `fastify.listen()` | ||
- `fastify.listen({ port: 8000 })` | ||
- `fastify.listen({ port: 8000 }, (err) => { if (err) throw err })` | ||
### Change of schema for multiple types | ||
Ajv has been upgraded to v8 in Fastify v4, meaning "type" keywords with multiple | ||
types other than "null" | ||
[are now prohibited](https://ajv.js.org/strict-mode.html#strict-types). | ||
You may encounter a console warning such as: | ||
```sh | ||
strict mode: use allowUnionTypes to allow union type keyword at "#/properties/image" (strictTypes) | ||
``` | ||
So schemas like below will need to be changed from | ||
As such, schemas like below will need to be changed from: | ||
``` | ||
@@ -123,4 +172,4 @@ type: 'object', | ||
``` | ||
to | ||
Into: | ||
``` | ||
@@ -127,0 +176,0 @@ type: 'object', |
@@ -83,3 +83,3 @@ <h1 align="center">Fastify</h1> | ||
In addition, you can enable services like [Dependabot](https://dependabot.com/), | ||
In addition, you can enable services like [Dependabot](https://github.com/dependabot), | ||
which will help you keep your dependencies up to date and discover if a new | ||
@@ -86,0 +86,0 @@ release of Fastify has some issues with your plugin. |
@@ -25,17 +25,20 @@ <h1 align="center">Fastify</h1> | ||
Enabling the logger with appropriate configuration for both local development | ||
and production environment requires bit more configuration: | ||
and production and test environment requires bit more configuration: | ||
```js | ||
const envToLogger = { | ||
development: { | ||
transport: { | ||
target: 'pino-pretty', | ||
options: { | ||
translateTime: 'HH:MM:ss Z', | ||
ignore: 'pid,hostname', | ||
}, | ||
}, | ||
}, | ||
production: true, | ||
test: false, | ||
} | ||
const fastify = require('fastify')({ | ||
logger: { | ||
transport: | ||
environment === 'development' | ||
? { | ||
target: 'pino-pretty', | ||
options: { | ||
translateTime: 'HH:MM:ss Z', | ||
ignore: 'pid,hostname' | ||
} | ||
} | ||
: undefined | ||
} | ||
logger: envToLogger[environment] ?? true // defaults to true if no entry matches in the map | ||
}) | ||
@@ -42,0 +45,0 @@ ``` |
@@ -57,2 +57,3 @@ <h1 align="center">Fastify</h1> | ||
- [route](#route) | ||
- [hasRoute](#hasRoute) | ||
- [close](#close) | ||
@@ -671,3 +672,3 @@ - [decorate*](#decorate) | ||
The default configuration is explained in the | ||
[#schema-validator](Validation-and-Serialization.md#schema-validator) section. | ||
[#schema-validator](./Validation-and-Serialization.md#schema-validator) section. | ||
@@ -1025,3 +1026,4 @@ ```js | ||
**Note**: The default 404 handler, or one set using `setNotFoundHandler`, will | ||
never trigger if the default route is overridden. Use | ||
never trigger if the default route is overridden. This sets the handler for the | ||
Fastify application, not just the current instance context. Use | ||
[setNotFoundHandler](#setnotfoundhandler) if you want to customize 404 handling | ||
@@ -1054,2 +1056,22 @@ instead. Method to set the `defaultRoute` for the server: | ||
#### hasRoute | ||
<a id="hasRoute"></a> | ||
Method to check if a route is already registered to the internal router. It | ||
expects an object as payload. `url` and `method` are mandatory fields. It is | ||
possible to also specify `constraints`. The method returns true if the route is | ||
registered, and false if it is not registered. | ||
```js | ||
const routeExists = fastify.hasRoute({ | ||
url: '/', | ||
method: 'GET', | ||
constraints: { version: '1.0.0' } // optional | ||
}) | ||
if (routeExists === false) { | ||
// add route | ||
} | ||
``` | ||
#### close | ||
@@ -1056,0 +1078,0 @@ <a id="close"></a> |
@@ -158,10 +158,3 @@ <h1 align="center">Fastify</h1> | ||
const server = Fastify({ | ||
ajv: { | ||
customOptions: { | ||
strict: 'log', | ||
keywords: ['kind', 'modifier'], | ||
}, | ||
}, | ||
}).withTypeProvider<TypeBoxTypeProvider>() | ||
const server = Fastify().withTypeProvider<TypeBoxTypeProvider>() | ||
@@ -217,10 +210,3 @@ server.register(plugin1) // wrong | ||
const server = Fastify({ | ||
ajv: { | ||
customOptions: { | ||
strict: 'log', | ||
keywords: ['kind', 'modifier'], | ||
}, | ||
}, | ||
}).withTypeProvider<TypeBoxTypeProvider>() | ||
const server = Fastify().withTypeProvider<TypeBoxTypeProvider>() | ||
@@ -227,0 +213,0 @@ registerRoutes(server) |
@@ -64,2 +64,7 @@ <h1 align="center">Fastify</h1> | ||
*Note 2: Avoid using ```"moduleResolution": "NodeNext"``` in tsconfig.json with | ||
```"type": "module"``` in package.json. This combination is currently not | ||
supported by fastify typing system. | ||
[ts(2349)](https://github.com/fastify/fastify/issues/4241) warning.* | ||
4. Create an `index.ts` file - this will contain the server code | ||
@@ -258,15 +263,3 @@ 5. Add the following code block to your file: | ||
**Note** For Ajv version 7 and above is required to use the `ajvTypeBoxPlugin`: | ||
```typescript | ||
import Fastify from 'fastify' | ||
import { ajvTypeBoxPlugin, TypeBoxTypeProvider } from '@fastify/type-provider-typebox' | ||
const fastify = Fastify({ | ||
ajv: { | ||
plugins: [ajvTypeBoxPlugin] | ||
} | ||
}).withTypeProvider<TypeBoxTypeProvider>() | ||
``` | ||
#### Schemas in JSON Files | ||
@@ -1242,4 +1235,4 @@ | ||
fastify().register(plugin, {}) // Error - options object is missing required properties | ||
fastify().register(plugin, { option1: '', option2: true }) // OK - options object contains required properties | ||
server().register(plugin, {}) // Error - options object is missing required properties | ||
server().register(plugin, { option1: '', option2: true }) // OK - options object contains required properties | ||
``` | ||
@@ -1246,0 +1239,0 @@ |
@@ -59,3 +59,3 @@ /** | ||
// Add our route handler with correct types | ||
server.get<{ | ||
server.post<{ | ||
Querystring: PingQuerystring; | ||
@@ -62,0 +62,0 @@ Params: PingParams; |
@@ -87,3 +87,3 @@ import * as http from 'http' | ||
> = FastifyServerOptions<Server, Logger> & { | ||
https: https.ServerOptions | ||
https: https.ServerOptions | null | ||
} | ||
@@ -201,3 +201,3 @@ | ||
export { FastifyContext, FastifyContextConfig } from './types/context' | ||
export { RouteHandler, RouteHandlerMethod, RouteOptions, RouteShorthandMethod, RouteShorthandOptions, RouteShorthandOptionsWithHandler } from './types/route' | ||
export { RouteHandler, RouteHandlerMethod, RouteOptions, RouteShorthandMethod, RouteShorthandOptions, RouteShorthandOptionsWithHandler, RouteGenericInterface } from './types/route' | ||
export * from './types/register' | ||
@@ -204,0 +204,0 @@ export { FastifyBodyParser, FastifyContentTypeParser, AddContentTypeParser, hasContentTypeParser, getDefaultJsonParser, ProtoAction, ConstructorAction } from './types/content-type-parser' |
'use strict' | ||
const VERSION = '4.5.3' | ||
const VERSION = '4.6.0' | ||
@@ -270,2 +270,5 @@ const Avvio = require('avvio') | ||
}, | ||
hasRoute: function _route (options) { | ||
return router.hasRoute.call(this, { options }) | ||
}, | ||
// expose logger instance | ||
@@ -272,0 +275,0 @@ log: logger, |
@@ -26,10 +26,2 @@ // This file is autogenerated by build/build-error-serializer.js, do not edit | ||
asAny (i) { | ||
return JSON.stringify(i) | ||
} | ||
asNull () { | ||
return 'null' | ||
} | ||
asInteger (i) { | ||
@@ -51,6 +43,2 @@ if (typeof i === 'bigint') { | ||
asIntegerNullable (i) { | ||
return i === null ? 'null' : this.asInteger(i) | ||
} | ||
asNumber (i) { | ||
@@ -67,6 +55,2 @@ const num = Number(i) | ||
asNumberNullable (i) { | ||
return i === null ? 'null' : this.asNumber(i) | ||
} | ||
asBoolean (bool) { | ||
@@ -76,6 +60,2 @@ return bool && 'true' || 'false' // eslint-disable-line | ||
asBooleanNullable (bool) { | ||
return bool === null ? 'null' : this.asBoolean(bool) | ||
} | ||
asDateTime (date) { | ||
@@ -86,9 +66,8 @@ if (date === null) return '""' | ||
} | ||
if (typeof date === 'string') { | ||
return '"' + date + '"' | ||
} | ||
throw new Error(`The value "${date}" cannot be converted to a date-time.`) | ||
} | ||
asDateTimeNullable (date) { | ||
return date === null ? 'null' : this.asDateTime(date) | ||
} | ||
asDate (date) { | ||
@@ -99,9 +78,8 @@ if (date === null) return '""' | ||
} | ||
if (typeof date === 'string') { | ||
return '"' + date + '"' | ||
} | ||
throw new Error(`The value "${date}" cannot be converted to a date.`) | ||
} | ||
asDateNullable (date) { | ||
return date === null ? 'null' : this.asDate(date) | ||
} | ||
asTime (date) { | ||
@@ -112,9 +90,8 @@ if (date === null) return '""' | ||
} | ||
if (typeof date === 'string') { | ||
return '"' + date + '"' | ||
} | ||
throw new Error(`The value "${date}" cannot be converted to a time.`) | ||
} | ||
asTimeNullable (date) { | ||
return date === null ? 'null' : this.asTime(date) | ||
} | ||
asString (str) { | ||
@@ -139,6 +116,2 @@ const quotes = '"' | ||
asStringNullable (str) { | ||
return str === null ? 'null' : this.asString(str) | ||
} | ||
// magically escape strings for json | ||
@@ -211,3 +184,3 @@ // relying on their charCodeAt | ||
json += "\"statusCode\"" + ':' | ||
json += serializer.asNumber.bind(serializer)(obj["statusCode"]) | ||
json += serializer.asNumber(obj["statusCode"]) | ||
} | ||
@@ -224,3 +197,3 @@ | ||
json += "\"code\"" + ':' | ||
json += serializer.asString.bind(serializer)(obj["code"]) | ||
json += serializer.asString(obj["code"]) | ||
} | ||
@@ -237,3 +210,3 @@ | ||
json += "\"error\"" + ':' | ||
json += serializer.asString.bind(serializer)(obj["error"]) | ||
json += serializer.asString(obj["error"]) | ||
} | ||
@@ -250,3 +223,3 @@ | ||
json += "\"message\"" + ':' | ||
json += serializer.asString.bind(serializer)(obj["message"]) | ||
json += serializer.asString(obj["message"]) | ||
} | ||
@@ -253,0 +226,0 @@ |
@@ -86,2 +86,3 @@ 'use strict' | ||
route, // configure a route in the fastify instance | ||
hasRoute, | ||
prepareRoute, | ||
@@ -145,2 +146,10 @@ getDefaultRoute: function () { | ||
function hasRoute ({ options }) { | ||
return router.find( | ||
options.method, | ||
options.url || '', | ||
options.constraints | ||
) !== null | ||
} | ||
// Route management | ||
@@ -147,0 +156,0 @@ function route ({ options, isFastify }) { |
@@ -65,2 +65,3 @@ 'use strict' | ||
if (typeof routeSchemas[key] === 'object' && Object.getPrototypeOf(routeSchemas[key]) !== Object.prototype) { | ||
routeSchemas[kSchemaVisited] = true | ||
return routeSchemas | ||
@@ -67,0 +68,0 @@ } |
@@ -322,3 +322,3 @@ 'use strict' | ||
/* Deal with listen ([port[, host[, backlog]]]) */ | ||
options.port = argsLength >= 1 && Number.isInteger(firstArg) ? firstArg : 0 | ||
options.port = argsLength >= 1 && Number.isInteger(firstArg) ? firstArg : normalizePort(firstArg) | ||
// This will listen to what localhost is. | ||
@@ -334,2 +334,7 @@ // It can be 127.0.0.1 or ::1, depending on the operating system. | ||
function normalizePort (firstArg) { | ||
const port = parseInt(firstArg, 10) | ||
return port >= 0 && !Number.isNaN(port) ? port : 0 | ||
} | ||
function logServerAddress (server) { | ||
@@ -336,0 +341,0 @@ let address = server.address() |
{ | ||
"name": "fastify", | ||
"version": "4.5.3", | ||
"version": "4.6.0", | ||
"description": "Fast and low overhead web framework, for Node.js", | ||
@@ -167,3 +167,3 @@ "main": "fastify.js", | ||
"tap": "^16.2.0", | ||
"tsd": "^0.22.0", | ||
"tsd": "^0.23.0", | ||
"typescript": "^4.7.2", | ||
@@ -170,0 +170,0 @@ "undici": "^5.4.0", |
@@ -203,1 +203,34 @@ 'use strict' | ||
}) | ||
test('listen accepts a port as string, and callback', t => { | ||
t.plan(2) | ||
const fastify = Fastify() | ||
t.teardown(fastify.close.bind(fastify)) | ||
const port = 3000 | ||
fastify.listen(port.toString(), localhost, (err) => { | ||
t.equal(fastify.server.address().port, port) | ||
t.error(err) | ||
}) | ||
}) | ||
test('listen accepts a port as string, address and callback', t => { | ||
t.plan(3) | ||
const fastify = Fastify() | ||
t.teardown(fastify.close.bind(fastify)) | ||
const port = 3000 | ||
fastify.listen(port.toString(), localhost, (err) => { | ||
t.equal(fastify.server.address().port, port) | ||
t.equal(fastify.server.address().address, localhost) | ||
t.error(err) | ||
}) | ||
}) | ||
test('listen with invalid port string without callback with (address)', t => { | ||
t.plan(1) | ||
const fastify = Fastify() | ||
t.teardown(fastify.close.bind(fastify)) | ||
fastify.listen('-1') | ||
.then(address => { | ||
t.equal(address, `http://${localhostForURL}:${fastify.server.address().port}`) | ||
}) | ||
}) |
@@ -5,2 +5,3 @@ 'use strict' | ||
const Joi = require('joi') | ||
const yup = require('yup') | ||
const AJV = require('ajv') | ||
@@ -677,1 +678,29 @@ const S = require('fluent-json-schema') | ||
}) | ||
test('Custom schema object should not trigger FST_ERR_SCH_DUPLICATE', async t => { | ||
const fastify = Fastify() | ||
const handler = () => { } | ||
fastify.get('/the/url', { | ||
schema: { | ||
query: yup.object({ | ||
foo: yup.string() | ||
}) | ||
}, | ||
validatorCompiler: ({ schema, method, url, httpPart }) => { | ||
return function (data) { | ||
// with option strict = false, yup `validateSync` function returns the coerced value if validation was successful, or throws if validation failed | ||
try { | ||
const result = schema.validateSync(data, {}) | ||
return { value: result } | ||
} catch (e) { | ||
return { error: e } | ||
} | ||
} | ||
}, | ||
handler | ||
}) | ||
await fastify.ready() | ||
t.pass('fastify is ready') | ||
}) |
@@ -11,2 +11,3 @@ import fastify, { | ||
InjectOptions, FastifyBaseLogger, | ||
RouteGenericInterface, | ||
ValidationResult | ||
@@ -28,2 +29,3 @@ } from '../../fastify' | ||
expectType<FastifyInstance<https.Server, http.IncomingMessage, http.ServerResponse> & PromiseLike<FastifyInstance<https.Server, http.IncomingMessage, http.ServerResponse>>>(fastify({ https: {} })) | ||
expectType<FastifyInstance<https.Server, http.IncomingMessage, http.ServerResponse> & PromiseLike<FastifyInstance<https.Server, http.IncomingMessage, http.ServerResponse>>>(fastify({ https: null })) | ||
// http2 server | ||
@@ -236,1 +238,8 @@ expectType<FastifyInstance<http2.Http2Server, http2.Http2ServerRequest, http2.Http2ServerResponse> & PromiseLike<FastifyInstance<http2.Http2Server, http2.Http2ServerRequest, http2.Http2ServerResponse>>>(fastify({ http2: true, http2SessionTimeout: 1000 })) | ||
expectAssignable<ValidationResult>(ajvErrorObject) | ||
const routeGeneric: RouteGenericInterface = {} | ||
expectType<unknown>(routeGeneric.Body) | ||
expectType<unknown>(routeGeneric.Headers) | ||
expectType<unknown>(routeGeneric.Params) | ||
expectType<unknown>(routeGeneric.Querystring) | ||
expectType<unknown>(routeGeneric.Reply) |
@@ -233,1 +233,12 @@ import fastify, { FastifyInstance, FastifyRequest, FastifyReply, RouteHandlerMethod } from '../../fastify' | ||
})) | ||
expectType<boolean>(fastify().hasRoute({ | ||
url: '/', | ||
method: 'GET' | ||
})) | ||
expectType<boolean>(fastify().hasRoute({ | ||
url: '/', | ||
method: 'GET', | ||
constraints: { version: '1.2.0' } | ||
})) |
@@ -7,28 +7,2 @@ 'use strict' | ||
t.test('Will return 505 HTTP error if HTTP version (default) is not supported', t => { | ||
const fastify = Fastify() | ||
t.teardown(fastify.close.bind(fastify)) | ||
fastify.get('/', (req, reply) => { | ||
reply.send({ hello: 'world' }) | ||
}) | ||
fastify.listen({ port: 0 }, err => { | ||
t.error(err) | ||
const port = fastify.server.address().port | ||
const client = net.createConnection({ port }, () => { | ||
client.write('GET / HTTP/5.1\r\n\r\n') | ||
client.once('data', data => { | ||
t.match(data.toString(), /505 HTTP Version Not Supported/i) | ||
client.end(() => { | ||
t.end() | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
t.test('Will return 505 HTTP error if HTTP version (2.0 when server is 1.1) is not supported', t => { | ||
@@ -35,0 +9,0 @@ const fastify = Fastify() |
@@ -8,3 +8,3 @@ import { Readable } from 'stream' | ||
import { FastifyError } from '@fastify/error' | ||
import { FastifyLoggerInstance } from './logger' | ||
import { FastifyBaseLogger } from './logger' | ||
import { | ||
@@ -38,3 +38,3 @@ FastifyTypeProvider, | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> { | ||
@@ -57,3 +57,3 @@ ( | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> { | ||
@@ -79,3 +79,3 @@ ( | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> { | ||
@@ -99,3 +99,3 @@ ( | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> { | ||
@@ -121,3 +121,3 @@ ( | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> { | ||
@@ -140,3 +140,3 @@ ( | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> { | ||
@@ -161,3 +161,3 @@ ( | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> { | ||
@@ -180,3 +180,3 @@ ( | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> { | ||
@@ -210,3 +210,3 @@ ( | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> { | ||
@@ -231,3 +231,3 @@ ( | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> { | ||
@@ -255,3 +255,3 @@ ( | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> { | ||
@@ -276,3 +276,3 @@ ( | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> { | ||
@@ -299,3 +299,3 @@ ( | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> { | ||
@@ -318,3 +318,3 @@ ( | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> { | ||
@@ -340,3 +340,3 @@ ( | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> { | ||
@@ -359,3 +359,3 @@ ( | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> { | ||
@@ -384,3 +384,3 @@ ( | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> { | ||
@@ -405,3 +405,3 @@ ( | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> { | ||
@@ -429,3 +429,3 @@ ( | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> { | ||
@@ -447,3 +447,3 @@ ( | ||
RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance, | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger, | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
@@ -466,3 +466,3 @@ Options extends FastifyPluginOptions = FastifyPluginOptions | ||
RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance, | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger, | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
@@ -480,3 +480,3 @@ > { | ||
RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance, | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger, | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
@@ -495,3 +495,3 @@ > { | ||
RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance, | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger, | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
@@ -509,3 +509,3 @@ > { | ||
RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance, | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger, | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault | ||
@@ -512,0 +512,0 @@ > { |
@@ -7,3 +7,3 @@ import { FastifyError } from '@fastify/error' | ||
import { onCloseAsyncHookHandler, onCloseHookHandler, onErrorAsyncHookHandler, onErrorHookHandler, onReadyAsyncHookHandler, onReadyHookHandler, onRegisterHookHandler, onRequestAsyncHookHandler, onRequestHookHandler, onResponseAsyncHookHandler, onResponseHookHandler, onRouteHookHandler, onSendAsyncHookHandler, onSendHookHandler, onTimeoutAsyncHookHandler, onTimeoutHookHandler, preHandlerAsyncHookHandler, preHandlerHookHandler, preParsingAsyncHookHandler, preParsingHookHandler, preSerializationAsyncHookHandler, preSerializationHookHandler, preValidationAsyncHookHandler, preValidationHookHandler } from './hooks' | ||
import { FastifyLoggerInstance } from './logger' | ||
import { FastifyBaseLogger } from './logger' | ||
import { FastifyRegister } from './register' | ||
@@ -88,3 +88,3 @@ import { FastifyReply } from './reply' | ||
RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance, | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger, | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
@@ -191,2 +191,8 @@ > { | ||
hasRoute< | ||
RouteGeneric extends RouteGenericInterface = RouteGenericInterface, | ||
ContextConfig = ContextConfigDefault, | ||
SchemaCompiler extends FastifySchema = FastifySchema, | ||
>(opts: Pick<RouteOptions<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>, 'method' | 'url' | 'constraints'>): boolean; | ||
// addHook: overloads | ||
@@ -204,3 +210,3 @@ | ||
SchemaCompiler extends FastifySchema = FastifySchema, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
>( | ||
@@ -215,3 +221,3 @@ name: 'onRequest', | ||
SchemaCompiler extends FastifySchema = FastifySchema, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
>( | ||
@@ -230,3 +236,3 @@ name: 'onRequest', | ||
SchemaCompiler extends FastifySchema = FastifySchema, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
>( | ||
@@ -241,3 +247,3 @@ name: 'preParsing', | ||
SchemaCompiler extends FastifySchema = FastifySchema, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
>( | ||
@@ -255,3 +261,3 @@ name: 'preParsing', | ||
SchemaCompiler extends FastifySchema = FastifySchema, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
>( | ||
@@ -266,3 +272,3 @@ name: 'preValidation', | ||
SchemaCompiler extends FastifySchema = FastifySchema, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
>( | ||
@@ -280,3 +286,3 @@ name: 'preValidation', | ||
SchemaCompiler extends FastifySchema = FastifySchema, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
>( | ||
@@ -291,3 +297,3 @@ name: 'preHandler', | ||
SchemaCompiler extends FastifySchema = FastifySchema, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
>( | ||
@@ -307,3 +313,3 @@ name: 'preHandler', | ||
SchemaCompiler extends FastifySchema = FastifySchema, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
>( | ||
@@ -319,3 +325,3 @@ name: 'preSerialization', | ||
SchemaCompiler extends FastifySchema = FastifySchema, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
>( | ||
@@ -335,3 +341,3 @@ name: 'preSerialization', | ||
SchemaCompiler extends FastifySchema = FastifySchema, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
>( | ||
@@ -347,3 +353,3 @@ name: 'onSend', | ||
SchemaCompiler extends FastifySchema = FastifySchema, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
>( | ||
@@ -362,3 +368,3 @@ name: 'onSend', | ||
SchemaCompiler extends FastifySchema = FastifySchema, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
>( | ||
@@ -373,3 +379,3 @@ name: 'onResponse', | ||
SchemaCompiler extends FastifySchema = FastifySchema, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
>( | ||
@@ -388,3 +394,3 @@ name: 'onResponse', | ||
SchemaCompiler extends FastifySchema = FastifySchema, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
>( | ||
@@ -399,3 +405,3 @@ name: 'onTimeout', | ||
SchemaCompiler extends FastifySchema = FastifySchema, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
>( | ||
@@ -416,3 +422,3 @@ name: 'onTimeout', | ||
SchemaCompiler extends FastifySchema = FastifySchema, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
>( | ||
@@ -427,3 +433,3 @@ name: 'onError', | ||
SchemaCompiler extends FastifySchema = FastifySchema, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
>( | ||
@@ -443,3 +449,3 @@ name: 'onError', | ||
SchemaCompiler extends FastifySchema = FastifySchema, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
>( | ||
@@ -446,0 +452,0 @@ name: 'onRoute', |
@@ -26,3 +26,3 @@ import { FastifyError } from '@fastify/error' | ||
// TODO delete FastifyLoggerInstance in the next major release. It seems that it is enough to have only FastifyBaseLogger. | ||
// TODO delete FastifyBaseLogger in the next major release. It seems that it is enough to have only FastifyBaseLogger. | ||
/** | ||
@@ -29,0 +29,0 @@ * @deprecated Use FastifyBaseLogger instead |
import { FastifyInstance } from './instance' | ||
import { RawServerBase, RawRequestDefaultExpression, RawReplyDefaultExpression, RawServerDefault } from './utils' | ||
import { FastifyTypeProvider, FastifyTypeProviderDefault } from './type-provider' | ||
import { FastifyLoggerInstance } from './logger' | ||
import { FastifyBaseLogger } from './logger' | ||
@@ -14,3 +14,3 @@ export type FastifyPluginOptions = Record<string, any> | ||
export type FastifyPluginCallback<Options extends FastifyPluginOptions = Record<never, never>, Server extends RawServerBase = RawServerDefault, TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault> = ( | ||
instance: FastifyInstance<Server, RawRequestDefaultExpression<Server>, RawReplyDefaultExpression<Server>, FastifyLoggerInstance, TypeProvider>, | ||
instance: FastifyInstance<Server, RawRequestDefaultExpression<Server>, RawReplyDefaultExpression<Server>, FastifyBaseLogger, TypeProvider>, | ||
opts: Options, | ||
@@ -30,3 +30,3 @@ done: (err?: Error) => void | ||
> = ( | ||
instance: FastifyInstance<Server, RawRequestDefaultExpression<Server>, RawReplyDefaultExpression<Server>, FastifyLoggerInstance, TypeProvider>, | ||
instance: FastifyInstance<Server, RawRequestDefaultExpression<Server>, RawReplyDefaultExpression<Server>, FastifyBaseLogger, TypeProvider>, | ||
opts: Options | ||
@@ -33,0 +33,0 @@ ) => Promise<void>; |
import { RawReplyDefaultExpression, RawServerBase, RawServerDefault, ContextConfigDefault, RawRequestDefaultExpression, ReplyDefault } from './utils' | ||
import { FastifyReplyType, ResolveFastifyReplyType, FastifyTypeProvider, FastifyTypeProviderDefault } from './type-provider' | ||
import { FastifyContext } from './context' | ||
import { FastifyLoggerInstance } from './logger' | ||
import { FastifyBaseLogger } from './logger' | ||
import { FastifyRequest } from './request' | ||
@@ -31,3 +31,3 @@ import { RouteGenericInterface } from './route' | ||
context: FastifyContext<ContextConfig>; | ||
log: FastifyLoggerInstance; | ||
log: FastifyBaseLogger; | ||
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>; | ||
@@ -34,0 +34,0 @@ server: FastifyInstance; |
@@ -1,2 +0,2 @@ | ||
import { FastifyLoggerInstance } from './logger' | ||
import { FastifyBaseLogger } from './logger' | ||
import { ContextConfigDefault, RawServerBase, RawServerDefault, RawRequestDefaultExpression, RequestBodyDefault, RequestQuerystringDefault, RequestParamsDefault, RequestHeadersDefault } from './utils' | ||
@@ -27,3 +27,3 @@ import { RouteGenericInterface } from './route' | ||
ContextConfig = ContextConfigDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance, | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger, | ||
RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric> | ||
@@ -30,0 +30,0 @@ // ^ Temporary Note: RequestType has been re-ordered to be the last argument in |
@@ -14,3 +14,3 @@ import { FastifyInstance } from './instance' | ||
} from './type-provider' | ||
import { FastifyLoggerInstance, LogLevel } from './logger' | ||
import { FastifyBaseLogger, LogLevel } from './logger' | ||
@@ -30,3 +30,3 @@ export interface RouteGenericInterface extends RequestGenericInterface, ReplyGenericInterface {} | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> { | ||
@@ -72,3 +72,3 @@ schema?: SchemaCompiler, // originally FastifySchema | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> = ( | ||
@@ -92,3 +92,3 @@ this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>, | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> extends RouteShorthandOptions<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger> { | ||
@@ -107,3 +107,3 @@ handler: RouteHandlerMethod<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>; | ||
> { | ||
<RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig = ContextConfigDefault, SchemaCompiler extends FastifySchema = FastifySchema, Logger extends FastifyLoggerInstance = FastifyLoggerInstance>( | ||
<RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig = ContextConfigDefault, SchemaCompiler extends FastifySchema = FastifySchema, Logger extends FastifyBaseLogger = FastifyBaseLogger>( | ||
path: string, | ||
@@ -113,7 +113,7 @@ opts: RouteShorthandOptions<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>, | ||
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>; | ||
<RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig = ContextConfigDefault, SchemaCompiler extends FastifySchema = FastifySchema, Logger extends FastifyLoggerInstance = FastifyLoggerInstance>( | ||
<RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig = ContextConfigDefault, SchemaCompiler extends FastifySchema = FastifySchema, Logger extends FastifyBaseLogger = FastifyBaseLogger>( | ||
path: string, | ||
handler: RouteHandlerMethod<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger> | ||
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>; | ||
<RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig = ContextConfigDefault, SchemaCompiler extends FastifySchema = FastifySchema, Logger extends FastifyLoggerInstance = FastifyLoggerInstance>( | ||
<RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig = ContextConfigDefault, SchemaCompiler extends FastifySchema = FastifySchema, Logger extends FastifyBaseLogger = FastifyBaseLogger>( | ||
path: string, | ||
@@ -135,3 +135,3 @@ opts: RouteShorthandOptionsWithHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger> | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> extends RouteShorthandOptions<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger> { | ||
@@ -151,3 +151,3 @@ method: HTTPMethods | HTTPMethods[]; | ||
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, | ||
Logger extends FastifyLoggerInstance = FastifyLoggerInstance | ||
Logger extends FastifyBaseLogger = FastifyBaseLogger | ||
> = ( | ||
@@ -154,0 +154,0 @@ this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>, |
1914820
270
45922