Skip to content

Commit

Permalink
feat: Manage Socket additional params to handle users in devtool
Browse files Browse the repository at this point in the history
  • Loading branch information
taorepoara committed Oct 24, 2023
1 parent aaf0c1c commit f9027a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ export default class LenraApp {
this.lenraOAuth2Client = new LenraOAuth2Client(oAuth2Opts);
}

async connect() {
async connect(params?: Record<string, any>) {
const accessToken = await this.lenraOAuth2Client.authenticate();
const socketOpts: LenraSocketOpts = {
appName: this.lenraAppOpts.appName,
token: accessToken,
additionalParams: params,
socketEndpoint: this.lenraAppOpts.socketEndpoint ?? (this.lenraAppOpts.isProd ? "wss://api.lenra.io/socket" : "ws://localhost:4001/socket"),
}
this.lenraSocket = new LenraSocket(socketOpts);
Expand Down
2 changes: 2 additions & 0 deletions src/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import LenraRoute, { Callback } from './route.js';
export type LenraSocketOpts = {
appName?: string,
token: string,
additionalParams?: Record<string, any>,
socketEndpoint: string,
}

Expand All @@ -15,6 +16,7 @@ export default class LenraSocket {
this.opts = opts;

let params = {
...opts.additionalParams,
token: opts.token,
app: opts.appName,
}
Expand Down

0 comments on commit f9027a7

Please sign in to comment.