From 252aa9c349ed7df044a0934dac6bb47ca8795e71 Mon Sep 17 00:00:00 2001 From: Yosi Attias Date: Sun, 9 Jan 2022 19:52:29 +0200 Subject: [PATCH] uServer: accept compression option --- lib/userver.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/userver.ts b/lib/userver.ts index 76c9a41d..422fc2ec 100644 --- a/lib/userver.ts +++ b/lib/userver.ts @@ -1,6 +1,6 @@ import debugModule from "debug"; import { AttachOptions, BaseServer, Server } from "./server"; -import { HttpRequest, HttpResponse } from "uWebSockets.js"; +import { HttpRequest, HttpResponse, CompressOptions } from "uWebSockets.js"; import transports from "./transports-uws"; const debug = debugModule("engine:uws"); @@ -39,13 +39,17 @@ export class uServer extends BaseServer { * @param app * @param options */ - public attach(app /* : TemplatedApp */, options: AttachOptions = {}) { + public attach( + app /* : TemplatedApp */, + options: AttachOptions & Partial<{ compression: CompressOptions }> = {} + ) { const path = (options.path || "/engine.io").replace(/\/$/, "") + "/"; app .any(path, this.handleRequest.bind(this)) // .ws(path, { + compression: options.compression, maxPayloadLength: this.opts.maxHttpBufferSize, upgrade: this.handleUpgrade.bind(this), open: ws => {