sendou.ink/pages/api/plus/users-for-voting.ts
Kalle (Sendou) 7b67a96b30 Closes #625
2021-09-18 18:05:33 +03:00

25 lines
737 B
TypeScript

import { NextApiRequest, NextApiResponse } from "next";
import { createHandler, getMySession } from "utils/api";
import plusService, { GetUsersForVoting } from "services/plus";
import { Serialized } from "utils/types";
export type UsersForVotingGet = Serialized<GetUsersForVoting>;
const GET = async (
req: NextApiRequest,
res: NextApiResponse<GetUsersForVoting>
) => {
const user = await getMySession(req);
if (!user) {
return res.status(401).end();
}
const usersForVoting = await plusService.getUsersForVoting(user.id);
res.status(200).json(usersForVoting);
};
const usersForVotingHandler = (req: NextApiRequest, res: NextApiResponse) =>
createHandler(req, res, { GET });
export default usersForVotingHandler;