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 4e1d0fa commit 7530287
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
1 change: 1 addition & 0 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ When running the api locally the following environment variables can be set in a
|-|-|-
Network|`mainnet` or `testnet`|Specify if the api should be in mainnet or testnet mode. Default: `mainnet`.
RestApiNodeUrl|ex: `"https://api.akashnet.net"`|Rest api to use. Will default to `"https://rest.cosmos.directory/akash"` for mainnet and `"https://api.testnet-02.aksh.pw:443"` for testnet.
ServerOrigin|ex: `http://localhost:3080`|Origin of the api server. Will be used to populate the swagger server list.
HealthchecksEnabled|`true` or `false`|Specify if the [Scheduler](./src/index.ts#L42) should send health check pings.
SentryDSN|ex: `"https://[email protected]/1234"`|[Sentry DSN](https://docs.sentry.io/product/sentry-basics/dsn-explainer/) used when [initializing](./src/index.ts#L29) Sentry
AkashDatabaseCS|ex: `postgres://user:password@localhost:5432/cloudmos-akash`|Akash Database Connection String
Expand Down
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 7530287

Please sign in to comment.