Skip to content

Commit 2151d60

Browse files
committed
🎉 feat: release
1 parent 8643e0e commit 2151d60

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# 1.2.5 - 1 Feb 2025
2-
- [#18](https://github.com/elysiajs/node/issues/18) reading cookie cause an error
3-
- Unable to set response status when error is thrown
4-
51
# 1.2.4 - 1 Feb 2025
62
Change:
73
- Support Elysia 1.2.11
@@ -10,6 +6,8 @@ Bug fix:
106
- [#23](https://github.com/elysiajs/node/issues/23) Response body object should not be disturbed or locked
117
- [#15](https://github.com/elysiajs/node/issues/15) Possibly fix `ReadableStream` duplex issue?
128
- [#14](https://github.com/elysiajs/node/issues/14) ReadableStream has already been used if request is reference multiple time
9+
- [#18](https://github.com/elysiajs/node/issues/18) reading cookie cause an error
10+
- Unable to set response status when error is thrown
1311

1412
# 1.2.3 - 27 Dec 2024
1513
Bug fix:

example/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,9 @@ const app = new Elysia({
1515
type: 'json'
1616
})
1717
.get('/', () => 'ok')
18+
.ws('/ws', {
19+
message(ws, message) {
20+
ws.send(message)
21+
}
22+
})
1823
.listen(3000)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@elysiajs/node",
3-
"version": "1.2.5",
3+
"version": "1.2.4",
44
"description": "Plugin for Elysia for retreiving Bearer token",
55
"license": "MIT",
66
"scripts": {

src/ws.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import { createServer, IncomingMessage, OutgoingMessage } from 'http'
1414

1515
import { nodeRequestToWebstand, ElysiaNodeContext } from '.'
1616

17-
import WebSocket from 'ws'
18-
import type { WebSocket as NodeWebSocket, WebSocketServer } from 'ws'
17+
import { WebSocketServer } from 'ws'
18+
import type { WebSocket as NodeWebSocket } from 'ws'
1919
import {
2020
createHandleWSResponse,
2121
createWSMessageParser,
@@ -135,6 +135,8 @@ export const requestToContext = (
135135
)
136136
}
137137

138+
let _request: Request | undefined
139+
138140
return Object.assign(
139141
{},
140142
// @ts-expect-error private property
@@ -148,7 +150,8 @@ export const requestToContext = (
148150
set,
149151
redirect,
150152
get request() {
151-
return nodeRequestToWebstand(request)
153+
if (_request) return _request
154+
return (_request = nodeRequestToWebstand(request))
152155
},
153156
[ElysiaNodeContext]: {
154157
req: request,
@@ -163,7 +166,7 @@ export const attachWebSocket = (
163166
app: AnyElysia,
164167
server: ReturnType<typeof createServer>
165168
) => {
166-
const wsServer = new WebSocket.Server({
169+
const wsServer = new WebSocketServer({
167170
noServer: true
168171
})
169172

0 commit comments

Comments
 (0)