Skip to content

Commit

Permalink
fix(api): fix swagger server list (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
Redm4x committed May 15, 2024
1 parent 1344fe5 commit 1379b6b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
9 changes: 2 additions & 7 deletions api/src/routers/apiRouter.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import { OpenAPIHono } from "@hono/zod-openapi";
import { swaggerUI } from "@hono/swagger-ui";
import routesV1 from "../routes/v1";
import { isProd } from "@src/utils/constants";
import { env } from "@src/utils/env";

export const apiRouter = new OpenAPIHono();

function registerApiVersion(version: string, baseRouter: OpenAPIHono, versionRoutes: OpenAPIHono[]) {
const versionRouter = new OpenAPIHono();

const servers = [{ url: `https://api.cloudmos.io/${version}`, description: "Production" }];
if (!isProd) {
servers.unshift({ url: `http://localhost:3080/${version}`, description: "Localhost" });
}

versionRouter.doc(`/doc`, {
openapi: "3.0.0",
servers: servers,
servers: [{ url: `${env.ServerOrigin}/${version}` }],
info: {
title: "Cloudmos API",
description: "Access Akash data from our indexer",
Expand Down
9 changes: 2 additions & 7 deletions api/src/routers/internalRouter.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import { isProd } from "@src/utils/constants";
import { OpenAPIHono } from "@hono/zod-openapi";
import { swaggerUI } from "@hono/swagger-ui";
import routes from "../routes/internal";
import { env } from "@src/utils/env";

export const internalRouter = new OpenAPIHono();

const servers = [{ url: `https://api.cloudmos.io/internal`, description: "Production" }];
if (!isProd) {
servers.unshift({ url: `http://localhost:3080/internal`, description: "Localhost" });
}

internalRouter.doc(`/doc`, {
openapi: "3.0.0",
servers: servers,
servers: [{ url: `${env.ServerOrigin}/internal` }],
info: {
title: "Cloudmos Internal API",
description: "APIs for internal use that are not part of the public API. There is no garantees of stability or backward compatibility.",
Expand Down
1 change: 1 addition & 0 deletions api/src/utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const env = z
UserDatabaseCS: z.string().optional(),
Network: z.string().default("mainnet"),
RestApiNodeUrl: z.string().optional(),
ServerOrigin: z.string().optional().default("http://localhost:3080"),
AkashlyticsGithubPAT: z.string().optional(),
Auth0JWKSUri: z.string().optional(),
Auth0Audience: z.string().optional(),
Expand Down

0 comments on commit 1379b6b

Please sign in to comment.