fix(servertools): Fix compression stream creation returns, handler proxy buffer conversion, and sitemap URL concatenation
This commit is contained in:
		| @@ -1,5 +1,12 @@ | ||||
| # Changelog | ||||
|  | ||||
| ## 2025-03-16 - 3.0.69 - fix(servertools) | ||||
| Fix compression stream creation returns, handler proxy buffer conversion, and sitemap URL concatenation | ||||
|  | ||||
| - Return compression stream immediately in createCompressionStream for each case instead of using break statements | ||||
| - Convert proxied response to a Buffer in handler proxy rather than throwing an error when it isn't a string | ||||
| - Fix addUrls method in sitemap to correctly concatenate new URLs without duplicating existing entries | ||||
|  | ||||
| ## 2025-02-07 - 3.0.68 - fix(cache-manager) | ||||
| Simplify cache control headers in cache manager | ||||
|  | ||||
|   | ||||
| @@ -3,6 +3,6 @@ | ||||
|  */ | ||||
| export const commitinfo = { | ||||
|   name: '@api.global/typedserver', | ||||
|   version: '3.0.68', | ||||
|   version: '3.0.69', | ||||
|   description: 'A TypeScript-based project for easy serving of static files with support for live reloading, compression, and typed requests.' | ||||
| } | ||||
|   | ||||
| @@ -111,6 +111,7 @@ export class Compressor { | ||||
|     switch (method) { | ||||
|       case 'gzip': | ||||
|         compressionStream = plugins.zlib.createGzip(); | ||||
|         return compressionStream; | ||||
|       case 'br': | ||||
|         compressionStream = plugins.zlib.createBrotliCompress({ | ||||
|           chunkSize: 16 * 1024, | ||||
| @@ -118,10 +119,13 @@ export class Compressor { | ||||
|              | ||||
|           }, | ||||
|         }); | ||||
|         return compressionStream; | ||||
|       case 'deflate': | ||||
|         compressionStream = plugins.zlib.createDeflate(); | ||||
|         return compressionStream; | ||||
|       default: | ||||
|         compressionStream = plugins.smartstream.createPassThrough(); | ||||
|         return compressionStream; | ||||
|     } | ||||
|   } | ||||
| } | ||||
| } | ||||
| @@ -41,10 +41,11 @@ export class HandlerProxy extends Handler { | ||||
|       } | ||||
|  | ||||
|       let responseToSend: Buffer = proxiedResponse.body; | ||||
|       if (typeof responseToSend !== 'string') { | ||||
|         console.log(proxyRequestUrl); | ||||
|         console.log(responseToSend); | ||||
|         throw new Error(`Proxied response is not a string, but ${typeof responseToSend}`); | ||||
|        | ||||
|       // Remove incorrect type check that expects responseToSend to be a string | ||||
|       // Instead, ensure it's a Buffer for consistent handling | ||||
|       if (!Buffer.isBuffer(responseToSend)) { | ||||
|         responseToSend = Buffer.from(responseToSend.toString()); | ||||
|       } | ||||
|  | ||||
|       if (optionsArg && optionsArg.responseModifier) { | ||||
| @@ -74,4 +75,4 @@ export class HandlerProxy extends Handler { | ||||
|       res.end(); | ||||
|     }); | ||||
|   } | ||||
| } | ||||
| } | ||||
| @@ -63,6 +63,6 @@ export class Sitemap { | ||||
|    * adds urls to the current set of urls | ||||
|    */ | ||||
|   public addUrls(urlsArg: IUrlInfo[]) { | ||||
|     this.urls = this.urls.concat(this.urls, urlsArg); | ||||
|     this.urls = this.urls.concat(urlsArg); | ||||
|   } | ||||
| } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user