import { Router } from "express";
import { apiReturn } from "../utils/returnHelper.utils.js";
import { closePool, connectProdSql } from "./prodSqlConnection.controller.js";

const r = Router();

r.post("/", async (_, res) => {
	await closePool();

	await new Promise((r) => setTimeout(r, 2000));

	const connect = await connectProdSql();
	apiReturn(res, {
		success: connect.success,
		level: connect.success ? "info" : "error",
		module: "routes",
		subModule: "prodSql",
		message: "Sql Server has been restarted",
		data: connect.data,
		status: connect.success ? 200 : 400,
	});
});
export default r;
