Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: probe server uptime status #359

Merged
merged 9 commits into from
Jul 29, 2024
1 change: 0 additions & 1 deletion src/controllers/ProductController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,6 @@ export class ProductController {
});
}

// For other types of errors
return res.status(500).json({
status: "unsuccessful",
status_code: 500,
Expand Down
29 changes: 25 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,24 @@ import {
notificationRouter,
productRouter,
jobRouter,
paymentStripeRouter,
blogRouter,
adminRouter,
exportRouter,
sendEmailRoute,
paymentRouter,
contactRouter,
paymentFlutterwaveRouter,
paymentStripeRouter,
} from "./routes";
import { smsRouter } from "./routes/sms";
import { routeNotFound, errorHandler } from "./middleware";
import { routeNotFound, errorHandler, authMiddleware } from "./middleware";
import { orgRouter } from "./routes/organisation";
import swaggerUi from "swagger-ui-express";
import swaggerSpec from "./swaggerConfig";
import updateRouter from "./routes/updateOrg";
import { Limiter } from "./utils";
import ServerAdapter from "./views/bull-board";
import passport from "passport";

dotenv.config();

Expand All @@ -53,7 +54,7 @@ server.use(
server.use(Limiter);
server.use(express.json());
server.use(express.urlencoded({ extended: true }));

server.use(passport.initialize());
server.get("/", (req: Request, res: Response) => {
res.send("Hello world");
});
Expand All @@ -62,6 +63,8 @@ server.use("/api/v1", userRouter);
server.use("/api/v1", authRoute);
server.use("/api/v1", adminRouter);
server.use("/api/v1", sendEmailRoute);
server.use("/api/v1/sms", smsRouter);
server.use("/api/v1/help-center", helpRouter);
server.use("/api/v1", smsRouter);
server.use("/api/v1", helpRouter);
server.use("/api/v1", productRouter);
Expand All @@ -76,6 +79,11 @@ server.use("/api/v1", orgRouter);
server.use("/api/v1", exportRouter);
server.use("/api/v1", testimonialRoute);
server.use("/api/v1", blogRouter);
server.use("/api/v1/product", productRouter);
server.use("/api/v1/settings", notificationRouter);
server.use("/api/v1/jobs", jobRouter);
server.use("/api/v1", orgRouter);
server.use("/api/v1", authMiddleware, orgRouter);
server.use("/api/v1", contactRouter);
server.use("/api/v1", jobRouter);
server.use("/api/v1", orgRouter);
Expand All @@ -89,10 +97,23 @@ server.use(errorHandler);
AppDataSource.initialize()
.then(async () => {
// await seed();
server.use(express.json());
server.get("/", (req: Request, res: Response) => {
res.send("Hello world");
});

server.get("/probe", (req: Request, res: Response) => {
try {
res.send("I am the express api responding");
} catch (error) {
res.status(500).json({ error: "Internal Server Error" });
}
});

server.listen(port, () => {
log.info(`Server is listening on port ${port}`);
});
})
.catch((error) => log.error(error));
.catch((error) => console.error(error));

export default server;
Loading