From 9a908a45baff2bf83bc11a6dd49287de87368bc4 Mon Sep 17 00:00:00 2001 From: Mathieu Lefebvre Date: Tue, 24 Oct 2023 14:35:09 -0400 Subject: [PATCH] / go to swagger doc --- src/banner.ts | 25 ------------------------- src/index.ts | 9 ++------- src/routes.ts | 10 +--------- 3 files changed, 3 insertions(+), 41 deletions(-) delete mode 100644 src/banner.ts diff --git a/src/banner.ts b/src/banner.ts deleted file mode 100644 index fcfd44f..0000000 --- a/src/banner.ts +++ /dev/null @@ -1,25 +0,0 @@ -import pkg from "../package.json" assert { type: "json" }; - -// https://fsymbols.com/generators/carty/ -export function banner() { - let text =` - - ███████╗██████╗░░█████╗░██████╗░░█████╗░  ░█████╗░██████╗░██╗ - ██╔════╝██╔══██╗██╔══██╗╚════██╗██╔══██╗  ██╔══██╗██╔══██╗██║ - █████╗░░██████╔╝██║░░╚═╝░░███╔═╝██║░░██║  ███████║██████╔╝██║ - ██╔══╝░░██╔══██╗██║░░██╗██╔══╝░░██║░░██║  ██╔══██║██╔═══╝░██║ - ███████╗██║░░██║╚█████╔╝███████╗╚█████╔╝  ██║░░██║██║░░░░░██║ - ╚══════╝╚═╝░░╚═╝░╚════╝░╚══════╝░╚════╝░  ╚═╝░░╚═╝╚═╝░░░░░╚═╝ - -` - text += ` 🚀 ${pkg.description} (${pkg.version}) - - Github: ${pkg.repository} - - HTTP GET - /supply?address=&block= - /contract?address= - /balance?wallet=&address=&block= -` - return text; -} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 0cfcafc..881085d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,12 +16,11 @@ import { getTotalSupply, getContract, getBalance } from "./queries"; import config from "./config"; import { HTTPException } from "hono/http-exception"; -import { banner } from "./banner"; export function generateApp() { const app = new OpenAPIHono(); - app.use("/swagger/*", serveStatic({ root: "./" })); + app.use("/", serveStatic({ root: "./swagger" })); app.doc("/openapi", { openapi: "3.0.0", @@ -44,11 +43,7 @@ export function generateApp() { return c.json({ error_message }, error_code); }); - app.openapi(routes.indexRoute, (c) => { - return { - response: c.text(banner()), - } as TypedResponse; - }); + app.openapi(routes.TotalSupplyQueryRoute, async (c) => { // @ts-expect-error: Suppress type of parameter expected to be never (see https://github.com/honojs/middleware/issues/200) diff --git a/src/routes.ts b/src/routes.ts index c029482..25854a1 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -1,15 +1,7 @@ import { createRoute } from "@hono/zod-openapi"; import * as schemas from "./schemas"; -export const indexRoute = createRoute({ - method: "get", - path: "/", - responses: { - 200: { - description: "Index page banner.", - }, - }, -}); + export const TotalSupplyQueryRoute = createRoute({ method: "get",