INNER CODE UNIT · TypeScript
createGame
ekzhang/setwithfriends · functions/src/index.ts:201
export const createGame = functions.https.onCall(async (data, context) => {
const gameId = data.gameId;
const access = data.access || "public";
const mode = data.mode || "normal";
const enableHint = data.enableHint || false;
if (
!(typeof gameId === "string") ||
gameId.length === 0 ||
gameId.length > MAX_GAME_ID_LENGTH ||
!gameId.match(/^[a-zA-Z0-9_-]+$/)
) {
throw new functions.https.HttpsError(
"invalid-argument",
"The function must be called with " +
"argument `gameId` to be created at `/games/:gameId`.",
);
}