diff --git a/src/config/index.ts b/src/config/index.ts index d94eb762..a9fe2c06 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -33,6 +33,7 @@ const config = { LEMONSQUEEZY_SIGNING_KEY: process.env.LEMONSQUEEZY_SIGNING_KEY, BASE_URL: process.env.BASE_URL, PAYSTACK_SECRET_KEY: process.env.PAYSTACK_SECRET_KEY, + SWAGGER_JSON_URL: process.env.SWAGGER_JSON_URL, }; export default config; diff --git a/src/index.ts b/src/index.ts index 4d06cf15..233600ae 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,6 +11,7 @@ import { adminRouter, authRoute, billingPlanRouter, + billingRouter, blogRouter, contactRouter, exportRouter, @@ -18,28 +19,27 @@ import { helpRouter, jobRouter, newsLetterSubscriptionRoute, + notificationRouter, + notificationsettingsRouter, paymentFlutterwaveRouter, + paymentPaystackRouter, paymentRouter, paymentStripeRouter, productRouter, - billingRouter, runTestRouter, sendEmailRoute, + squeezeRoute, testimonialRoute, userRouter, - paymentPaystackRouter, - squeezeRoute, - notificationsettingsRouter, - notificationRouter, } from "./routes"; import { orgRouter } from "./routes/organisation"; +import { planRouter } from "./routes/plans"; +import { roleRouter } from "./routes/roles"; import { smsRouter } from "./routes/sms"; import swaggerSpec from "./swaggerConfig"; import { Limiter } from "./utils"; import log from "./utils/logger"; import ServerAdapter from "./views/bull-board"; -import { roleRouter } from "./routes/roles"; -import { planRouter } from "./routes/plans"; dotenv.config(); const port = config.port; @@ -103,6 +103,10 @@ server.use("/api/v1", squeezeRoute); server.use("/api/v1", planRouter); server.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerSpec)); +server.use("/openapi.json", (_req: Request, res: Response) => { + res.setHeader("Content-Type", "application/json"); + res.send(swaggerSpec); +}); server.use(routeNotFound); server.use(errorHandler); diff --git a/src/swaggerConfig.ts b/src/swaggerConfig.ts index 35061141..1f5b07af 100644 --- a/src/swaggerConfig.ts +++ b/src/swaggerConfig.ts @@ -9,6 +9,7 @@ const swaggerDefinition: SwaggerDefinition = { version: version, // description: // "This is a simple CRUD API application made with Express and documented with Swagger", + basePath: "http://localhost:8000/api-docs", }, servers: [ { @@ -34,6 +35,9 @@ const swaggerDefinition: SwaggerDefinition = { bearerAuth: [], }, ], + externalDocs: { + url: config.SWAGGER_JSON_URL, + }, }; const options = {