diff --git a/bun.lockb b/bun.lockb index db2cbd5..60cf686 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 8e976be..b5c96c1 100644 --- a/package.json +++ b/package.json @@ -14,14 +14,14 @@ "devDependencies": { "@types/node": "^20.4.1", "bun-types": "^0.6.13", - "elysia": "^0.6.0-alpha.1", + "elysia": "^1.1.17", "eslint": "^8.44.0", "rimraf": "4.4.1", "ts-node": "^10.9.1", "typescript": "^5.1.6" }, "peerDependencies": { - "elysia": ">= 0.6.0-alpha.1" + "elysia": "^1" }, "exports": { "require": "./dist/cjs/index.js", diff --git a/src/index.ts b/src/index.ts index a27058f..3661750 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,6 +10,7 @@ import { mapResponse, mapEarlyResponse, NotFoundError, + type ComposedHandler, type Context, type HTTPMethod, type InternalRoute @@ -40,8 +41,7 @@ const toResponse = async (res: HttpResponse, response: Response) => { export const node = (port: number, callback: (socket: us_listen_socket) => any = () => {}) => (app: Elysia) => { - // @ts-ignore - const routes: InternalRoute[] = app.routes + const routes: InternalRoute[] = app.routes const server = App() @@ -83,7 +83,7 @@ export const node = } const context = { - ...app.decorators, + ...app.decorator, set, params, store: app.store, @@ -103,12 +103,12 @@ export const node = } try { - return void toResponse(res, await handle(context)) + return void toResponse(res, await (handle as ComposedHandler)(context)) } catch (error) { return void toResponse( res, // @ts-ignore - await app.handleError(request, error as Error, set) + await app.handleError({ request, set }, error as Error) ) } }) @@ -140,14 +140,14 @@ export const node = const response = mapResponse( // @ts-ignore - await app.handleError(request, new NotFoundError(), set), + await app.handleError({ request, set }, new NotFoundError()), set ) await toResponse( res, // @ts-ignore - await app.handleError(request, new NotFoundError(), set) + await app.handleError({ request, set }, new NotFoundError()) ) })