diff --git a/public/api/specs/liljudd.json b/public/api/specs/liljudd.json index faa29e4..2b35d6c 100644 --- a/public/api/specs/liljudd.json +++ b/public/api/specs/liljudd.json @@ -10,7 +10,7 @@ "version": "0.0.0" }, "paths": { - "/api/boot/config": { + "/api/config/boot": { "get": { "tags": ["Guild configs"], "summary": "Find a guild's config by ID", @@ -41,7 +41,7 @@ ] } }, - "/api/{guildId}/config": { + "/api/config/{guildId}": { "get": { "tags": ["Guild configs"], "summary": "Find a guild's config by ID", @@ -118,7 +118,7 @@ ] } }, - "/api/{guildId}/tp_messages": { + "/api/tp_messages/{guildId}": { "get": { "tags": ["Time planning messages"], "summary": "Find the tp_messages of guild by ID", @@ -208,56 +208,7 @@ ] } }, - "/api/{guildId}/matches": { - "get": { - "tags": ["Matches"], - "summary": "Find all matches of guild by ID", - "description": "Returns tp_messages for a guild", - "operationId": "getMatchesOfGuildById", - "parameters": [ - { - "name": "guildId", - "in": "path", - "description": "ID of guild's tp_messages to return", - "required": true, - "schema": { - "type": "string", - "format": "varchar(20)" - } - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/tp_messages" - } - } - } - } - }, - "204": { - "description": "Time planning not enabled for this guild" - }, - "400": { - "description": "Invalid ID supplied" - }, - "404": { - "description": "Guild not found" - } - }, - "security": [ - { - "api_key": [] - } - ] - } - }, - "/api/{guildId}/matches/{channelId}": { + "/api/match/{guildId}/{channelId}": { "post": { "tags": ["Matches"], "summary": "Save a new created match in channel of guild by IDs", @@ -313,7 +264,7 @@ ] } }, - "/api/{guildId}/matches/{channelId}/{matchMessageId}": { + "/api/match/{guildId}/{channelId}/{matchMessageId}": { "put": { "tags": ["Matches"], "summary": "Set state for match of guild by IDs", @@ -378,6 +329,55 @@ } ] } + }, + "/api/match/{guildId}": { + "get": { + "tags": ["Matches"], + "summary": "Find all matches of guild by ID", + "description": "Returns tp_messages for a guild", + "operationId": "getMatchesOfGuildById", + "parameters": [ + { + "name": "guildId", + "in": "path", + "description": "ID of guild's tp_messages to return", + "required": true, + "schema": { + "type": "string", + "format": "varchar(20)" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/tp_messages" + } + } + } + } + }, + "204": { + "description": "Time planning not enabled for this guild" + }, + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Guild not found" + } + }, + "security": [ + { + "api_key": [] + } + ] + } } }, "components": { diff --git a/src/routes/api/[guildId]/config.ts b/src/routes/api/[guildId]/config.ts deleted file mode 100644 index 25fdaf9..0000000 --- a/src/routes/api/[guildId]/config.ts +++ /dev/null @@ -1,48 +0,0 @@ -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; -}; diff --git a/src/routes/api/[guildId]/matches/[channelId]/[matchMessageId].ts b/src/routes/api/[guildId]/matches/[channelId]/[matchMessageId].ts deleted file mode 100644 index c701f81..0000000 --- a/src/routes/api/[guildId]/matches/[channelId]/[matchMessageId].ts +++ /dev/null @@ -1,24 +0,0 @@ -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; -}; diff --git a/src/routes/api/[guildId]/matches/[channelId]/index.ts b/src/routes/api/[guildId]/matches/[channelId]/index.ts deleted file mode 100644 index bf84d60..0000000 --- a/src/routes/api/[guildId]/matches/[channelId]/index.ts +++ /dev/null @@ -1,24 +0,0 @@ -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; -}; diff --git a/src/routes/api/[guildId]/matches/index.ts b/src/routes/api/[guildId]/matches/index.ts deleted file mode 100644 index 403aab3..0000000 --- a/src/routes/api/[guildId]/matches/index.ts +++ /dev/null @@ -1,24 +0,0 @@ -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; -}; diff --git a/src/routes/api/[guildId]/tp_messages.ts b/src/routes/api/[guildId]/tp_messages.ts deleted file mode 100644 index 8ede1ed..0000000 --- a/src/routes/api/[guildId]/tp_messages.ts +++ /dev/null @@ -1,28 +0,0 @@ -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"; -}; diff --git a/src/routes/api/boot/config.ts b/src/routes/api/boot/config.ts deleted file mode 100644 index c93810c..0000000 --- a/src/routes/api/boot/config.ts +++ /dev/null @@ -1,14 +0,0 @@ -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 }; -};