dashpresshq/dashpress

View on GitHub
src/pages/api/entities/[entity]/relations.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import { entitiesApiService } from "@/backend/entities/entities.service";
import { requestHandler } from "@/backend/lib/request";
import type { IAccountProfile } from "@/shared/types/user";

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

    return await entitiesApiService.getEntityRelationsForUserRole(
      validatedRequest.entity,
      (validatedRequest.authenticatedUser as IAccountProfile).role
    );
  },
});