/api/client/list Endpoint 추가

This commit is contained in:
static
2024-12-29 22:03:39 +09:00
parent 97f6e1e32f
commit 4a10ba0fbf
4 changed files with 28 additions and 10 deletions

View File

@@ -6,6 +6,7 @@ import {
createClient,
getClientByPubKey,
createUserClient,
getAllUserClients,
getUserClient,
createUserClientChallenge,
getUserClientChallenge,
@@ -13,6 +14,16 @@ import {
} from "$lib/server/db/client";
import env from "$lib/server/loadenv";
export const getUserClientList = async (userId: number) => {
const userClients = await getAllUserClients(userId);
return {
userClients: userClients.map(({ clientId, state }) => ({
id: clientId,
state,
})),
};
};
const expiresIn = ms(env.challenge.pubKeyExp);
const expiresAt = () => new Date(Date.now() + expiresIn);