added opendock apt check route

This commit is contained in:
2026-02-20 12:17:39 -06:00
parent 5469a0dc5c
commit a8af021621
4 changed files with 52 additions and 2 deletions

View File

@@ -0,0 +1,13 @@
import { type Express, Router } from "express";
import { requireAuth } from "../middleware/auth.middleware.js";
import getApt from "./opendockGetRelease.route.js";
export const setupOpendockRoutes = (baseUrl: string, app: Express) => {
//setup all the routes
// Apply auth to entire router
const router = Router();
router.use(requireAuth);
router.use(getApt);
app.use(`${baseUrl}/api/opendock`, router);
};

View File

@@ -0,0 +1,34 @@
import { desc, lte, sql } from "drizzle-orm";
import { Router } from "express";
import { open } from "inspector/promises";
import { db } from "../db/db.controller.js";
import { opendockApt } from "../db/schema/opendock.schema.js";
import { apiReturn } from "../utils/returnHelper.utils.js";
import { tryCatch } from "../utils/trycatch.utils.js";
const r = Router();
r.get("/", async (_, res) => {
//const limit
const { data, error } = await tryCatch(
db
.select()
.from(opendockApt)
.where(lte(opendockApt.createdAt, sql.raw(`NOW() - INTERVAL '30 days'`)))
.orderBy(desc(opendockApt.createdAt))
.limit(500),
);
apiReturn(res, {
success: true,
level: "info",
module: "opendock",
subModule: "apt",
message: "The first x Apt",
data: data ?? [],
status: 200,
});
});
export default r;