chore: more debugging
This commit is contained in:
@@ -46,7 +46,13 @@ const GetFromGame = z.object({
|
|||||||
gameName: z.string().nonempty(),
|
gameName: z.string().nonempty(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.use((req, _res, next) => {
|
||||||
|
console.log(`Received request ${req.url}`);
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
app.get("/api/announcements", async (_, res) => {
|
app.get("/api/announcements", async (_, res) => {
|
||||||
|
console.log(`Processing GET /api/announcements`);
|
||||||
const announcements = await db
|
const announcements = await db
|
||||||
.selectFrom("announcements")
|
.selectFrom("announcements")
|
||||||
.select(["id", "title", "text", "publication_date", "image"])
|
.select(["id", "title", "text", "publication_date", "image"])
|
||||||
@@ -56,6 +62,7 @@ app.get("/api/announcements", async (_, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.get("/api/announcements/from-game", async (req, res) => {
|
app.get("/api/announcements/from-game", async (req, res) => {
|
||||||
|
console.log(`Processing GET /api/announcements/from-game`);
|
||||||
const fromGameData = GetFromGame.parse(req.query);
|
const fromGameData = GetFromGame.parse(req.query);
|
||||||
console.log(`Request from game ${fromGameData.gameName}`);
|
console.log(`Request from game ${fromGameData.gameName}`);
|
||||||
const announcements = await db
|
const announcements = await db
|
||||||
@@ -69,6 +76,7 @@ app.get("/api/announcements/from-game", async (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.get("/api/announcements/:announcementId", async (req, res) => {
|
app.get("/api/announcements/:announcementId", async (req, res) => {
|
||||||
|
console.log(`Processing GET /api/announcements/:announcementId`);
|
||||||
const { announcementId } = AnnouncementIdInput.parse(req.params);
|
const { announcementId } = AnnouncementIdInput.parse(req.params);
|
||||||
const announcement = await db
|
const announcement = await db
|
||||||
.selectFrom("announcements")
|
.selectFrom("announcements")
|
||||||
@@ -79,6 +87,7 @@ app.get("/api/announcements/:announcementId", async (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.post("/api/announcements", upload.single("image"), async (req, res) => {
|
app.post("/api/announcements", upload.single("image"), async (req, res) => {
|
||||||
|
console.log(`Processing POST /api/announcements`);
|
||||||
const postInput = PostInput.parse(req);
|
const postInput = PostInput.parse(req);
|
||||||
const announcement = {
|
const announcement = {
|
||||||
title: postInput.body.title,
|
title: postInput.body.title,
|
||||||
@@ -94,6 +103,7 @@ app.post(
|
|||||||
"/api/announcements/:announcementId",
|
"/api/announcements/:announcementId",
|
||||||
upload.single("image"),
|
upload.single("image"),
|
||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
|
console.log(`Processing POST /api/announcements/:announcementId`);
|
||||||
const patchInput = PatchInput.parse(req);
|
const patchInput = PatchInput.parse(req);
|
||||||
const { announcementId } = AnnouncementIdInput.parse(req.params);
|
const { announcementId } = AnnouncementIdInput.parse(req.params);
|
||||||
await db
|
await db
|
||||||
@@ -112,6 +122,8 @@ app.post(
|
|||||||
);
|
);
|
||||||
|
|
||||||
app.delete("/api/announcements/:announcementId", async (req, res) => {
|
app.delete("/api/announcements/:announcementId", async (req, res) => {
|
||||||
|
console.log(`Processing DELETE /api/announcements`);
|
||||||
|
|
||||||
const { announcementId } = AnnouncementIdInput.parse(req.params);
|
const { announcementId } = AnnouncementIdInput.parse(req.params);
|
||||||
|
|
||||||
const { image } = await db
|
const { image } = await db
|
||||||
|
|||||||
Reference in New Issue
Block a user