Skip to content

Instantly share code, notes, and snippets.

View ryuujo1573's full-sized avatar

张新伟 ryuujo1573

  • Singapore
View GitHub Profile
@ryuujo1573
ryuujo1573 / event-demo.ts
Last active April 17, 2023 09:23
Demonstrates how to define type of custom `Event`s
// aliases
type MyEvent = PingEvent | MessageEvent;
type EventTypes = MyEvent["type"];
type EventHandler<T> = (payload: T) => void;
type EventHandlers = {
ping: EventHandler<PingEvent>[];
message: EventHandler<MessageEvent>[];
};
// type defs
@ryuujo1573
ryuujo1573 / nginx-websocket-proxy.conf
Created March 27, 2023 03:39
use Nginx as Reverse Proxy for WebSocket backends.
# http {
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream local_origin {
server localhost:5173;
# I was using this for Vite HMR backend.
# For Vite HMR ws proxy, see:
@ryuujo1573
ryuujo1573 / test.ts
Created February 7, 2023 05:30
test
console.log('test!')