fix: Added unfinished api routes to backend

This commit is contained in:
Aron Malcher 2024-02-12 11:08:34 +01:00
parent 1974152b48
commit c4251d9f51
Signed by: aronmal
GPG key ID: 816B7707426FC612
6 changed files with 162 additions and 0 deletions

View file

@ -0,0 +1,48 @@
import { APIEvent } from "@solidjs/start/server/types";
import { eq } from "drizzle-orm";
import db from "~/drizzle";
import { guilds } from "~/drizzle/schema";
export const GET = async ({ params }: APIEvent) => {
const guild = await db.query.guilds
.findFirst({
where: eq(guilds.id, params.guildId),
with: {
timePlanning: { with: { messages: true } },
matches: true,
},
})
.execute();
if (!guild)
return new Response(JSON.stringify({ error: "No such guild found." }), {
status: 404,
});
return guild;
};
export const DELETE = async ({ params }: APIEvent) => {
const guildQuery = await db.query.guilds
.findFirst({
where: eq(guilds.id, params.guildId),
with: {
timePlanning: { with: { messages: true } },
matches: true,
},
})
.execute();
if (!guildQuery)
return new Response(JSON.stringify({ error: "No such guild found." }), {
status: 404,
});
const guild = await db
.delete(guilds)
.where(eq(guilds.id, params.guildId))
.returning()
.execute();
return guild;
};

View file

@ -0,0 +1,24 @@
import { APIEvent } from "@solidjs/start/server/types";
import { eq } from "drizzle-orm";
import db from "~/drizzle";
import { guilds } from "~/drizzle/schema";
export const PUT = async ({ params }: APIEvent) => {
const guild = await db.query.guilds
.findFirst({
where: eq(guilds.id, params.guildId),
with: {
timePlanning: { with: { messages: true } },
matches: true,
},
})
.execute();
if (!guild)
return new Response(JSON.stringify({ error: "No such guild found." }), {
status: 404,
});
return "TODO";
// return guild.timePlanning;
};

View file

@ -0,0 +1,24 @@
import { APIEvent } from "@solidjs/start/server/types";
import { eq } from "drizzle-orm";
import db from "~/drizzle";
import { guilds } from "~/drizzle/schema";
export const POST = async ({ params }: APIEvent) => {
const guild = await db.query.guilds
.findFirst({
where: eq(guilds.id, params.guildId),
with: {
timePlanning: { with: { messages: true } },
matches: true,
},
})
.execute();
if (!guild)
return new Response(JSON.stringify({ error: "No such guild found." }), {
status: 404,
});
return "TODO";
// return guild.timePlanning;
};

View file

@ -0,0 +1,24 @@
import { APIEvent } from "@solidjs/start/server/types";
import { eq } from "drizzle-orm";
import db from "~/drizzle";
import { guilds } from "~/drizzle/schema";
export const GET = async ({ params }: APIEvent) => {
const guild = await db.query.guilds
.findFirst({
where: eq(guilds.id, params.guildId),
with: {
timePlanning: { with: { messages: true } },
matches: true,
},
})
.execute();
if (!guild)
return new Response(JSON.stringify({ error: "No such guild found." }), {
status: 404,
});
return "TODO";
// return guild.timePlanning;
};

View file

@ -0,0 +1,28 @@
import { APIEvent } from "@solidjs/start/server/types";
import { eq } from "drizzle-orm";
import db from "~/drizzle";
import { guilds } from "~/drizzle/schema";
export const GET = async ({ params }: APIEvent) => {
const guild = await db.query.guilds
.findFirst({
where: eq(guilds.id, params.guildId),
with: {
timePlanning: { with: { messages: true } },
matches: true,
},
})
.execute();
if (!guild)
return new Response(JSON.stringify({ error: "No such guild found." }), {
status: 404,
});
return "TODO";
// return guild.timePlanning;
};
export const PUT = async () => {
return "TODO";
};

View file

@ -0,0 +1,14 @@
import db from "~/drizzle";
export const GET = async () => {
const guilds = await db.query.guilds
.findMany({
with: {
timePlanning: { with: { messages: true } },
matches: true,
},
})
.execute();
return { guilds };
};