pusher / chatkit-server-node

Node.js SDK for Pusher Chatkit
https://pusher.com/chatkit
MIT License
16 stars 9 forks source link

client SDK and server SDK API differences #42

Closed dcsan closed 5 years ago

dcsan commented 5 years ago

What?

I want to create a server based client (for a bot to listen to rooms)

with client code this works

    Rabbit.chatkit.getUser({
      id: userId,
    }).then(currentUser => {
      debug.info('connected currentUser', currentUser)
      let room = currentUser.rooms[0]

but server I have to call another API to get users list of rooms

Suggested improvements

normalize APIs / prepopulate room list on server response

dcsan commented 5 years ago

another example where userId param is different based on the API call

    // let opts = { userId }  // cannot do this

    Rabbit.chatkit.getUser({id: userId}).then(currentUser => {
      debug.info('connected currentUser', currentUser)
      Rabbit.chatkit.getUserRooms({userId: userId}).then( (rooms, err) => {
callum-oakley commented 5 years ago

The server SDK is intentionally lower level and more flexible. We don't want you to have to pay the cost of getting information for all the user's rooms on the server every time you want to get a user in isolation.

Regarding id vs userId, then convention we've tried to follow is to use id if the context is obvious. However maybe this causes more confusion than if we were just consistent with it everywhere... thanks for the feedback.

As with the other issues, closing this as a feature request. (I've added it to our internal system.)

dcsan commented 5 years ago

related #39 https://github.com/pusher/chatkit-server-node/issues/39