From 34b6a0f00786b81412b3f1384c41f62b0e95390f Mon Sep 17 00:00:00 2001 From: dave caruso Date: Tue, 26 Dec 2023 15:18:15 -0500 Subject: [PATCH] fix error message when not using bun --- src/index.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/index.ts b/src/index.ts index 652f51be..1b96a821 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3973,7 +3973,10 @@ export default class Elysia< options: string | number | Partial, callback?: ListenCallback ) => { - if (!Bun) throw new Error('Bun to run') + if (typeof Bun === 'undefined') + throw new Error( + '.listen() is designed to run on Bun only. If you are running Elysia in other environment please use a dedicated plugin or export the handler via Elysia.fetch' + ) this.compile() @@ -4013,11 +4016,6 @@ export default class Elysia< error: this.outerErrorHandler } as Serve) - if (typeof Bun === 'undefined') - throw new Error( - '.listen() is designed to run on Bun only. If you are running Elysia in other environment please use a dedicated plugin or export the handler via Elysia.fetch' - ) - this.server = Bun?.serve(serve) if (this.event.start.length)