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