我有一个Express服务器,它可以像这样创建WSS服务器:
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: '8080' });
wss.on('connection', async (ws, req) => {
...
})
// routes setup
const chatRouter = require('./routes/chatPoint')(wss);
app.use('/api/chat', chatRouter);
我正在尝试将参数'wss“传递给以下模块:
router.patch('/title', jsonParser, async (req, res) => {
...
});
module.exports = router;
我当前遇到的错误是:
return fn.apply(this, arguments);
^
TypeError: Cannot read property 'apply' of undefined
请告知。