dashpresshq/dashpress

View on GitHub
src/pages/api/entities/[entity]/relation-list.ts

Summary

Maintainability
A
30 mins
Test Coverage
A
100%
import { entitiesApiController } from "@/backend/entities/entities.controller";
import { requestHandler } from "@/backend/lib/request";
import { UserPermissions } from "@/shared/constants/user";

export default requestHandler(
  {
    GET: async (getValidatedRequest) => {
      const validatedRequest = await getValidatedRequest(["entity"]);

      return await entitiesApiController.listAllEntityRelations(
        validatedRequest.entity
      );
    },
  },
  [
    {
      _type: "canUser",
      body: UserPermissions.CAN_CONFIGURE_APP,
    },
  ]
);