pusher-chatkit-server
Advanced tools
Comparing version
{ | ||
"name": "pusher-chatkit-server", | ||
"description": "Pusher ChatKit server library", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"main": "./target/index.js", | ||
@@ -20,3 +20,3 @@ "license": "MIT", | ||
"jsonwebtoken": "^7.4.1", | ||
"pusher-platform-node": "~0.8.1" | ||
"pusher-platform-node": "~0.8.2" | ||
}, | ||
@@ -23,0 +23,0 @@ "devDependencies": { |
@@ -44,2 +44,3 @@ import { | ||
jwt?: string; | ||
qs?: object; | ||
} | ||
@@ -124,4 +125,37 @@ | ||
getUsersByIds(userIds: Array<number>): Promise<any> { | ||
return this.apiInstance.request({ | ||
method: 'GET', | ||
path: `/users_by_ids`, | ||
qs: { | ||
user_ids: userIds.join(','), | ||
}, | ||
jwt: this.getServerToken(), | ||
}).then((res) => { | ||
return JSON.parse(res.body); | ||
}) | ||
} | ||
// Room interactions | ||
getRoom(roomId: number): Promise<any> { | ||
return this.apiInstance.request({ | ||
method: 'GET', | ||
path: `/rooms/${roomId}`, | ||
jwt: this.getServerToken(), | ||
}).then((res) => { | ||
return JSON.parse(res.body); | ||
}) | ||
} | ||
getRoomMessages(roomId: number, initialId: number, direction: string, limit: number): Promise<any> { | ||
return this.apiInstance.request({ | ||
method: 'GET', | ||
path: `/rooms/${roomId}/messages`, | ||
jwt: this.getServerToken(), | ||
}).then((res) => { | ||
return JSON.parse(res.body); | ||
}) | ||
} | ||
getRooms(): Promise<any> { | ||
@@ -128,0 +162,0 @@ return this.apiInstance.request({ |
@@ -27,3 +27,2 @@ // All possible permissions | ||
CREATE_TYPING_EVENT, | ||
SUBSCRIBE_PRESENCE, | ||
GET_ROOM_MESSAGES, | ||
@@ -30,0 +29,0 @@ ]; |
@@ -25,2 +25,3 @@ import { Instance, AuthenticationResponse, AuthenticateOptions, BaseClient, TokenWithExpiry } from 'pusher-platform-node'; | ||
jwt?: string; | ||
qs?: object; | ||
} | ||
@@ -37,2 +38,5 @@ export default class ChatKit { | ||
getUsers(): Promise<any>; | ||
getUsersByIds(userIds: Array<number>): Promise<any>; | ||
getRoom(roomId: number): Promise<any>; | ||
getRoomMessages(roomId: number, initialId: number, direction: string, limit: number): Promise<any>; | ||
getRooms(): Promise<any>; | ||
@@ -39,0 +43,0 @@ createRoomRole(name: string, permissions: Array<string>): Promise<void>; |
@@ -70,3 +70,33 @@ "use strict"; | ||
}; | ||
ChatKit.prototype.getUsersByIds = function (userIds) { | ||
return this.apiInstance.request({ | ||
method: 'GET', | ||
path: "/users_by_ids", | ||
qs: { | ||
user_ids: userIds.join(','), | ||
}, | ||
jwt: this.getServerToken(), | ||
}).then(function (res) { | ||
return JSON.parse(res.body); | ||
}); | ||
}; | ||
// Room interactions | ||
ChatKit.prototype.getRoom = function (roomId) { | ||
return this.apiInstance.request({ | ||
method: 'GET', | ||
path: "/rooms/" + roomId, | ||
jwt: this.getServerToken(), | ||
}).then(function (res) { | ||
return JSON.parse(res.body); | ||
}); | ||
}; | ||
ChatKit.prototype.getRoomMessages = function (roomId, initialId, direction, limit) { | ||
return this.apiInstance.request({ | ||
method: 'GET', | ||
path: "/rooms/" + roomId + "/messages", | ||
jwt: this.getServerToken(), | ||
}).then(function (res) { | ||
return JSON.parse(res.body); | ||
}); | ||
}; | ||
ChatKit.prototype.getRooms = function () { | ||
@@ -73,0 +103,0 @@ return this.apiInstance.request({ |
@@ -28,3 +28,2 @@ "use strict"; | ||
exports.CREATE_TYPING_EVENT, | ||
exports.SUBSCRIBE_PRESENCE, | ||
exports.GET_ROOM_MESSAGES, | ||
@@ -31,0 +30,0 @@ ]; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
82225
3.75%817
8.36%Updated