INNER CODE UNIT · TypeScript

archiveGameState

ekzhang/setwithfriends · functions/src/index.ts:430

async function archiveGameState(
  gameId: string,
  snapInit?: DataSnapshot,
): Promise<boolean> {
  let snap: DataSnapshot;
  if (snapInit) {
    snap = snapInit;
  } else {
    snap = await getDatabase().ref(`gameData/${gameId}`).get();
  }
  if (!snap.exists()) {
    return false; // Game state is not present in the database, maybe racy?
  }

  const jsonBlob = JSON.stringify(snap.val());
  const gzippedBlob = await gzip.compress(jsonBlob);

  await getStorage()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…