Skip to content
This repository was archived by the owner on Nov 15, 2024. It is now read-only.

Elysia v1 #6

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
Binary file modified bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 7 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
mapResponse,
mapEarlyResponse,
NotFoundError,
type ComposedHandler,
type Context,
type HTTPMethod,
type InternalRoute
Expand Down Expand Up @@ -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<any>[] = app.routes
const routes: InternalRoute[] = app.routes

const server = App()

Expand Down Expand Up @@ -83,7 +83,7 @@ export const node =
}

const context = {
...app.decorators,
...app.decorator,
set,
params,
store: app.store,
Expand All @@ -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)
)
}
})
Expand Down Expand Up @@ -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())
)
})

Expand Down