Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/filesystemUtils.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
18 changes: 11 additions & 7 deletions src/networkUtils.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -79,7 +79,8 @@ interface HttpsOptions {
serverName?: string;
}

interface ServerConfiguration extends Pick<ServeOptions, 'error' | 'hostname' | 'port'> {
interface ServerConfiguration
extends Pick<Serve.Options<undefined>, 'error' | 'hostname' | 'port'> {
/**
* Options for customizing HTTPS functionality.
*/
Expand Down Expand Up @@ -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<undefined>['url']['href'],
tlsServerName: HttpsOptions['serverName'],
) {
globalThis.hotReloadCount ??= 0;
Expand Down Expand Up @@ -197,7 +198,7 @@ function logServerStartup(
* @returns `Promise` resolving to the return value of `Bun.serve()`.
*/
async function startDevelopmentServer(
entrypointFunction: Serve['fetch'],
entrypointFunction: NonNullable<Serve.Options<undefined>['fetch']>,
serverConfiguration: ServerConfiguration = {},
) {
const {
Expand All @@ -207,9 +208,9 @@ async function startDevelopmentServer(
onLogRequestBody = () => true,
port,
} = serverConfiguration;
const serverOptions: Serve = {
const serverOptions: Serve.Options<undefined> = {
development: true,
async fetch(request: Request, server: Server): Promise<Response> {
async fetch(request: Request, server: Server<undefined>): Promise<Response> {
const requestClone = request.clone();
const [[response, responseError], elapsedTime] = await measureElapsedTime(async () => {
const { pathname, search } = new URL(request.url);
Expand Down Expand Up @@ -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 }),
Expand All @@ -263,6 +263,7 @@ async function startDevelopmentServer(
certificateAuthorityPath,
certificatePath,
diffieHellmanParametersPath,
lowMemoryMode,
passphrase,
privateKeyPath,
serverName,
Expand Down Expand Up @@ -316,6 +317,9 @@ async function startDevelopmentServer(
if (serverName) {
serverOptions.tls.serverName = serverName;
}
if (lowMemoryMode !== undefined) {
serverOptions.tls.lowMemoryMode = lowMemoryMode;
}
}

if (process.env.DEBUG) {
Expand Down
Loading