dashpresshq/dashpress

View on GitHub
src/pages/api/data/[entity]/[id]/reference.ts

Summary

Maintainability
A
1 hr
Test Coverage
A
100%
import { dataApiController } from "@/backend/data/data.controller";
import { requestHandler } from "@/backend/lib/request";
import { DataActionType } from "@/shared/configurations";

export default requestHandler({
  GET: async (getValidatedRequest) => {
    const validatedRequest = await getValidatedRequest([
      "entity",
      "entityId",
      {
        _type: "crudEnabled",
        options: DataActionType.Reference,
      },
    ]);

    return await dataApiController.referenceData(
      validatedRequest.entity,
      validatedRequest.entityId
    );
  },
});