Migrace na OpenAPI - TypeScript typy
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import express, { Request } from "express";
|
||||
import { getLogin, getTrusted } from "../auth";
|
||||
import { addChoice, addVolatileData, getDateForWeekIndex, getToday, removeChoice, removeChoices, updateDepartureTime, updateNote } from "../service";
|
||||
import { addChoice, getDateForWeekIndex, getToday, removeChoice, removeChoices, updateDepartureTime, updateNote } from "../service";
|
||||
import { getDayOfWeekIndex, parseToken } from "../utils";
|
||||
import { getWebsocket } from "../websocket";
|
||||
import { callNotifikace } from "../notifikace";
|
||||
import { AddChoiceRequest, ChangeDepartureTimeRequest, IDayIndex, RemoveChoiceRequest, RemoveChoicesRequest, UdalostEnum, UpdateNoteRequest } from "../../../types";
|
||||
import { AddChoiceRequest, ChangeDepartureTimeRequest, IDayIndex, RemoveChoiceRequest, RemoveChoicesRequest, UpdateNoteRequest } from "../../../types";
|
||||
import { UdalostEnum } from "../../../types";
|
||||
|
||||
/**
|
||||
* Ověří a vrátí index dne v týdnu z požadavku, za předpokladu, že byl předán, a je zároveň
|
||||
@@ -45,7 +46,7 @@ router.post("/addChoice", async (req: Request<{}, any, AddChoiceRequest>, res, n
|
||||
}
|
||||
try {
|
||||
const data = await addChoice(login, trusted, req.body.locationKey, req.body.foodIndex, date);
|
||||
getWebsocket().emit("message", await addVolatileData(data));
|
||||
getWebsocket().emit("message", data);
|
||||
return res.status(200).json(data);
|
||||
} catch (e: any) { next(e) }
|
||||
});
|
||||
@@ -65,7 +66,7 @@ router.post("/removeChoices", async (req: Request<{}, any, RemoveChoicesRequest>
|
||||
}
|
||||
try {
|
||||
const data = await removeChoices(login, trusted, req.body.locationKey, date);
|
||||
getWebsocket().emit("message", await addVolatileData(data));
|
||||
getWebsocket().emit("message", data);
|
||||
res.status(200).json(data);
|
||||
} catch (e: any) { next(e) }
|
||||
});
|
||||
@@ -85,7 +86,7 @@ router.post("/removeChoice", async (req: Request<{}, any, RemoveChoiceRequest>,
|
||||
}
|
||||
try {
|
||||
const data = await removeChoice(login, trusted, req.body.locationKey, req.body.foodIndex, date);
|
||||
getWebsocket().emit("message", await addVolatileData(data));
|
||||
getWebsocket().emit("message", data);
|
||||
res.status(200).json(data);
|
||||
} catch (e: any) { next(e) }
|
||||
});
|
||||
@@ -109,7 +110,7 @@ router.post("/updateNote", async (req: Request<{}, any, UpdateNoteRequest>, res,
|
||||
date = getDateForWeekIndex(dayIndex);
|
||||
}
|
||||
const data = await updateNote(login, trusted, note, date);
|
||||
getWebsocket().emit("message", await addVolatileData(data));
|
||||
getWebsocket().emit("message", data);
|
||||
res.status(200).json(data);
|
||||
} catch (e: any) { next(e) }
|
||||
});
|
||||
@@ -128,7 +129,7 @@ router.post("/changeDepartureTime", async (req: Request<{}, any, ChangeDeparture
|
||||
}
|
||||
try {
|
||||
const data = await updateDepartureTime(login, req.body?.time, date);
|
||||
getWebsocket().emit("message", await addVolatileData(data));
|
||||
getWebsocket().emit("message", data);
|
||||
res.status(200).json(data);
|
||||
} catch (e: any) { next(e) }
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user