To set a timeout for a middleware, you can use the timeout()
method provided by the httpMiddleware.for()
function.
Here's an example of setting a timeout of 5 seconds for a middleware:
import { httpMiddleware } from '@deepkit/http'; // ... new App({ // ... middlewares: [ httpMiddleware.for(MyMiddleware).timeout(5000), ], // ... }).run();
This sets a timeout of 5 seconds for the execution of the middleware. If the middleware does not call the next()
function within the given timeout, Deepkit HTTP will log a warning and proceed with the request handling.