MCPcopy
hub / github.com/socketio/socket.io / onlyForHandshake

Function onlyForHandshake

examples/passport-example/ts/index.ts:94–109  ·  view source on GitHub ↗
(
  middleware: (req: Request, res: Response, next: any) => void,
)

Source from the content-addressed store, hash-verified

92const io = new Server(httpServer);
93
94function onlyForHandshake(
95 middleware: (req: Request, res: Response, next: any) => void,
96) {
97 return (
98 req: Request & { _query: Record<string, string> },
99 res: Response,
100 next: (err?: Error) => void,
101 ) => {
102 const isHandshake = req._query.sid === undefined;
103 if (isHandshake) {
104 middleware(req, res, next);
105 } else {
106 next();
107 }
108 };
109}
110
111io.engine.use(onlyForHandshake(sessionMiddleware));
112io.engine.use(onlyForHandshake(passport.session()));

Callers 1

index.tsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected