From 200610e226c62e4f1a47beeb7d6a9913408e852b Mon Sep 17 00:00:00 2001 From: Daniel Kluge Date: Sat, 30 Jul 2022 18:15:16 +0200 Subject: [PATCH] Remove unused project API route --- pages/api/projects.ts | 29 ----------------------------- pages/api/projects/[name].ts | 33 --------------------------------- 2 files changed, 62 deletions(-) delete mode 100644 pages/api/projects.ts delete mode 100644 pages/api/projects/[name].ts diff --git a/pages/api/projects.ts b/pages/api/projects.ts deleted file mode 100644 index 9562a52..0000000 --- a/pages/api/projects.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { readFileSync } from "fs"; -import { resolve } from "path"; -import type { NextApiRequest, NextApiResponse } from "next"; - -interface IFileError { - message: string; - name: string; - stack?: string; - code: string; - errno: number; - syscall: string; - path: string; -} - -export default function handler(req: NextApiRequest, res: NextApiResponse) { - if (req.method !== "GET") return res.status(405).end(); - - try { - const path = resolve("./public", "projects", "list.json"); - const data = readFileSync(path).toString(); - if (!req.query.swr) console.debug("[API/projects]\tRequest for project list"); - res.status(200).send(data); - } catch (err) { - console.error(`[API/projects]\tError in request for project list! Code: ${(err as IFileError).code}`); - res.status(500); - } finally { - res.end(); - } -} diff --git a/pages/api/projects/[name].ts b/pages/api/projects/[name].ts deleted file mode 100644 index 8bf83f2..0000000 --- a/pages/api/projects/[name].ts +++ /dev/null @@ -1,33 +0,0 @@ -import { readFileSync } from "fs"; -import { resolve } from "path"; -import type { NextApiRequest, NextApiResponse } from "next"; - -interface IFileError { - message: string; - name: string; - stack?: string; - code: string; - errno: number; - syscall: string; - path: string; -} - -export default function handler(req: NextApiRequest, res: NextApiResponse) { - if (req.method !== "GET") return res.status(405).end(); - if (!req.query.name) return res.status(400).end(); - - const project = req.query.name; - - try { - const path = resolve("./public", "projects", `${project}.adoc`); - const data = readFileSync(path).toString(); - console.debug(`[API/projects]\tRequest for ${project}`); - res.status(200).send(data); - } catch (err) { - console.error(`[API/projects]\tError in request for ${project}! Code: ${(err as IFileError).code}`); - if ((err as IFileError).code === "ENOENT") res.status(404); - else res.status(500); - } finally { - res.end(); - } -}