Skip to content

Commit 06ec8c8

Browse files
committed
refactor: convert genUsageResponse to use object parameters
1 parent bbf89bf commit 06ec8c8

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

backend/src/api/usage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ async function usageHandler(
9090
}
9191

9292
// Return personal usage data (default behavior)
93-
const usageResponse = await genUsageResponse(
93+
const usageResponse = await genUsageResponse({
9494
fingerprintId,
9595
userId,
9696
clientSessionId,
97-
)
97+
})
9898

9999
return res.status(200).json(usageResponse)
100100
} catch (error) {

backend/src/websockets/websocket-action.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,12 @@ export const getUserIdFromAuthToken = async (params: {
7575
* @param clientSessionId - Optional session ID
7676
* @returns A UsageResponse object containing usage metrics and referral information
7777
*/
78-
export async function genUsageResponse(
79-
fingerprintId: string,
80-
userId: string,
81-
clientSessionId: string | undefined,
82-
): Promise<UsageResponse> {
78+
export async function genUsageResponse(params: {
79+
fingerprintId: string
80+
userId: string
81+
clientSessionId?: string
82+
}): Promise<UsageResponse> {
83+
const { fingerprintId, userId, clientSessionId } = params
8384
const logContext = { fingerprintId, userId, sessionId: clientSessionId }
8485
const defaultResp = {
8586
type: 'usage-response' as const,
@@ -180,11 +181,10 @@ const onPrompt = async (
180181
})
181182
} finally {
182183
cancelUserInput({ userId, userInputId: promptId })
183-
const usageResponse = await genUsageResponse(
184+
const usageResponse = await genUsageResponse({
184185
fingerprintId,
185186
userId,
186-
undefined,
187-
)
187+
})
188188
sendAction(ws, usageResponse)
189189
}
190190
},
@@ -298,11 +298,11 @@ const onInit = async (
298298
}
299299

300300
// Send combined init and usage response
301-
const usageResponse = await genUsageResponse(
301+
const usageResponse = await genUsageResponse({
302302
fingerprintId,
303303
userId,
304304
clientSessionId,
305-
)
305+
})
306306
sendAction(ws, {
307307
...usageResponse,
308308
type: 'init-response',

0 commit comments

Comments
 (0)