Implement json request compression
This commit is contained in:
@@ -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';
|
||||
|
||||
|
||||
11
src/ZlibCoder.ts
Normal file
11
src/ZlibCoder.ts
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
// process.on('exit', cleanup);
|
||||
// process.on('SIGINT', cleanup);
|
||||
// process.on('SIGUSR1', cleanup);
|
||||
// process.on('SIGUSR2', cleanup);
|
||||
Reference in New Issue
Block a user