diff --git a/package.json b/package.json index 92b4af6..4a68a5d 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "nanotimer": "^0.3.15", "smpp": "^0.6.0-rc.4", "ts-node": "^10.9.1", - "ws": "^8.13.0" + "ws": "^8.13.0", + "zlib": "^1.0.5" } } diff --git a/src/HttpServer/HttpServer.ts b/src/HttpServer/HttpServer.ts index 3742a14..518458c 100644 --- a/src/HttpServer/HttpServer.ts +++ b/src/HttpServer/HttpServer.ts @@ -6,6 +6,8 @@ import {RequestHandler} from "./RequestHandler"; const express = require("express"); const bodyParser = require("body-parser"); +const compression = require("compression"); +const zlib = require("zlib"); const SERVER_PORT: number = Number(process.env.SERVER_PORT) || 8190; @@ -24,6 +26,11 @@ export class HttpServer { this.app = express(); this.app.use(bodyParser.json()); + this.app.use(compression({ + level: 9, + strategy: zlib.constants.BROTLI_MODE_TEXT, + })); + let clientApiPath: string = 'ClientEntity'; let centerApiPath: string = 'CenterEntity'; diff --git a/src/ZlibCoder.ts b/src/ZlibCoder.ts new file mode 100644 index 0000000..a77bb3c --- /dev/null +++ b/src/ZlibCoder.ts @@ -0,0 +1,11 @@ +const zlib = require("zlib"); + +export default class ZlibCoder { + static compress(input: string): Buffer { + return zlib.compress(input); + } + + static decompress(input: Buffer): string { + return zlib.decompress(input).toString(); + } +} \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 1e4bddf..4015f56 100644 --- a/src/main.ts +++ b/src/main.ts @@ -29,7 +29,7 @@ function cleanup(): void { process.exit(0); } -process.on('exit', cleanup); -process.on('SIGINT', cleanup); -process.on('SIGUSR1', cleanup); -process.on('SIGUSR2', cleanup); \ No newline at end of file +// process.on('exit', cleanup); +// process.on('SIGINT', cleanup); +// process.on('SIGUSR1', cleanup); +// process.on('SIGUSR2', cleanup); \ No newline at end of file