logux/docs

Examples from docs, send false like userId

Closed this issue · 1 comments

I'm following by documents two create serwer and client based on logux and with this code on client the serwer recieved undefined but no the false:

client:

let client = new Client({
  subprotocol: '1.0.0',
  server: 'ws://localhost:31337',
  userId: false
})

serwer:

const server = new Server(
  Server.loadOptions(process, {
    subprotocol: '1.0.0',
    supports: '1.x',
    root: __dirname
  })
)

server.auth(async (userId, token) => {
  if (userId === 'false') { // here the server recieved undefined
    return true
  } else {
    try {
      const data = await jwt.verify(token, process.env.JWT_SECRET)
      return data.sub === userId
    } catch (e) {
      return false
    }
  }
})
ai commented

Thanks. Now we will use false instead of "false" in this case.

I change server behavior: logux/server@ea7a6ec
And update docs: afc3d74