import type { Express } from "express";
import { requireAuth } from "../middleware/auth.middleware.js";
import { featureCheck } from "../middleware/featureActive.middleware.js";
import undo from "./openDockUndoLastStatus.js";
import articleCheck from "./opendock.articleCheck.route.js";
import getApt from "./opendockRelease.route.js";

export const setupOpendockRoutes = (baseUrl: string, app: Express) => {
	//setup all the routes

	app.use(
		`${baseUrl}/api/opendock`,
		featureCheck("opendock_sync"),
		requireAuth,
		getApt,
	);

	app.use(
		`${baseUrl}/api/opendock/articleCheck`,
		featureCheck("opendock_sync"),
		requireAuth,
		articleCheck,
	);

	app.use(
		`${baseUrl}/api/opendock/undo-latest-status`,
		featureCheck("opendock_sync"),
		requireAuth,
		undo,
	);
};
