import { updateSettings } from "@/models/settings";
import { response } from "@/utils/helper";

export async function PATCH(request) {
  try {
    let body = await request.json();

    if (!body?.data)
      return response(400, "Bad Request", null, {
        error: "Data is unvalid or empty",
      });

    const result = await updateSettings(body.data, "bridge");

    return response(200, "Set settings successfully", result);
  } catch (error) {
    console.log(error);
    return response(500, "Internal Server Error", null, {
      error: "Failed to set settings",
    });
  }
}
