Questions & Answers

How can I use Express middlewares?

Deepkit HTTP
50 up-votes
Warning: The answer is generated by an artificial intelligence. It might not be correct.
To adjust rating, open the thread in Discord and click on the up/down vote button.

Deepkit HTTP supports most of the Express middlewares. To use an Express middleware in Deepkit HTTP, you can simply import it from the respective package and use it with httpMiddleware.for().

Here's an example of using the compression middleware:

import * as compression from 'compression';
import { httpMiddleware } from '@deepkit/http';

// ...

new App({
  // ...
  middlewares: [
    httpMiddleware.for(compression()),
  ],
  // ...
}).run();

You can use any other Express middleware in a similar way.