Skip to content

Commit 2c19e4e

Browse files
author
Arjan Singh
committed
Add middlewarehooks documentation
1 parent ea0be49 commit 2c19e4e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,22 @@ let server = new FastBootAppServer({
103103
server.start();
104104
```
105105

106+
## Pre and Post FastBoot middleware hooks
107+
108+
If you need something less than a custom server and just want to run some middleware
109+
before or after FastBoot runs, the server provides hooks for you to do so:
110+
111+
```js
112+
// Custom Middlewares
113+
function modifyRequest(req, res, next) { /* do pre-fastboot stuff to `req` */ };
114+
function handleErrors(err, req, res, next) { /* do error recovery stuff */ };
115+
116+
const server = FastBootAppServer({
117+
preFastbootMiddlewares: function (app) { app.use(modifyRequest); },
118+
postFastbootMiddlewares: function (app) { app.use(handleErrors); }
119+
})
120+
```
121+
106122
## Downloaders
107123

108124
You can point the app server at a static path that you manage, but that

0 commit comments

Comments
 (0)