You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
624 B
23 lines
624 B
"use strict"; |
|
|
|
Object.defineProperty(exports, "__esModule", { |
|
value: true |
|
}); |
|
exports.default = wrapMiddleware; |
|
function wrapMiddleware(middleware) { |
|
return function (req, res, next) { |
|
if (req.ws !== null && req.ws !== undefined) { |
|
req.wsHandled = true; |
|
try { |
|
/* Unpack the `.ws` property and call the actual handler. */ |
|
middleware(req.ws, req, next); |
|
} catch (err) { |
|
/* If an error is thrown, let's send that on to any error handling */ |
|
next(err); |
|
} |
|
} else { |
|
/* This wasn't a WebSocket request, so skip this middleware. */ |
|
next(); |
|
} |
|
}; |
|
} |