feat: Added a healthcheck to backend
This commit is contained in:
@@ -5,6 +5,7 @@ import { adminRouter } from "./api/adminRouter";
|
||||
import { appRouter } from "./api/appRouter";
|
||||
import { authRouter } from "./auth/index";
|
||||
import capability, { Features } from "@/helpers/capability";
|
||||
import mongoose from "mongoose";
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -12,6 +13,14 @@ router.use('/app', appRouter)
|
||||
router.use('/admin', adminRouter)
|
||||
router.use('/auth', authRouter)
|
||||
|
||||
router.get("/healthcheck", async (req, res) => {
|
||||
res.status(200).send({
|
||||
uptime: process.uptime(),
|
||||
date: new Date(),
|
||||
db: mongoose.connection.readyState
|
||||
})
|
||||
})
|
||||
|
||||
router.post("/notif", islogged, capability.mw(Features.Notif), async (req, res) => {
|
||||
var obj = {user: req.user._id, ...req.body}
|
||||
await Notification.findOneAndUpdate(obj, obj, {upsert: true})
|
||||
|
||||
Reference in New Issue
Block a user