Spaces:
Build error
Build error
saas: use compression
Browse files- package-lock.json +80 -0
- package.json +2 -0
- src/stand-alone/crawl.ts +18 -0
- src/stand-alone/search.ts +18 -0
- src/stand-alone/serp.ts +18 -0
package-lock.json
CHANGED
|
@@ -26,6 +26,7 @@
|
|
| 26 |
"htmlparser2": "^9.0.0",
|
| 27 |
"jose": "^5.1.0",
|
| 28 |
"koa": "^2.16.0",
|
|
|
|
| 29 |
"langdetect": "^0.2.1",
|
| 30 |
"linkedom": "^0.18.4",
|
| 31 |
"lru-cache": "^11.0.2",
|
|
@@ -54,6 +55,7 @@
|
|
| 54 |
"@types/busboy": "^1.5.4",
|
| 55 |
"@types/cors": "^2.8.17",
|
| 56 |
"@types/koa": "^2.15.0",
|
|
|
|
| 57 |
"@types/node": "^20.14.13",
|
| 58 |
"@types/set-cookie-parser": "^2.4.7",
|
| 59 |
"@types/xmldom": "^0.1.34",
|
|
@@ -2508,6 +2510,17 @@
|
|
| 2508 |
"@types/koa": "*"
|
| 2509 |
}
|
| 2510 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2511 |
"node_modules/@types/lodash": {
|
| 2512 |
"version": "4.17.0",
|
| 2513 |
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.0.tgz",
|
|
@@ -4197,6 +4210,18 @@
|
|
| 4197 |
"node": ">= 12.0.0"
|
| 4198 |
}
|
| 4199 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4200 |
"node_modules/concat-map": {
|
| 4201 |
"version": "0.0.1",
|
| 4202 |
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
|
@@ -8313,6 +8338,55 @@
|
|
| 8313 |
"resolved": "https://registry.npmjs.org/koa-compose/-/koa-compose-4.1.0.tgz",
|
| 8314 |
"integrity": "sha512-8ODW8TrDuMYvXRwra/Kh7/rJo9BtOfPc6qO8eAfC80CnCvSjSl0bkRM24X6/XBBEyj0v1nRUQ1LyOy3dbqOWXw=="
|
| 8315 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8316 |
"node_modules/koa-convert": {
|
| 8317 |
"version": "2.0.0",
|
| 8318 |
"resolved": "https://registry.npmjs.org/koa-convert/-/koa-convert-2.0.0.tgz",
|
|
@@ -8325,6 +8399,12 @@
|
|
| 8325 |
"node": ">= 10"
|
| 8326 |
}
|
| 8327 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8328 |
"node_modules/koa/node_modules/http-errors": {
|
| 8329 |
"version": "1.8.1",
|
| 8330 |
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz",
|
|
|
|
| 26 |
"htmlparser2": "^9.0.0",
|
| 27 |
"jose": "^5.1.0",
|
| 28 |
"koa": "^2.16.0",
|
| 29 |
+
"koa-compress": "^5.1.1",
|
| 30 |
"langdetect": "^0.2.1",
|
| 31 |
"linkedom": "^0.18.4",
|
| 32 |
"lru-cache": "^11.0.2",
|
|
|
|
| 55 |
"@types/busboy": "^1.5.4",
|
| 56 |
"@types/cors": "^2.8.17",
|
| 57 |
"@types/koa": "^2.15.0",
|
| 58 |
+
"@types/koa-compress": "^4.0.6",
|
| 59 |
"@types/node": "^20.14.13",
|
| 60 |
"@types/set-cookie-parser": "^2.4.7",
|
| 61 |
"@types/xmldom": "^0.1.34",
|
|
|
|
| 2510 |
"@types/koa": "*"
|
| 2511 |
}
|
| 2512 |
},
|
| 2513 |
+
"node_modules/@types/koa-compress": {
|
| 2514 |
+
"version": "4.0.6",
|
| 2515 |
+
"resolved": "https://registry.npmjs.org/@types/koa-compress/-/koa-compress-4.0.6.tgz",
|
| 2516 |
+
"integrity": "sha512-jJzlsQTeIXRfQzY7y2Dl/syqOxvEaNJzFTJ8ZGaDFWvqgMmCXplfCGjPfHQgU7xYNKq/mCdN3YWus1YOldfIwg==",
|
| 2517 |
+
"dev": true,
|
| 2518 |
+
"license": "MIT",
|
| 2519 |
+
"dependencies": {
|
| 2520 |
+
"@types/koa": "*",
|
| 2521 |
+
"@types/node": "*"
|
| 2522 |
+
}
|
| 2523 |
+
},
|
| 2524 |
"node_modules/@types/lodash": {
|
| 2525 |
"version": "4.17.0",
|
| 2526 |
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.0.tgz",
|
|
|
|
| 4210 |
"node": ">= 12.0.0"
|
| 4211 |
}
|
| 4212 |
},
|
| 4213 |
+
"node_modules/compressible": {
|
| 4214 |
+
"version": "2.0.18",
|
| 4215 |
+
"resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.18.tgz",
|
| 4216 |
+
"integrity": "sha512-AF3r7P5dWxL8MxyITRMlORQNaOA2IkAFaTr4k7BUumjPtRpGDTZpl0Pb1XCO6JeDCBdp126Cgs9sMxqSjgYyRg==",
|
| 4217 |
+
"license": "MIT",
|
| 4218 |
+
"dependencies": {
|
| 4219 |
+
"mime-db": ">= 1.43.0 < 2"
|
| 4220 |
+
},
|
| 4221 |
+
"engines": {
|
| 4222 |
+
"node": ">= 0.6"
|
| 4223 |
+
}
|
| 4224 |
+
},
|
| 4225 |
"node_modules/concat-map": {
|
| 4226 |
"version": "0.0.1",
|
| 4227 |
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
|
|
|
| 8338 |
"resolved": "https://registry.npmjs.org/koa-compose/-/koa-compose-4.1.0.tgz",
|
| 8339 |
"integrity": "sha512-8ODW8TrDuMYvXRwra/Kh7/rJo9BtOfPc6qO8eAfC80CnCvSjSl0bkRM24X6/XBBEyj0v1nRUQ1LyOy3dbqOWXw=="
|
| 8340 |
},
|
| 8341 |
+
"node_modules/koa-compress": {
|
| 8342 |
+
"version": "5.1.1",
|
| 8343 |
+
"resolved": "https://registry.npmjs.org/koa-compress/-/koa-compress-5.1.1.tgz",
|
| 8344 |
+
"integrity": "sha512-UgMIN7ZoEP2DuoSQmD6CYvFSLt0NReGlc2qSY4bO4Oq0L56OiD9pDG41Kj/zFmVY/A3Wvmn4BqKcfq5H30LGIg==",
|
| 8345 |
+
"license": "MIT",
|
| 8346 |
+
"dependencies": {
|
| 8347 |
+
"bytes": "^3.1.2",
|
| 8348 |
+
"compressible": "^2.0.18",
|
| 8349 |
+
"http-errors": "^1.8.1",
|
| 8350 |
+
"koa-is-json": "^1.0.0"
|
| 8351 |
+
},
|
| 8352 |
+
"engines": {
|
| 8353 |
+
"node": ">= 12"
|
| 8354 |
+
}
|
| 8355 |
+
},
|
| 8356 |
+
"node_modules/koa-compress/node_modules/depd": {
|
| 8357 |
+
"version": "1.1.2",
|
| 8358 |
+
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
|
| 8359 |
+
"integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==",
|
| 8360 |
+
"license": "MIT",
|
| 8361 |
+
"engines": {
|
| 8362 |
+
"node": ">= 0.6"
|
| 8363 |
+
}
|
| 8364 |
+
},
|
| 8365 |
+
"node_modules/koa-compress/node_modules/http-errors": {
|
| 8366 |
+
"version": "1.8.1",
|
| 8367 |
+
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz",
|
| 8368 |
+
"integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==",
|
| 8369 |
+
"license": "MIT",
|
| 8370 |
+
"dependencies": {
|
| 8371 |
+
"depd": "~1.1.2",
|
| 8372 |
+
"inherits": "2.0.4",
|
| 8373 |
+
"setprototypeof": "1.2.0",
|
| 8374 |
+
"statuses": ">= 1.5.0 < 2",
|
| 8375 |
+
"toidentifier": "1.0.1"
|
| 8376 |
+
},
|
| 8377 |
+
"engines": {
|
| 8378 |
+
"node": ">= 0.6"
|
| 8379 |
+
}
|
| 8380 |
+
},
|
| 8381 |
+
"node_modules/koa-compress/node_modules/statuses": {
|
| 8382 |
+
"version": "1.5.0",
|
| 8383 |
+
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
|
| 8384 |
+
"integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==",
|
| 8385 |
+
"license": "MIT",
|
| 8386 |
+
"engines": {
|
| 8387 |
+
"node": ">= 0.6"
|
| 8388 |
+
}
|
| 8389 |
+
},
|
| 8390 |
"node_modules/koa-convert": {
|
| 8391 |
"version": "2.0.0",
|
| 8392 |
"resolved": "https://registry.npmjs.org/koa-convert/-/koa-convert-2.0.0.tgz",
|
|
|
|
| 8399 |
"node": ">= 10"
|
| 8400 |
}
|
| 8401 |
},
|
| 8402 |
+
"node_modules/koa-is-json": {
|
| 8403 |
+
"version": "1.0.0",
|
| 8404 |
+
"resolved": "https://registry.npmjs.org/koa-is-json/-/koa-is-json-1.0.0.tgz",
|
| 8405 |
+
"integrity": "sha512-+97CtHAlWDx0ndt0J8y3P12EWLwTLMXIfMnYDev3wOTwH/RpBGMlfn4bDXlMEg1u73K6XRE9BbUp+5ZAYoRYWw==",
|
| 8406 |
+
"license": "MIT"
|
| 8407 |
+
},
|
| 8408 |
"node_modules/koa/node_modules/http-errors": {
|
| 8409 |
"version": "1.8.1",
|
| 8410 |
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz",
|
package.json
CHANGED
|
@@ -35,6 +35,7 @@
|
|
| 35 |
"htmlparser2": "^9.0.0",
|
| 36 |
"jose": "^5.1.0",
|
| 37 |
"koa": "^2.16.0",
|
|
|
|
| 38 |
"langdetect": "^0.2.1",
|
| 39 |
"linkedom": "^0.18.4",
|
| 40 |
"lru-cache": "^11.0.2",
|
|
@@ -63,6 +64,7 @@
|
|
| 63 |
"@types/busboy": "^1.5.4",
|
| 64 |
"@types/cors": "^2.8.17",
|
| 65 |
"@types/koa": "^2.15.0",
|
|
|
|
| 66 |
"@types/node": "^20.14.13",
|
| 67 |
"@types/set-cookie-parser": "^2.4.7",
|
| 68 |
"@types/xmldom": "^0.1.34",
|
|
|
|
| 35 |
"htmlparser2": "^9.0.0",
|
| 36 |
"jose": "^5.1.0",
|
| 37 |
"koa": "^2.16.0",
|
| 38 |
+
"koa-compress": "^5.1.1",
|
| 39 |
"langdetect": "^0.2.1",
|
| 40 |
"linkedom": "^0.18.4",
|
| 41 |
"lru-cache": "^11.0.2",
|
|
|
|
| 64 |
"@types/busboy": "^1.5.4",
|
| 65 |
"@types/cors": "^2.8.17",
|
| 66 |
"@types/koa": "^2.15.0",
|
| 67 |
+
"@types/koa-compress": "^4.0.6",
|
| 68 |
"@types/node": "^20.14.13",
|
| 69 |
"@types/set-cookie-parser": "^2.4.7",
|
| 70 |
"@types/xmldom": "^0.1.34",
|
src/stand-alone/crawl.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { ThreadedServiceRegistry } from '../services/threaded';
|
|
| 18 |
import { GlobalLogger } from '../services/logger';
|
| 19 |
import { AsyncLocalContext } from '../services/async-context';
|
| 20 |
import finalizer, { Finalizer } from '../services/finalizer';
|
|
|
|
| 21 |
|
| 22 |
@singleton()
|
| 23 |
export class CrawlStandAloneServer extends KoaServer {
|
|
@@ -98,6 +99,23 @@ export class CrawlStandAloneServer extends KoaServer {
|
|
| 98 |
}
|
| 99 |
|
| 100 |
registerRoutes(): void {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
this.koaApp.use(this.makeAssetsServingController());
|
| 102 |
this.koaApp.use(this.registry.makeShimController());
|
| 103 |
}
|
|
|
|
| 18 |
import { GlobalLogger } from '../services/logger';
|
| 19 |
import { AsyncLocalContext } from '../services/async-context';
|
| 20 |
import finalizer, { Finalizer } from '../services/finalizer';
|
| 21 |
+
import koaCompress from 'koa-compress';
|
| 22 |
|
| 23 |
@singleton()
|
| 24 |
export class CrawlStandAloneServer extends KoaServer {
|
|
|
|
| 99 |
}
|
| 100 |
|
| 101 |
registerRoutes(): void {
|
| 102 |
+
this.koaApp.use(koaCompress({
|
| 103 |
+
filter(type) {
|
| 104 |
+
if (type.startsWith('text/')) {
|
| 105 |
+
return true;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
if (type.includes('application/json') || type.includes('+json') || type.includes('+xml')) {
|
| 109 |
+
return true;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
if (type.includes('application/x-ndjson')) {
|
| 113 |
+
return true;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
return false;
|
| 117 |
+
}
|
| 118 |
+
}));
|
| 119 |
this.koaApp.use(this.makeAssetsServingController());
|
| 120 |
this.koaApp.use(this.registry.makeShimController());
|
| 121 |
}
|
src/stand-alone/search.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { ThreadedServiceRegistry } from '../services/threaded';
|
|
| 18 |
import { GlobalLogger } from '../services/logger';
|
| 19 |
import { AsyncLocalContext } from '../services/async-context';
|
| 20 |
import finalizer, { Finalizer } from '../services/finalizer';
|
|
|
|
| 21 |
|
| 22 |
@singleton()
|
| 23 |
export class SearchStandAloneServer extends KoaServer {
|
|
@@ -106,6 +107,23 @@ export class SearchStandAloneServer extends KoaServer {
|
|
| 106 |
}
|
| 107 |
|
| 108 |
registerRoutes(): void {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
this.koaApp.use(this.makeAssetsServingController());
|
| 110 |
this.koaApp.use(this.registry.makeShimController());
|
| 111 |
}
|
|
|
|
| 18 |
import { GlobalLogger } from '../services/logger';
|
| 19 |
import { AsyncLocalContext } from '../services/async-context';
|
| 20 |
import finalizer, { Finalizer } from '../services/finalizer';
|
| 21 |
+
import koaCompress from 'koa-compress';
|
| 22 |
|
| 23 |
@singleton()
|
| 24 |
export class SearchStandAloneServer extends KoaServer {
|
|
|
|
| 107 |
}
|
| 108 |
|
| 109 |
registerRoutes(): void {
|
| 110 |
+
this.koaApp.use(koaCompress({
|
| 111 |
+
filter(type) {
|
| 112 |
+
if (type.startsWith('text/')) {
|
| 113 |
+
return true;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
if (type.includes('application/json') || type.includes('+json') || type.includes('+xml')) {
|
| 117 |
+
return true;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
if (type.includes('application/x-ndjson')) {
|
| 121 |
+
return true;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
return false;
|
| 125 |
+
}
|
| 126 |
+
}));
|
| 127 |
this.koaApp.use(this.makeAssetsServingController());
|
| 128 |
this.koaApp.use(this.registry.makeShimController());
|
| 129 |
}
|
src/stand-alone/serp.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { GlobalLogger } from '../services/logger';
|
|
| 18 |
import { AsyncLocalContext } from '../services/async-context';
|
| 19 |
import finalizer, { Finalizer } from '../services/finalizer';
|
| 20 |
import { SerpHost } from '../api/serp';
|
|
|
|
| 21 |
|
| 22 |
@singleton()
|
| 23 |
export class SERPStandAloneServer extends KoaServer {
|
|
@@ -106,6 +107,23 @@ export class SERPStandAloneServer extends KoaServer {
|
|
| 106 |
}
|
| 107 |
|
| 108 |
registerRoutes(): void {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
this.koaApp.use(this.makeAssetsServingController());
|
| 110 |
this.koaApp.use(this.registry.makeShimController());
|
| 111 |
}
|
|
|
|
| 18 |
import { AsyncLocalContext } from '../services/async-context';
|
| 19 |
import finalizer, { Finalizer } from '../services/finalizer';
|
| 20 |
import { SerpHost } from '../api/serp';
|
| 21 |
+
import koaCompress from 'koa-compress';
|
| 22 |
|
| 23 |
@singleton()
|
| 24 |
export class SERPStandAloneServer extends KoaServer {
|
|
|
|
| 107 |
}
|
| 108 |
|
| 109 |
registerRoutes(): void {
|
| 110 |
+
this.koaApp.use(koaCompress({
|
| 111 |
+
filter(type) {
|
| 112 |
+
if (type.startsWith('text/')) {
|
| 113 |
+
return true;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
if (type.includes('application/json') || type.includes('+json') || type.includes('+xml')) {
|
| 117 |
+
return true;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
if (type.includes('application/x-ndjson')) {
|
| 121 |
+
return true;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
return false;
|
| 125 |
+
}
|
| 126 |
+
}));
|
| 127 |
this.koaApp.use(this.makeAssetsServingController());
|
| 128 |
this.koaApp.use(this.registry.makeShimController());
|
| 129 |
}
|