fix(node-ws): allow `Hono` with custom Env for `createNodeWebSocket` (#951)
* fix(node-ws): allow `Hono` with custom Env * add changesetpull/953/head
parent
5cad2e1afe
commit
c80ffbfb4c
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@hono/node-ws': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: allow `Hono` with custom Env for `createNodeWebSocket`
|
|
@ -9,7 +9,7 @@
|
||||||
"dist"
|
"dist"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "vitest --run",
|
"test": "tsc --noEmit && vitest --run",
|
||||||
"build": "tsup ./src/index.ts --format esm,cjs --dts",
|
"build": "tsup ./src/index.ts --format esm,cjs --dts",
|
||||||
"publint": "publint",
|
"publint": "publint",
|
||||||
"release": "yarn build && yarn test && yarn publint && yarn publish"
|
"release": "yarn build && yarn test && yarn publint && yarn publish"
|
||||||
|
|
|
@ -149,4 +149,15 @@ describe('WebSocket helper', () => {
|
||||||
expect((receivedMessage as Buffer).at(idx)).toBe(val)
|
expect((receivedMessage as Buffer).at(idx)).toBe(val)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('Types', () => {
|
||||||
|
it('Should not throw a type error with an app with Variables generics', () => {
|
||||||
|
const app = new Hono<{
|
||||||
|
Variables: {
|
||||||
|
foo: string
|
||||||
|
}
|
||||||
|
}>()
|
||||||
|
createNodeWebSocket({ app })
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,7 +12,8 @@ export interface NodeWebSocket {
|
||||||
injectWebSocket(server: Server | Http2Server | Http2SecureServer): void
|
injectWebSocket(server: Server | Http2Server | Http2SecureServer): void
|
||||||
}
|
}
|
||||||
export interface NodeWebSocketInit {
|
export interface NodeWebSocketInit {
|
||||||
app: Hono
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
app: Hono<any, any, any>
|
||||||
baseUrl?: string | URL
|
baseUrl?: string | URL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue