Skip to content

Commit

Permalink
feat: add json link to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
masterchief-Dave committed Aug 21, 2024
1 parent 3e46fb3 commit 190f570
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
18 changes: 11 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,35 @@ import {
adminRouter,
authRoute,
billingPlanRouter,
billingRouter,
blogRouter,
contactRouter,
exportRouter,
faqRouter,
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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/swaggerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand All @@ -34,6 +35,9 @@ const swaggerDefinition: SwaggerDefinition = {
bearerAuth: [],
},
],
externalDocs: {
url: config.SWAGGER_JSON_URL,
},
};

const options = {
Expand Down

0 comments on commit 190f570

Please sign in to comment.