| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import { z } from "zod";
- import {
- upstashIntegrationValidator,
- type ClientUpstashIntegration,
- } from "lib/upstash/types";
- import api from "shared/api";
- type TUseUpstash = {
- getUpstashIntegrations: ({
- projectId,
- }: {
- projectId: number;
- }) => Promise<ClientUpstashIntegration[]>;
- };
- export const useUpstash = (): TUseUpstash => {
- const getUpstashIntegrations = async ({
- projectId,
- }: {
- projectId: number;
- }): Promise<ClientUpstashIntegration[]> => {
- const response = await api.getUpstashIntegrations(
- "<token>",
- {},
- {
- projectId,
- }
- );
- const results = await z
- .object({ integrations: z.array(upstashIntegrationValidator) })
- .parseAsync(response.data);
- return results.integrations;
- };
- return {
- getUpstashIntegrations,
- };
- };
|