INNER CODE UNIT · TypeScript
finishGame
ekzhang/setwithfriends · functions/src/index.ts:37
export const finishGame = functions.https.onCall(async (data, context) => {
const gameId = data.gameId;
if (
!(typeof gameId === "string") ||
gameId.length === 0 ||
gameId.length > MAX_GAME_ID_LENGTH
) {
throw new functions.https.HttpsError(
"invalid-argument",
"The function must be called with " +
"argument `gameId` to be finished at `/games/:gameId`.",
);
}
if (!context.auth) {
throw new functions.https.HttpsError(
"failed-precondition",
"The function must be called while authenticated.",
);