Fix linting
This commit is contained in:
parent
038457f02d
commit
7b0ddf25d5
@ -2,7 +2,7 @@ import * as functions from "firebase-functions";
|
|||||||
import express, {Request, Response} from "express";
|
import express, {Request, Response} from "express";
|
||||||
import cors from "cors";
|
import cors from "cors";
|
||||||
import {createVote, setActiveVote, getAllVotes} from "../types/vote";
|
import {createVote, setActiveVote, getAllVotes} from "../types/vote";
|
||||||
import { setState, updateState } from "../types/state";
|
import {setState, updateState} from "../types/state";
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ app.post("/create", async (req: Request, res: Response) => {
|
|||||||
const id = await createVote(prompt, description, options);
|
const id = await createVote(prompt, description, options);
|
||||||
await setState(id);
|
await setState(id);
|
||||||
|
|
||||||
console.log("set state")
|
console.log("set state");
|
||||||
|
|
||||||
res.json({id});
|
res.json({id});
|
||||||
});
|
});
|
||||||
@ -68,11 +68,11 @@ app.put("/closeVote", async (req: Request, res: Response) => {
|
|||||||
res.json({success});
|
res.json({success});
|
||||||
});
|
});
|
||||||
|
|
||||||
export const getAllVotesCall = functions.https.onCall(async () =>
|
export const getAllVotesCall = functions.https.onCall(async () =>
|
||||||
(await getAllVotes()).docs.map((vote) => ({
|
(await getAllVotes()).docs.map((vote) => ({
|
||||||
...vote.data(),
|
...vote.data(),
|
||||||
id: vote.id,
|
id: vote.id,
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
|
@ -10,7 +10,7 @@ import {
|
|||||||
getVote,
|
getVote,
|
||||||
getActiveVote,
|
getActiveVote,
|
||||||
} from "../types/vote";
|
} from "../types/vote";
|
||||||
import { updateVoteCount } from "../types/state";
|
import {updateVoteCount} from "../types/state";
|
||||||
|
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import {
|
import {
|
||||||
FieldValue,
|
FieldValue,
|
||||||
getFirestore,
|
getFirestore,
|
||||||
} from "firebase-admin/firestore";
|
} from "firebase-admin/firestore";
|
||||||
|
|
||||||
const db = getFirestore();
|
const db = getFirestore();
|
||||||
|
|
||||||
export type State = {
|
export type State = {
|
||||||
currentVote: string | null
|
currentVote: string | null
|
||||||
@ -14,14 +14,16 @@ export type State = {
|
|||||||
const stateCollection = db.collection("state");
|
const stateCollection = db.collection("state");
|
||||||
|
|
||||||
export const setState = (currentVote: string | null) =>
|
export const setState = (currentVote: string | null) =>
|
||||||
stateCollection.doc("currentVote").set({
|
stateCollection.doc("currentVote").set({
|
||||||
currentVote,
|
currentVote,
|
||||||
changes: 0,
|
changes: 0,
|
||||||
voteChanges: 0
|
voteChanges: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const updateState = () =>
|
export const updateState = () =>
|
||||||
stateCollection.doc("currentVote").update({changes: FieldValue.increment(1)});
|
stateCollection.doc("currentVote").update({changes: FieldValue.increment(1)});
|
||||||
|
|
||||||
export const updateVoteCount = () =>
|
export const updateVoteCount = () =>
|
||||||
stateCollection.doc("currentVote").update({voteChanges: FieldValue.increment(1)});
|
stateCollection.doc("currentVote").update({
|
||||||
|
voteChanges: FieldValue.increment(1),
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user