mirror of
https://github.com/LukeHagar/crossws.git
synced 2025-12-06 04:19:26 +00:00
testing things
This commit is contained in:
@@ -6,11 +6,12 @@ import { readFileSync } from "node:fs";
|
||||
const ws = crossws({
|
||||
hooks: defineHooks({
|
||||
upgrade(req, socket) {
|
||||
if (!authorizedCheck(req)) {
|
||||
// if (!authorizedCheck(req)) {
|
||||
socket.reject("Unauthorized")
|
||||
} else {
|
||||
socket.accept()
|
||||
}
|
||||
// } else {
|
||||
// socket.accept()
|
||||
|
||||
// }
|
||||
},
|
||||
|
||||
open(peer) {
|
||||
@@ -43,6 +44,7 @@ const port = 3000;
|
||||
const index = readFileSync("./public/index.html");
|
||||
|
||||
const server = createServer((req, res) => {
|
||||
console.log('hit');
|
||||
res.writeHead(200);
|
||||
res.end(index);
|
||||
})
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"name": "crossws-examples-node",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "node ./index.js"
|
||||
},
|
||||
|
||||
@@ -34,7 +34,7 @@ export class AdapterHookable {
|
||||
([globalRes, hook]) => {
|
||||
const hookResPromise = hook?.(arg1 as any, arg2 as any);
|
||||
return hookResPromise instanceof Promise
|
||||
? hookResPromise.then((hookRes) => hookRes ?? globalRes)
|
||||
? hookResPromise.then((hookRes) => hookRes || globalRes)
|
||||
: hookResPromise || globalRes;
|
||||
},
|
||||
) as Promise<any>;
|
||||
@@ -146,7 +146,7 @@ export interface Hooks {
|
||||
accept: (params?: { headers?: HeadersInit }) => void,
|
||||
reject: (reason: Reasons) => void,
|
||||
},
|
||||
) => MaybePromise<void>;
|
||||
) => MaybePromise<void | Response>;
|
||||
|
||||
/** A message is received */
|
||||
message: (peer: Peer, message: Message) => MaybePromise<void>;
|
||||
|
||||
Reference in New Issue
Block a user