Skip to content

Commit

Permalink
docs: reference new @fastify/* modules (#3860)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Apr 29, 2022
1 parent 8a2b226 commit e94cd92
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 68 deletions.
78 changes: 39 additions & 39 deletions docs/Guides/Ecosystem.md
Expand Up @@ -8,105 +8,105 @@ section.

#### [Core](#core)

- [`fastify-accepts`](https://github.com/fastify/fastify-accepts) to have
- [`@fastify/accepts`](https://github.com/fastify/fastify-accepts) to have
[accepts](https://www.npmjs.com/package/accepts) in your request object.
- [`fastify-accepts-serializer`](https://github.com/fastify/fastify-accepts-serializer)
- [`@fastify/accepts-serializer`](https://github.com/fastify/fastify-accepts-serializer)
to serialize to output according to `Accept` header.
- [`fastify-auth`](https://github.com/fastify/fastify-auth) Run multiple auth
- [`@fastify/auth`](https://github.com/fastify/fastify-auth) Run multiple auth
functions in Fastify.
- [`fastify-autoload`](https://github.com/fastify/fastify-autoload) Require all
- [`@fastify/autoload`](https://github.com/fastify/fastify-autoload) Require all
plugins in a directory.
- [`fastify-awilix`](https://github.com/fastify/fastify-awilix) Dependency
injection support for Fastify, based on
[awilix](https://github.com/jeffijoe/awilix).
- [`fastify-bankai`](https://github.com/fastify/fastify-bankai)
- [`@fastify/bankai`](https://github.com/fastify/fastify-bankai)
[Bankai](https://github.com/yoshuawuyts/bankai) assets compiler for Fastify.
- [`fastify-basic-auth`](https://github.com/fastify/fastify-basic-auth) Basic
- [`@fastify/basic-auth`](https://github.com/fastify/fastify-basic-auth) Basic
auth plugin for Fastify.
- [`fastify-bearer-auth`](https://github.com/fastify/fastify-bearer-auth) Bearer
- [`@fastify/bearer-auth`](https://github.com/fastify/fastify-bearer-auth) Bearer
auth plugin for Fastify.
- [`fastify-caching`](https://github.com/fastify/fastify-caching) General
- [`@fastify/caching`](https://github.com/fastify/fastify-caching) General
server-side cache and ETag support.
- [`fastify-circuit-breaker`](https://github.com/fastify/fastify-circuit-breaker)
- [`@fastify/circuit-breaker`](https://github.com/fastify/fastify-circuit-breaker)
A low overhead circuit breaker for your routes.
- [`fastify-compress`](https://github.com/fastify/fastify-compress) Fastify
- [`@fastify/compress`](https://github.com/fastify/fastify-compress) Fastify
compression utils.
- [`fastify-cookie`](https://github.com/fastify/fastify-cookie) Parse and set
- [`@fastify/cookie`](https://github.com/fastify/fastify-cookie) Parse and set
cookie headers.
- [`fastify-cors`](https://github.com/fastify/fastify-cors) Enables the use of
- [`@fastify/cors`](https://github.com/fastify/fastify-cors) Enables the use of
CORS in a Fastify application.
- [`fastify-csrf`](https://github.com/fastify/fastify-csrf) A plugin for adding
[CSRF](https://en.wikipedia.org/wiki/Cross-site_request_forgery) protection to
Fastify.
- [`fastify-diagnostics-channel`](https://github.com/fastify/fastify-diagnostics-channel)
- [`@fastify/diagnostics-channel`](https://github.com/fastify/fastify-diagnostics-channel)
Plugin to deal with `diagnostics_channel` on Fastify
- [`fastify-elasticsearch`](https://github.com/fastify/fastify-elasticsearch)
- [`@fastify/elasticsearch`](https://github.com/fastify/fastify-elasticsearch)
Plugin to share the same ES client.
- [`fastify-env`](https://github.com/fastify/fastify-env) Load and check
- [`@fastify/env`](https://github.com/fastify/fastify-env) Load and check
configuration.
- [`fastify-etag`](https://github.com/fastify/fastify-etag) Automatically
- [`@fastify/etag`](https://github.com/fastify/fastify-etag) Automatically
generate ETags for HTTP responses.
- [`fastify-flash`](https://github.com/fastify/fastify-flash) Set and get flash
- [`@fastify/flash`](https://github.com/fastify/fastify-flash) Set and get flash
messages using the session.
- [`fastify-formbody`](https://github.com/fastify/fastify-formbody) Plugin to
- [`@fastify/formbody`](https://github.com/fastify/fastify-formbody) Plugin to
parse x-www-form-urlencoded bodies.
- [`fastify-funky`](https://github.com/fastify/fastify-funky) Makes functional
- [`@fastify/funky`](https://github.com/fastify/fastify-funky) Makes functional
programming in Fastify more convenient. Adds support for Fastify routes
returning functional structures, such as Either, Task or plain parameterless
function.
- [`fastify-helmet`](https://github.com/fastify/fastify-helmet) Important
- [`@fastify/helmet`](https://github.com/fastify/fastify-helmet) Important
security headers for Fastify.
- [`fastify-http-proxy`](https://github.com/fastify/fastify-http-proxy) Proxy
- [`@fastify/http-proxy`](https://github.com/fastify/fastify-http-proxy) Proxy
your HTTP requests to another server, with hooks.
- [`fastify-jwt`](https://github.com/fastify/fastify-jwt) JWT utils for Fastify,
- [`@fastify/jwt`](https://github.com/fastify/fastify-jwt) JWT utils for Fastify,
internally uses [fast-jwt](https://github.com/nearform/fast-jwt).
- [`fastify-leveldb`](https://github.com/fastify/fastify-leveldb) Plugin to
- [`@fastify/leveldb`](https://github.com/fastify/fastify-leveldb) Plugin to
share a common LevelDB connection across Fastify.
- [`fastify-mongodb`](https://github.com/fastify/fastify-mongodb) Fastify
- [`@fastify/mongodb`](https://github.com/fastify/fastify-mongodb) Fastify
MongoDB connection plugin, with which you can share the same MongoDB
connection pool across every part of your server.
- [`fastify-multipart`](https://github.com/fastify/fastify-multipart) Multipart
- [`@fastify/multipart`](https://github.com/fastify/fastify-multipart) Multipart
support for Fastify.
- [`fastify-oauth2`](https://github.com/fastify/fastify-oauth2) Wrap around
- [`@fastify/oauth2`](https://github.com/fastify/fastify-oauth2) Wrap around
[`simple-oauth2`](https://github.com/lelylan/simple-oauth2).
- [`fastify-postgres`](https://github.com/fastify/fastify-postgres) Fastify
- [`@fastify/postgres`](https://github.com/fastify/fastify-postgres) Fastify
PostgreSQL connection plugin, with this you can share the same PostgreSQL
connection pool in every part of your server.
- [`fastify-rate-limit`](https://github.com/fastify/fastify-rate-limit) A low
- [`@fastify/rate-limit`](https://github.com/fastify/fastify-rate-limit) A low
overhead rate limiter for your routes.
- [`fastify-request-context`](https://github.com/fastify/fastify-request-context)
- [`@fastify/request-context`](https://github.com/fastify/fastify-request-context)
Request-scoped storage, based on
[AsyncLocalStorage](https://nodejs.org/api/async_hooks.html#async_hooks_class_asynclocalstorage)
(with fallback to [cls-hooked](https://github.com/Jeff-Lewis/cls-hooked)),
providing functionality similar to thread-local storages.
- [`fastify-response-validation`](https://github.com/fastify/fastify-response-validation)
- [`@fastify/response-validation`](https://github.com/fastify/fastify-response-validation)
A simple plugin that enables response validation for Fastify.
- [`fastify-nextjs`](https://github.com/fastify/fastify-nextjs) React
- [`@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
- [`@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
- [`@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
- [`@fastify/routes`](https://github.com/fastify/fastify-routes) Plugin that
provides a `Map` of routes.
- [`fastify-schedule`](https://github.com/fastify/fastify-schedule) Plugin for
scheduling periodic jobs, based on
[toad-scheduler](https://github.com/kibertoad/toad-scheduler).
- [`fastify-sensible`](https://github.com/fastify/fastify-sensible) Defaults for
- [`@fastify/sensible`](https://github.com/fastify/fastify-sensible) Defaults for
Fastify that everyone can agree on. It adds some useful decorators such as
HTTP errors and assertions, but also more request and reply methods.
- [`@fastify/session`](https://github.com/fastify/session) a session plugin for
Fastify.
- [`fastify-static`](https://github.com/fastify/fastify-static) Plugin for
- [`@fastify/static`](https://github.com/fastify/fastify-static) Plugin for
serving static files as fast as possible.
- [`fastify-swagger`](https://github.com/fastify/fastify-swagger) Plugin for
- [`@fastify/swagger`](https://github.com/fastify/fastify-swagger) Plugin for
serving Swagger/OpenAPI documentation for Fastify, supporting dynamic
generation.
- [`fastify-websocket`](https://github.com/fastify/fastify-websocket) WebSocket
- [`@fastify/websocket`](https://github.com/fastify/fastify-websocket) WebSocket
support for Fastify. Built upon [ws](https://github.com/websockets/ws).
- [`fastify-url-data`](https://github.com/fastify/fastify-url-data) Decorate the
- [`@fastify/url-data`](https://github.com/fastify/fastify-url-data) Decorate the
`Request` object with a method to access raw URL components.
- [`middie`](https://github.com/fastify/middie) Middleware engine for Fastify.
- [`point-of-view`](https://github.com/fastify/point-of-view) Templates
Expand Down
8 changes: 4 additions & 4 deletions docs/Guides/Getting-Started.md
Expand Up @@ -195,10 +195,10 @@ Fastify handles this internally, with minimum effort!
Let's rewrite the above example with a database connection.


First, install `fastify-plugin` and `fastify-mongodb`:
First, install `fastify-plugin` and `@fastify/mongodb`:

```
npm i --save fastify-plugin fastify-mongodb
npm i --save fastify-plugin @fastify/mongodb
```

**server.js**
Expand Down Expand Up @@ -246,7 +246,7 @@ fastify.listen(3000, function (err, address) {
```js
// ESM
import fastifyPlugin from 'fastify-plugin'
import fastifyMongo from 'fastify-mongodb'
import fastifyMongo from '@fastify/mongodb'

async function dbConnector (fastify, options) {
fastify.register(fastifyMongo, {
Expand All @@ -265,7 +265,7 @@ module.exports = fastifyPlugin(dbConnector)
const fastifyPlugin = require('fastify-plugin')

async function dbConnector (fastify, options) {
fastify.register(require('fastify-mongodb'), {
fastify.register(require('@fastify/mongodb'), {
url: 'mongodb://localhost:27017/test_database'
})
}
Expand Down
4 changes: 2 additions & 2 deletions docs/Guides/Migration-Guide-V3.md
Expand Up @@ -14,7 +14,7 @@ From Fastify v3, middleware support does not come out-of-the-box with the
framework itself.

If you use Express middleware in your application, please install and register
the [`fastify-express`](https://github.com/fastify/fastify-express) or
the [`@fastify/express`](https://github.com/fastify/fastify-express) or
[`middie`](https://github.com/fastify/middie) plugin before doing so.

**v2:**
Expand All @@ -28,7 +28,7 @@ fastify.use(require('cors')());

```js
// Using the Express `cors` middleware in Fastify v3.
await fastify.register(require('fastify-express'));
await fastify.register(require('@fastify/express'));
fastify.use(require('cors')());
```

Expand Down
10 changes: 5 additions & 5 deletions docs/Guides/Plugins-Guide.md
Expand Up @@ -445,10 +445,10 @@ fastify

If your plugin needs to expose custom errors, you can easily generate consistent
error objects across your codebase and plugins with the
[`fastify-error`](https://github.com/fastify/fastify-error) module.
[`@fastify/error`](https://github.com/fastify/fastify-error) module.

```js
const createError = require('fastify-error')
const createError = require('@fastify/error')
const CustomError = createError('ERROR_CODE', 'message')
console.log(new CustomError())
```
Expand Down Expand Up @@ -477,12 +477,12 @@ section of our documentation!
If you want to see some real-world examples, check out:
- [`point-of-view`](https://github.com/fastify/point-of-view) Templates
rendering (*ejs, pug, handlebars, marko*) plugin support for Fastify.
- [`fastify-mongodb`](https://github.com/fastify/fastify-mongodb) Fastify
- [`@fastify/mongodb`](https://github.com/fastify/fastify-mongodb) Fastify
MongoDB connection plugin, with this you can share the same MongoDB connection
pool in every part of your server.
- [`fastify-multipart`](https://github.com/fastify/fastify-multipart) Multipart
- [`@fastify/multipart`](https://github.com/fastify/fastify-multipart) Multipart
support for Fastify
- [`fastify-helmet`](https://github.com/fastify/fastify-helmet) Important
- [`@fastify/helmet`](https://github.com/fastify/fastify-helmet) Important
security headers for Fastify


Expand Down
12 changes: 6 additions & 6 deletions docs/Guides/Write-Plugin.md
Expand Up @@ -33,9 +33,9 @@ unused.

If you want to see some good examples on how to document a plugin take a look
at:
- [`fastify-caching`](https://github.com/fastify/fastify-caching)
- [`fastify-compress`](https://github.com/fastify/fastify-compress)
- [`fastify-cookie`](https://github.com/fastify/fastify-cookie)
- [`@fastify/caching`](https://github.com/fastify/fastify-caching)
- [`@fastify/compress`](https://github.com/fastify/fastify-compress)
- [`@fastify/cookie`](https://github.com/fastify/fastify-cookie)
- [`point-of-view`](https://github.com/fastify/point-of-view)
- [`under-pressure`](https://github.com/fastify/under-pressure)

Expand Down Expand Up @@ -93,10 +93,10 @@ our documentation!
If you want to see some real world examples, check out:
- [`point-of-view`](https://github.com/fastify/point-of-view) Templates
rendering (*ejs, pug, handlebars, marko*) plugin support for Fastify.
- [`fastify-mongodb`](https://github.com/fastify/fastify-mongodb) Fastify
- [`@fastify/mongodb`](https://github.com/fastify/fastify-mongodb) Fastify
MongoDB connection plugin, with this you can share the same MongoDB connection
pool in every part of your server.
- [`fastify-multipart`](https://github.com/fastify/fastify-multipart) Multipart
- [`@fastify/multipart`](https://github.com/fastify/fastify-multipart) Multipart
support for Fastify.
- [`fastify-helmet`](https://github.com/fastify/fastify-helmet) Important
- [`@fastify/helmet`](https://github.com/fastify/fastify-helmet) Important
security headers for Fastify.
6 changes: 3 additions & 3 deletions docs/Reference/Encapsulation.md
Expand Up @@ -33,7 +33,7 @@ this example into concrete terms, consider a basic scenario of a REST API
server that has three routes: the first route (`/one`) requires authentication,
the second route (`/two`) does not, and the third route (`/three`) has
access to the same context as the second route. Using
[fastify-bearer-auth][bearer] to provide the authentication, the code for this
[@fastify/bearer-auth][bearer] to provide the authentication, the code for this
example is as follows:

```js
Expand All @@ -44,7 +44,7 @@ const fastify = require('fastify')()
fastify.decorateRequest('answer', 42)

fastify.register(async function authenticatedContext (childServer) {
childServer.register(require('fastify-bearer-auth'), { keys: ['abc123'] })
childServer.register(require('@fastify/bearer-auth'), { keys: ['abc123'] })

childServer.route({
path: '/one',
Expand Down Expand Up @@ -103,7 +103,7 @@ original diagram:
1. Each _child context_ (`authenticatedContext`, `publicContext`, and
`grandchildContext`) has access to the `answer` request decorator defined in
the _root context_.
2. Only the `authenticatedContext` has access to the `fastify-bearer-auth`
2. Only the `authenticatedContext` has access to the `@fastify/bearer-auth`
plugin.
3. Both the `publicContext` and `grandchildContext` have access to the `foo`
request decorator.
Expand Down
2 changes: 1 addition & 1 deletion docs/Reference/Hooks.md
Expand Up @@ -351,7 +351,7 @@ fastify.addHook('preHandler', async (request, reply) => {
})

fastify.addHook('preHandler', async (request, reply) => {
// the fastify-static plugin will send a file asynchronously,
// the @fastify/static plugin will send a file asynchronously,
// so we should return reply
reply.sendFile('myfile')
return reply
Expand Down
12 changes: 6 additions & 6 deletions docs/Reference/Middleware.md
Expand Up @@ -4,16 +4,16 @@

Starting with Fastify v3.0.0, middleware is not supported out of the box and
requires an external plugin such as
[`fastify-express`](https://github.com/fastify/fastify-express) or
[`@fastify/express`](https://github.com/fastify/fastify-express) or
[`middie`](https://github.com/fastify/middie).


An example of registering the
[`fastify-express`](https://github.com/fastify/fastify-express) plugin to `use`
[`@fastify/express`](https://github.com/fastify/fastify-express) plugin to `use`
Express middleware:

```js
await fastify.register(require('fastify-express'))
await fastify.register(require('@fastify/express'))
fastify.use(require('cors')())
fastify.use(require('dns-prefetch-control')())
fastify.use(require('frameguard')())
Expand Down Expand Up @@ -70,9 +70,9 @@ fastify.use(['/css', '/js'], serveStatic(path.join(__dirname, '/assets')))
### Alternatives

Fastify offers some alternatives to the most commonly used middleware, such as
[`fastify-helmet`](https://github.com/fastify/fastify-helmet) in case of
[`@fastify/helmet`](https://github.com/fastify/fastify-helmet) in case of
[`helmet`](https://github.com/helmetjs/helmet),
[`fastify-cors`](https://github.com/fastify/fastify-cors) for
[`@fastify/cors`](https://github.com/fastify/fastify-cors) for
[`cors`](https://github.com/expressjs/cors), and
[`fastify-static`](https://github.com/fastify/fastify-static) for
[`@fastify/static`](https://github.com/fastify/fastify-static) for
[`serve-static`](https://github.com/expressjs/serve-static).
2 changes: 1 addition & 1 deletion docs/Reference/Reply.md
Expand Up @@ -483,7 +483,7 @@ be used to enhance the HTTP response.

Tip: you can simplify errors by using the
[`http-errors`](https://npm.im/http-errors) module or
[`fastify-sensible`](https://github.com/fastify/fastify-sensible) plugin to
[`@fastify/sensible`](https://github.com/fastify/fastify-sensible) plugin to
generate errors:

```js
Expand Down
2 changes: 1 addition & 1 deletion docs/Reference/TypeScript.md
Expand Up @@ -604,7 +604,7 @@ newer, automatically adds `.default` property and a named export to the exported
plugin. Be sure to `export default` and `export const myPlugin` in your typings
to provide the best developer experience. For a complete example you can check
out
[fastify-swagger](https://github.com/fastify/fastify-swagger/blob/master/index.d.ts).
[@fastify/swagger](https://github.com/fastify/fastify-swagger/blob/master/index.d.ts).

With those files completed, the plugin is now ready to be consumed by any
TypeScript project!
Expand Down

0 comments on commit e94cd92

Please sign in to comment.