import { Hono } from "hono/tiny";
import { createRoute } from "../../modules/api-utils/createRoute";
import { credentialTypes } from "../../managers/credentialTypes";
import { apiResponse } from "../../modules/api-utils/apiResponse";
import { ContentfulStatusCode } from "hono/utils/http-status";
import { authMiddleware } from "../middleware/authorization";

/* /v1/credential-type/:id */
export default createRoute(
  "delete",
  ["/:id"],

  async (c) => {
    await credentialTypes.delete(c.req.param("id"));

    const response = apiResponse.successful(
      "Credential Type Deleted Successfully!",
      null,
    );
    return c.json(response, response.status as ContentfulStatusCode);
  },
  authMiddleware({ permissions: ["credential_type.delete"] }),
);
