From 7998b7d622014c9fe4f3b3baa4be51803910643c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Moreau?= Date: Mon, 9 Dec 2024 21:51:40 +0100 Subject: [PATCH] fix: listeningListener not called (#31) --- .vscode/settings.json | 20 ------------------- .../node/custom-build/app/server/index.ts | 5 +++-- package-lock.json | 4 ++-- package.json | 2 +- src/adapters/node.ts | 10 ++++++---- 5 files changed, 12 insertions(+), 29 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index f3c03aa..4246311 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,32 +3,12 @@ "editor.defaultFormatter": "biomejs.biome", "json.format.enable": true, "editor.formatOnSave": true, - "javascript.format.enable": false, - "javascript.suggest.autoImports": true, - "javascript.suggest.paths": true, - "typescript.format.enable": false, - "typescript.suggest.paths": true, - "typescript.suggest.autoImports": true, - "editor.renderWhitespace": "all", - "editor.rulers": [120, 160], "editor.codeActionsOnSave": { "source.fixAll": "never", "source.organizeImports": "never", "source.organizeImports.biome": "explicit", "quickfix.biome": "never" }, - "editor.insertSpaces": false, - "editor.detectIndentation": true, - "editor.trimAutoWhitespace": true, - "files.trimTrailingWhitespace": true, - "files.trimTrailingWhitespaceInRegexAndStrings": true, - "files.trimFinalNewlines": true, - "explorer.fileNesting.patterns": { - "*.ts": "${basename}.*.${extname}", - ".env": ".env.*", - "*.tsx": "${basename}.*.${extname},${basename}.*.ts", - "package.json": "*.json, *.yml, *.config.js, *.config.ts, *.yaml" - }, "eslint.enable": false, "eslint.format.enable": false, "prettier.enable": false, diff --git a/examples/node/custom-build/app/server/index.ts b/examples/node/custom-build/app/server/index.ts index 5348855..d26ec80 100644 --- a/examples/node/custom-build/app/server/index.ts +++ b/examples/node/custom-build/app/server/index.ts @@ -1,12 +1,13 @@ import { createHonoServer } from "react-router-hono-server/node"; -import reactRouterConfig from "../../react-router.config"; import { exampleMiddleware } from "./middleware"; console.log("loading server"); export default await createHonoServer({ - buildDirectory: reactRouterConfig.buildDirectory, configure(server) { server.use("*", exampleMiddleware()); }, + listeningListener(info) { + console.log(`Server is listening on http://localhost:${info.port}`); + }, }); diff --git a/package-lock.json b/package-lock.json index 9439c2c..063e7c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "react-router-hono-server", - "version": "2.2.0", + "version": "2.2.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "react-router-hono-server", - "version": "2.2.0", + "version": "2.2.1", "license": "ISC", "workspaces": [ ".", diff --git a/package.json b/package.json index 972e8ea..2fd3472 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-router-hono-server", - "version": "2.2.0", + "version": "2.2.1", "type": "module", "description": "The Vite plugin you need to create a Hono server for your React Router app in less than 10 seconds.", "exports": { diff --git a/src/adapters/node.ts b/src/adapters/node.ts index 96fa541..8e04948 100644 --- a/src/adapters/node.ts +++ b/src/adapters/node.ts @@ -54,10 +54,12 @@ export async function createHonoServer( export async function createHonoServer(options?: HonoServerOptions) { const mergedOptions: HonoServerOptions = { ...options, - listeningListener: (info) => { - console.log(`🚀 Server started on port ${info.port}`); - console.log(`🌍 http://127.0.0.1:${info.port}`); - }, + listeningListener: + options?.listeningListener || + ((info) => { + console.log(`🚀 Server started on port ${info.port}`); + console.log(`🌍 http://127.0.0.1:${info.port}`); + }), port: options?.port || Number(process.env.PORT) || 3000, defaultLogger: options?.defaultLogger ?? true, };