dashpresshq/dashpress

View on GitHub
src/pages/api/integrations/storage/active.ts

Summary

Maintainability
A
1 hr
Test Coverage
A
100%
import { requestHandler } from "@/backend/lib/request";
import { storageApiService } from "@/backend/storage/storage.service";
import { UserPermissions } from "@/shared/constants/user";

export default requestHandler(
  {
    GET: async () => {
      return { data: await storageApiService.getCurrentActivatedStorage() };
    },
    POST: async (getValidatedRequest) => {
      const validatedRequest = await getValidatedRequest([
        {
          _type: "requestBody",
          options: {},
        },
      ]);

      return await storageApiService.activateStorage(
        validatedRequest.requestBody
      );
    },
  },
  [
    {
      _type: "canUser",
      body: UserPermissions.CAN_MANAGE_APP_CREDENTIALS,
    },
  ]
);