diff --git a/CHANGELOG.md b/CHANGELOG.md index d7f5f6d..aa418b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog -## 2.35.3 +## 2.35.1 + +- Fix changelog version + +## 2.35.0 - Upgrade target Bun version from `1.2.14` to `1.3.12` diff --git a/package.json b/package.json index d62dca2..c1307cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mangs/bun-utils", - "version": "2.35.0", + "version": "2.35.1", "author": "Eric L. Goldstein", "description": "Useful utils for your Bun projects", "engines": { diff --git a/src/filesystemUtils.mts b/src/filesystemUtils.mts index 137a759..5c331de 100644 --- a/src/filesystemUtils.mts +++ b/src/filesystemUtils.mts @@ -140,7 +140,7 @@ function usingNewTemporaryFile(options?: TemporaryFileOptions) { * @param shouldForceFlush Whether or not to force a flush to disk when appending. */ async append(appendContents: string, shouldForceFlush = false) { - writer.write(appendContents); + await writer.write(appendContents); if (shouldForceFlush) { await writer.flush(); } diff --git a/src/networkUtils.mts b/src/networkUtils.mts index e0b6552..9e43f38 100644 --- a/src/networkUtils.mts +++ b/src/networkUtils.mts @@ -7,7 +7,7 @@ import { cyan, dim, green, printError, red, yellow } from './consoleUtils.mts'; import { measureElapsedTime, sleep } from './timeUtils.mts'; // Type Imports -import type { Serve, ServeOptions, Server } from 'bun'; +import type { Serve, Server } from 'bun'; // Global Types declare global { @@ -79,7 +79,8 @@ interface HttpsOptions { serverName?: string; } -interface ServerConfiguration extends Pick { +interface ServerConfiguration + extends Pick, 'error' | 'hostname' | 'port'> { /** * Options for customizing HTTPS functionality. */ @@ -168,7 +169,7 @@ function getColorByStatusCode(statusCode: number) { * @param tlsServerName The TLS certificate hostname to expect when connecting to the server. */ function logServerStartup( - serverHref: Server['url']['href'], + serverHref: Server['url']['href'], tlsServerName: HttpsOptions['serverName'], ) { globalThis.hotReloadCount ??= 0; @@ -197,7 +198,7 @@ function logServerStartup( * @returns `Promise` resolving to the return value of `Bun.serve()`. */ async function startDevelopmentServer( - entrypointFunction: Serve['fetch'], + entrypointFunction: NonNullable['fetch']>, serverConfiguration: ServerConfiguration = {}, ) { const { @@ -207,9 +208,9 @@ async function startDevelopmentServer( onLogRequestBody = () => true, port, } = serverConfiguration; - const serverOptions: Serve = { + const serverOptions: Serve.Options = { development: true, - async fetch(request: Request, server: Server): Promise { + async fetch(request: Request, server: Server): Promise { const requestClone = request.clone(); const [[response, responseError], elapsedTime] = await measureElapsedTime(async () => { const { pathname, search } = new URL(request.url); @@ -252,7 +253,6 @@ async function startDevelopmentServer( return response; }, - lowMemoryMode: httpsOptions?.lowMemoryMode ?? false, port: port ?? process.env.DEVELOPMENT_SERVER_PORT ?? 80, ...(error && { error }), ...(hostname && { hostname }), @@ -263,6 +263,7 @@ async function startDevelopmentServer( certificateAuthorityPath, certificatePath, diffieHellmanParametersPath, + lowMemoryMode, passphrase, privateKeyPath, serverName, @@ -316,6 +317,9 @@ async function startDevelopmentServer( if (serverName) { serverOptions.tls.serverName = serverName; } + if (lowMemoryMode !== undefined) { + serverOptions.tls.lowMemoryMode = lowMemoryMode; + } } if (process.env.DEBUG) {