This commit is contained in:
@@ -4,7 +4,7 @@ import { addChoice, getDateForWeekIndex, getToday, removeChoice, removeChoices,
|
||||
import { getDayOfWeekIndex, parseToken } from "../utils";
|
||||
import { getWebsocket } from "../websocket";
|
||||
import { callNotifikace } from "../notifikace";
|
||||
import { AddChoiceRequest, ChangeDepartureTimeRequest, IDayIndex, RemoveChoiceRequest, RemoveChoicesRequest, UdalostEnum, UpdateNoteRequest } from "../../../types";
|
||||
import { AddChoiceData, ChangeDepartureTimeData, RemoveChoiceData, RemoveChoicesData, UdalostEnum, UpdateNoteData } from "../../../types/gen/types.gen";
|
||||
|
||||
/**
|
||||
* Ověří a vrátí index dne v týdnu z požadavku, za předpokladu, že byl předán, a je zároveň
|
||||
@@ -13,7 +13,7 @@ import { AddChoiceRequest, ChangeDepartureTimeRequest, IDayIndex, RemoveChoiceRe
|
||||
* @param req request
|
||||
* @returns index dne v týdnu
|
||||
*/
|
||||
const parseValidateFutureDayIndex = (req: Request<{}, any, IDayIndex>) => {
|
||||
const parseValidateFutureDayIndex = (req: Request<{}, any, AddChoiceData["body"] | UpdateNoteData["body"]>) => {
|
||||
if (req.body.dayIndex == null) {
|
||||
throw Error(`Nebyl předán index dne v týdnu.`);
|
||||
}
|
||||
@@ -30,7 +30,7 @@ const parseValidateFutureDayIndex = (req: Request<{}, any, IDayIndex>) => {
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
router.post("/addChoice", async (req: Request<{}, any, AddChoiceRequest>, res, next) => {
|
||||
router.post("/addChoice", async (req: Request<{}, any, AddChoiceData["body"]>, res, next) => {
|
||||
const login = getLogin(parseToken(req));
|
||||
const trusted = getTrusted(parseToken(req));
|
||||
let date = undefined;
|
||||
@@ -50,7 +50,7 @@ router.post("/addChoice", async (req: Request<{}, any, AddChoiceRequest>, res, n
|
||||
} catch (e: any) { next(e) }
|
||||
});
|
||||
|
||||
router.post("/removeChoices", async (req: Request<{}, any, RemoveChoicesRequest>, res, next) => {
|
||||
router.post("/removeChoices", async (req: Request<{}, any, RemoveChoicesData["body"]>, res, next) => {
|
||||
const login = getLogin(parseToken(req));
|
||||
const trusted = getTrusted(parseToken(req));
|
||||
let date = undefined;
|
||||
@@ -70,7 +70,7 @@ router.post("/removeChoices", async (req: Request<{}, any, RemoveChoicesRequest>
|
||||
} catch (e: any) { next(e) }
|
||||
});
|
||||
|
||||
router.post("/removeChoice", async (req: Request<{}, any, RemoveChoiceRequest>, res, next) => {
|
||||
router.post("/removeChoice", async (req: Request<{}, any, RemoveChoiceData["body"]>, res, next) => {
|
||||
const login = getLogin(parseToken(req));
|
||||
const trusted = getTrusted(parseToken(req));
|
||||
let date = undefined;
|
||||
@@ -90,7 +90,7 @@ router.post("/removeChoice", async (req: Request<{}, any, RemoveChoiceRequest>,
|
||||
} catch (e: any) { next(e) }
|
||||
});
|
||||
|
||||
router.post("/updateNote", async (req: Request<{}, any, UpdateNoteRequest>, res, next) => {
|
||||
router.post("/updateNote", async (req: Request<{}, any, UpdateNoteData["body"]>, res, next) => {
|
||||
const login = getLogin(parseToken(req));
|
||||
const trusted = getTrusted(parseToken(req));
|
||||
const note = req.body.note;
|
||||
@@ -114,7 +114,7 @@ router.post("/updateNote", async (req: Request<{}, any, UpdateNoteRequest>, res,
|
||||
} catch (e: any) { next(e) }
|
||||
});
|
||||
|
||||
router.post("/changeDepartureTime", async (req: Request<{}, any, ChangeDepartureTimeRequest>, res, next) => {
|
||||
router.post("/changeDepartureTime", async (req: Request<{}, any, ChangeDepartureTimeData["body"]>, res, next) => {
|
||||
const login = getLogin(parseToken(req));
|
||||
let date = undefined;
|
||||
if (req.body.dayIndex != null) {
|
||||
|
||||
Reference in New Issue
Block a user