2022-04-25 15:15:17 +02:00
|
|
|
import axios from "axios";
|
|
|
|
import { AppwriteFileWithPreview } from "../types/File.type";
|
|
|
|
|
|
|
|
const get = async (shareId: string, password?: string) => {
|
2022-04-28 16:01:50 +02:00
|
|
|
return (await axios.post(`/api/share/${shareId}`, { password }))
|
|
|
|
.data as AppwriteFileWithPreview[];
|
|
|
|
};
|
|
|
|
const isIdAlreadyInUse = async (shareId: string) => {
|
|
|
|
return (await axios.get(`/api/share/${shareId}/exists`)).data
|
|
|
|
.exists as boolean;
|
2022-04-25 15:15:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const authenticateWithPassword = async (shareId: string, password?: string) => {
|
2022-04-28 16:01:50 +02:00
|
|
|
return (await axios.post(`/api/share/${shareId}/enterPassword`, { password }))
|
|
|
|
.data as AppwriteFileWithPreview[];
|
2022-04-25 15:15:17 +02:00
|
|
|
};
|
|
|
|
|
2022-04-28 16:01:50 +02:00
|
|
|
export default { get, authenticateWithPassword, isIdAlreadyInUse };
|