refactor: modularize OpenAPI configuration and extract version constants into separate files
CI / build (pull_request) Failing after 22s
CI / build (pull_request) Failing after 22s
This commit is contained in:
+3
-2
@@ -1,5 +1,6 @@
|
||||
export const API_VERSION = "v1";
|
||||
export const APP_VERSION = "1.1.0";
|
||||
import { API_VERSION, APP_VERSION } from "./version";
|
||||
|
||||
export { API_VERSION, APP_VERSION };
|
||||
export const API_PREFIX = `/api/${API_VERSION}`;
|
||||
export const AUTH_PREFIX = `/${API_VERSION}/auth`;
|
||||
export const DOCS_PREFIX = `/docs/${API_VERSION}`;
|
||||
|
||||
+4
-30
@@ -4,8 +4,9 @@ import { serveStatic } from "hono/bun";
|
||||
import { logger } from "hono/logger";
|
||||
import { prettyJSON } from "hono/pretty-json";
|
||||
import { config } from "./config";
|
||||
import { API_PREFIX, APP_VERSION, AUTH_PREFIX, DOCS_PREFIX } from "./constants";
|
||||
import { API_PREFIX, AUTH_PREFIX, DOCS_PREFIX } from "./constants";
|
||||
import { redis } from "./core/RedisClient";
|
||||
import { openApiSpec, securityScheme } from "./openapi";
|
||||
import { apiRoutes } from "./routes/api";
|
||||
import { authRoutes } from "./routes/auth";
|
||||
import { configRoutes } from "./routes/config";
|
||||
@@ -14,35 +15,8 @@ import { dashboardRoutes } from "./routes/dashboard";
|
||||
const app = new OpenAPIHono({ strict: false });
|
||||
|
||||
// OpenAPI specs
|
||||
app.doc(`${DOCS_PREFIX}/openapi.json`, {
|
||||
openapi: "3.0.0",
|
||||
info: {
|
||||
version: APP_VERSION,
|
||||
title: "toknd Auth Broker API",
|
||||
description:
|
||||
"A high-performance OAuth2 broker and token management service. Designed to centralize provider configurations and automate token lifecycle management across distributed systems.",
|
||||
},
|
||||
tags: [
|
||||
{
|
||||
name: "Tokens",
|
||||
description: "Endpoint operations for accessing and force-refreshing active provider tokens.",
|
||||
},
|
||||
{
|
||||
name: "Management",
|
||||
description: "Administrative operations for provider lifecycle and configuration.",
|
||||
},
|
||||
{
|
||||
name: "Auth (Internal)",
|
||||
description: "System-level OAuth2 handshake and callback processing.",
|
||||
},
|
||||
],
|
||||
security: [{ API_KEY: [] }],
|
||||
});
|
||||
|
||||
app.openAPIRegistry.registerComponent("securitySchemes", "API_KEY", {
|
||||
type: "http",
|
||||
scheme: "bearer",
|
||||
});
|
||||
app.doc(`${DOCS_PREFIX}/openapi.json`, openApiSpec);
|
||||
app.openAPIRegistry.registerComponent("securitySchemes", "API_KEY", securityScheme);
|
||||
|
||||
// Scalar API Reference
|
||||
app.get(
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import { API_VERSION, APP_VERSION } from "./constants";
|
||||
|
||||
export const openApiSpec = {
|
||||
openapi: "3.0.0",
|
||||
info: {
|
||||
version: `${API_VERSION}.${APP_VERSION}`,
|
||||
title: "toknd Auth Broker API",
|
||||
description:
|
||||
"A high-performance OAuth2 broker and token management service. Designed to centralize provider configurations and automate token lifecycle management across distributed systems.",
|
||||
},
|
||||
tags: [
|
||||
{
|
||||
name: "Tokens",
|
||||
description: "Endpoint operations for accessing and force-refreshing active provider tokens.",
|
||||
},
|
||||
{
|
||||
name: "Management",
|
||||
description: "Administrative operations for provider lifecycle and configuration.",
|
||||
},
|
||||
{
|
||||
name: "Auth (Internal)",
|
||||
description: "System-level OAuth2 handshake and callback processing.",
|
||||
},
|
||||
],
|
||||
security: [{ API_KEY: [] }],
|
||||
};
|
||||
|
||||
export const securityScheme = {
|
||||
type: "http",
|
||||
scheme: "bearer",
|
||||
} as const;
|
||||
@@ -0,0 +1,2 @@
|
||||
export const API_VERSION = "v1";
|
||||
export const APP_VERSION = "1.0";
|
||||
Reference in New Issue
Block a user