To handle different types of content encodings, such as compression, you can use the compression middleware provided by the @deepkit/http
module.
Here is an example of how to use the compression middleware:
import * as express from 'express'; import { Server } from 'http'; import { HttpRequest, HttpResponse, httpMiddleware } from '@deepkit/http'; const app = express(); app.use(httpMiddleware.for(compression())); app.get('/', (req: HttpRequest, res: HttpResponse) => { res.send('Hello World!'); }); const server = new Server(app); server.listen(3000, () => { console.log('Server listening on port 3000'); });
In this example, the compression middleware is added to the express app using app.use(httpMiddleware.for(compression()))
. This enables compression for all routes in the app.