diff --git a/functions/src/route/admin.ts b/functions/src/route/admin.ts index 16a3ac6..f4bdf85 100644 --- a/functions/src/route/admin.ts +++ b/functions/src/route/admin.ts @@ -2,7 +2,7 @@ import * as functions from "firebase-functions"; import express, {Request, Response} from "express"; import cors from "cors"; import {createVote, setActiveVote, getAllVotes} from "../types/vote"; -import { setState, updateState } from "../types/state"; +import {setState, updateState} from "../types/state"; const app = express(); @@ -31,7 +31,7 @@ app.post("/create", async (req: Request, res: Response) => { const id = await createVote(prompt, description, options); await setState(id); - console.log("set state") + console.log("set state"); res.json({id}); }); @@ -68,11 +68,11 @@ app.put("/closeVote", async (req: Request, res: Response) => { res.json({success}); }); -export const getAllVotesCall = functions.https.onCall(async () => - (await getAllVotes()).docs.map((vote) => ({ - ...vote.data(), - id: vote.id, - })) +export const getAllVotesCall = functions.https.onCall(async () => + (await getAllVotes()).docs.map((vote) => ({ + ...vote.data(), + id: vote.id, + })) ); export default app; diff --git a/functions/src/route/voting.ts b/functions/src/route/voting.ts index bbfcbd6..b421eee 100644 --- a/functions/src/route/voting.ts +++ b/functions/src/route/voting.ts @@ -10,7 +10,7 @@ import { getVote, getActiveVote, } from "../types/vote"; -import { updateVoteCount } from "../types/state"; +import {updateVoteCount} from "../types/state"; const app = express(); diff --git a/functions/src/types/state.ts b/functions/src/types/state.ts index 6173c4e..dbfa4eb 100644 --- a/functions/src/types/state.ts +++ b/functions/src/types/state.ts @@ -1,9 +1,9 @@ import { - FieldValue, - getFirestore, - } from "firebase-admin/firestore"; - - const db = getFirestore(); + FieldValue, + getFirestore, +} from "firebase-admin/firestore"; + +const db = getFirestore(); export type State = { currentVote: string | null @@ -14,14 +14,16 @@ export type State = { const stateCollection = db.collection("state"); export const setState = (currentVote: string | null) => - stateCollection.doc("currentVote").set({ - currentVote, - changes: 0, - voteChanges: 0 - }); + stateCollection.doc("currentVote").set({ + currentVote, + changes: 0, + voteChanges: 0, + }); export const updateState = () => - stateCollection.doc("currentVote").update({changes: FieldValue.increment(1)}); + stateCollection.doc("currentVote").update({changes: FieldValue.increment(1)}); export const updateVoteCount = () => - stateCollection.doc("currentVote").update({voteChanges: FieldValue.increment(1)}); \ No newline at end of file + stateCollection.doc("currentVote").update({ + voteChanges: FieldValue.increment(1), + });