feat(endpoints) adding js docs to endpoint functions

This commit is contained in:
Tanner Shaw
2023-10-30 14:51:22 -05:00
parent b4593e39bc
commit c0062ff9ca
2 changed files with 43 additions and 4 deletions

View File

@@ -52,9 +52,10 @@ time stamp to prevent replay attacks
https://github.com/Discreetly/IdentityCommitmentNullifierCircuit <- Circuit and JS to do this
*/
/**
* This function takes in an identity and returns the rooms the identity is in.
* @param identity - the identity of a user
* @param {string[]} identity - the identity of a user
* @returns an array of roomIds
*/
export async function findRoomsByIdentity(identity: string): Promise<string[]> {
@@ -93,6 +94,11 @@ export async function findClaimCode(code: string): Promise<ClaimCodeI | null> {
});
}
/**
* Finds a gateway identity in the database.
* @param {string} identity - The identity to find
* @returns
*/
export async function findGatewayByIdentity(
identity: string
): Promise<GateWayIdentityI | null> {
@@ -122,6 +128,12 @@ export async function findUpdatedRooms(roomIds: string[]): Promise<RoomI[]> {
});
}
/**
* This function is used to find a room in the database using a message and the roomId and returns the room
* @param {string} roomId - The id of the room to find
* @param {MessageI} message - The id of message to find
* @returns
*/
export async function findRoomWithMessageId(
roomId: string,
message: MessageI
@@ -156,6 +168,12 @@ export async function findRoomWithMessageId(
}
}
/**
* This function is used to find groups in the database that the ethereum address is in
* @param {string} group - The type of the group to find
* @param {string} group - The address of the group to find
* @returns
*/
export function findManyGroups(
group: string,
address?: string
@@ -204,6 +222,11 @@ export function findManyGroups(
}
}
/**
* This function is used to find a group in the database and returns the groups ethereum addresses
* @param {string} name - The name of the group to find
* @returns {Promise<{ ethereumAddresses: string[] } | null>} - A promise that resolves to the group
*/
export function findUniqueEthGroup(
name: string
): Promise<{ ethereumAddresses: string[] } | null> {
@@ -217,6 +240,11 @@ export function findUniqueEthGroup(
});
}
/**
* This function is used to find messages in a room
* @param {string} roomId - The id of the room to find messages in
* @returns {void}
*/
export function findMessages(roomId : string) {
return prisma.messages
.findMany({

View File

@@ -321,6 +321,13 @@ export async function createEthGroupForRoom(
});
}
/**
*
* @param {string[]} names - The names of the ethereum groups to add the addresses to
* @param {string[]} ethAddresses - An array of ethereum addresses to add to the groups
* @returns
*/
export function addAddressesToEthGroup(names: string[], ethAddresses: string[]) {
return prisma.ethereumGroup.updateMany({
where: {
@@ -336,7 +343,13 @@ export function addAddressesToEthGroup(names: string[], ethAddresses: string[])
});
}
/**
* This function updates an ethereum group in the database.
* @param {string} name - The name of the ethereum group to update
* @param {string[]} ethAddresses - An array of ethereum addresses to add to the group
* @param {string[]} roomIds - The ids of the rooms to connect to the group
* @returns
*/
export function updateEthGroup(name: string, ethAddresses: string[], roomIds: string[]) {
return prisma.ethereumGroup.update({
where: {
@@ -352,5 +365,3 @@ export function updateEthGroup(name: string, ethAddresses: string[], roomIds: st
}
});
}