From e105e3be6a8757cb2acc670d9f4e9c5cf697aa97 Mon Sep 17 00:00:00 2001 From: Ev Haus Date: Fri, 30 Aug 2024 22:27:54 -0700 Subject: [PATCH 1/3] docs: Warn users about export Elysia as a default Fixes elysiajs/elysia#550 --- docs/essential/route.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/essential/route.md b/docs/essential/route.md index 503562e9..3c6130d2 100644 --- a/docs/essential/route.md +++ b/docs/essential/route.md @@ -49,12 +49,16 @@ We can define a route by calling a **method named after HTTP verbs**, passing a ```typescript twoslash import { Elysia } from 'elysia' -new Elysia() +export const app = new Elysia() .get('/', () => 'hello') .get('/hi', () => 'hi') .listen(3000) ``` +::: warning +Do **not** `export default app` as Bun's [auto-execution](https://bun.sh/docs/api/http#object-syntax) feature will cause the Elysia server to run twice. +::: + We can access the web server by going to **http://localhost:3000** By default, web browsers will send a GET method when visiting a page. From a09312114bc2320bb3c374e7ed3d032e5e35f68a Mon Sep 17 00:00:00 2001 From: bogeychan Date: Sat, 31 Aug 2024 11:20:38 +0200 Subject: [PATCH 2/3] docs: revert previous changes --- docs/essential/route.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/docs/essential/route.md b/docs/essential/route.md index 3c6130d2..503562e9 100644 --- a/docs/essential/route.md +++ b/docs/essential/route.md @@ -49,16 +49,12 @@ We can define a route by calling a **method named after HTTP verbs**, passing a ```typescript twoslash import { Elysia } from 'elysia' -export const app = new Elysia() +new Elysia() .get('/', () => 'hello') .get('/hi', () => 'hi') .listen(3000) ``` -::: warning -Do **not** `export default app` as Bun's [auto-execution](https://bun.sh/docs/api/http#object-syntax) feature will cause the Elysia server to run twice. -::: - We can access the web server by going to **http://localhost:3000** By default, web browsers will send a GET method when visiting a page. From 07db9f3450bcc1b311eb3d3d4a90047060d8ce2f Mon Sep 17 00:00:00 2001 From: bogeychan Date: Sat, 31 Aug 2024 11:21:57 +0200 Subject: [PATCH 3/3] docs: add troubleshooting page --- docs/.vitepress/config.ts | 10 +++++++++ docs/.vitepress/theme/custom.css | 6 +++++- docs/public/assets/help.svg | 1 + docs/support/troubleshooting.md | 37 ++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 docs/public/assets/help.svg create mode 100644 docs/support/troubleshooting.md diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 89722a05..3fd3dbc0 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -443,6 +443,16 @@ export default defineConfig({ // link: '/integrations/cheat-sheet' // } ] + }, + { + text: 'Support', + collapsed: true, + items: [ + { + text: 'Troubleshooting', + link: '/support/troubleshooting' + } + ] } ], socialLinks: [ diff --git a/docs/.vitepress/theme/custom.css b/docs/.vitepress/theme/custom.css index 2de905f4..87c51e8f 100644 --- a/docs/.vitepress/theme/custom.css +++ b/docs/.vitepress/theme/custom.css @@ -124,7 +124,11 @@ button.copy::after { background-image: url(/assets/integration.svg); } -.dark #VPSidebarNav > .group:nth-child(-n + 9):not(:first-child) > .VPSidebarItem > .item > .text::before { +#VPSidebarNav > .group:nth-child(10) > .VPSidebarItem > .item > .text::before { + background-image: url(/assets/help.svg); +} + +.dark #VPSidebarNav > .group:nth-child(-n + 10):not(:first-child) > .VPSidebarItem > .item > .text::before { filter: invert(1); } diff --git a/docs/public/assets/help.svg b/docs/public/assets/help.svg new file mode 100644 index 00000000..87807c32 --- /dev/null +++ b/docs/public/assets/help.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/support/troubleshooting.md b/docs/support/troubleshooting.md new file mode 100644 index 00000000..0212c326 --- /dev/null +++ b/docs/support/troubleshooting.md @@ -0,0 +1,37 @@ +--- +title: Troubleshooting - ElysiaJS +head: + - - meta + - property: 'og:title' + content: Troubleshooting - ElysiaJS + + - - meta + - name: 'description' + content: This section helps you resolve common issues in ElysiaJS. Whether you're facing compatibility problems, configuration errors, performance bottlenecks, or bugs from updates, you'll find guidance here. Start by consulting the documentation and community channels for potential solutions. Make use of debugging tools and logs to pinpoint issues. Keeping your environment well-configured and updated can prevent many common problems. + + - - meta + - property: 'og:description' + content: This section helps you resolve common issues in ElysiaJS. Whether you're facing compatibility problems, configuration errors, performance bottlenecks, or bugs from updates, you'll find guidance here. Start by consulting the documentation and community channels for potential solutions. Make use of debugging tools and logs to pinpoint issues. Keeping your environment well-configured and updated can prevent many common problems. +--- + +# Troubleshooting + +## EADDRINUSE: Failed to start server. Is port in use? + +Do **not** `export default app` as Bun's [auto-execution](https://bun.sh/docs/api/http#object-syntax) feature will cause the Elysia server to run twice. + +Do this: + +```typescript +export const app = new Elysia().listen(3000) +``` + +Instead of: + +```typescript +const app = new Elysia().listen(3000) + +export default app +``` + +For more details, checkout: [elysiajs/elysia#550](https://github.com/elysiajs/elysia/issues/550)