Skip to content

Commit 7309bbc

Browse files
docs: add information on use with fastify (#733)
Co-authored-by: Alexander Akait <[email protected]>
1 parent 49ac96b commit 7309bbc

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ app.use(
5555
app.listen(3000, () => console.log('Example app listening on port 3000!'));
5656
```
5757

58+
See [below](#other-servers) for an example of use with fastify.
59+
5860
## Options
5961

6062
The middleware accepts an `options` Object. The following is a property reference for the Object.
@@ -340,6 +342,30 @@ a modification, please feel free to create an issue on Github. _Note: The issue
340342
template isn't optional, so please be sure not to remove it, and please fill it
341343
out completely._
342344

345+
## Other servers
346+
347+
Examples of use with other servers will follow here.
348+
349+
### Fastify
350+
351+
Fastify interop will require the use of `fastify-express` instead of `middie` for providing middleware support. As the authors of `fastify-express` recommend, this should only be used as a stopgap while full Fastify support is worked on.
352+
353+
```js
354+
const fastify = require('fastify')()
355+
const webpack = require('webpack')
356+
const webpackConfig = require('./webpack.config.js')
357+
const devMiddleware = require('webpack-dev-middleware')
358+
359+
const compiler = webpack(webpackConfig)
360+
const { publicPath } = webpackConfig.output
361+
362+
;(async () => {
363+
await fastify.register(require('fastify-express'))
364+
await fastify.use(devMiddleware(compiler, { publicPath }))
365+
await fastify.listen(3000)
366+
})()
367+
```
368+
343369
## Contributing
344370

345371
Please take a moment to read our contributing guidelines if you haven't yet done so.

0 commit comments

Comments
 (0)