IEatBeans
01/29/2023, 5:13 AMauth
folder or smth? Doesnt seem super clean that way thoughIEatBeans
01/29/2023, 5:13 AMIEatBeans
01/29/2023, 5:14 AMSkye
01/29/2023, 10:07 AMSkye
01/29/2023, 10:09 AMjs
export const onRequestGet = [myMiddlewareHandler, myRouteThatShouldHaveMiddlewareFirst]
That way, you can explicitly choose which routes it runs onHazard
01/29/2023, 10:09 AMHardAtWork
01/29/2023, 11:15 AMHazard
01/29/2023, 11:19 AMHardAtWork
01/29/2023, 11:20 AMHazard
01/29/2023, 11:21 AMHardAtWork
01/29/2023, 11:22 AMtsconfig.json
?Hazard
01/29/2023, 11:25 AMERROR Error: Failed to construct 'WebSocket': the constructor is not implemented.
Hazard
01/29/2023, 11:25 AMkian
01/29/2023, 11:26 AMthe constructor is not implemented
is something thrown by the runtimeHardAtWork
01/29/2023, 11:26 AMcompatibility_date
in your wrangler.toml
?HardAtWork
01/29/2023, 11:27 AMWebSocket
isn't a recent addition, but if your compat date is really old, it might not be there...Hazard
01/29/2023, 11:27 AM--compatibility-date=2023-01-29
Skye
01/29/2023, 11:34 AMnew WebSocket
- which is not implemented. The guide you were linked explains how to create websockets in the workers runtimeDani Foldi
01/29/2023, 3:26 PMDani Foldi
01/29/2023, 3:27 PMkian
01/29/2023, 3:30 PMkian
01/29/2023, 3:31 PMjsg::unimplemented
or wontimplement
- but that is what'd throw the errorHazard
01/29/2023, 4:10 PMkian
01/29/2023, 4:12 PMHazard
01/29/2023, 4:17 PMjs
let resp = await fetch(url, {
headers: {
Upgrade: 'websocket',
},
});
let ws = resp.webSocket;
if (!ws) {
throw new Error("server didn't accept WebSocket");
}
ws.accept();
James
01/29/2023, 4:18 PMWebSocket
constructor should work fine: https://developers.cloudflare.com/workers/learning/using-websockets/#writing-a-websocket-client
If It doesn't, I would recommend filing an issue on the wrangler2
repoJames
01/29/2023, 4:19 PMnew WebSocket(url)
constructor.Hazard
01/29/2023, 4:20 PM