staff yup => zod

This commit is contained in:
Manav Rathi
2024-06-02 17:10:27 +05:30
parent c9c582cbcc
commit 7c3a137723
2 changed files with 5 additions and 5 deletions

View File

@@ -11,7 +11,7 @@
"dependencies": {
"react": "^18",
"react-dom": "^18",
"yup": "^1.4"
"zod": "^3"
},
"devDependencies": {
"@/build-config": "*",

View File

@@ -1,10 +1,10 @@
import { object, type InferType } from "yup";
import { z } from "zod";
const apiOrigin = import.meta.env.VITE_ENTE_ENDPOINT ?? "https://api.ente.io";
const userDetailsSchema = object({});
const UserDetails = z.object({}).passthrough();
export type UserDetails = InferType<typeof userDetailsSchema>;
export type UserDetails = z.infer<typeof UserDetails>;
/** Fetch details of the user associated with the given {@link authToken}. */
export const getUserDetails = async (
@@ -17,5 +17,5 @@ export const getUserDetails = async (
},
});
if (!res.ok) throw new Error(`Failed to fetch ${url}: HTTP ${res.status}`);
return await userDetailsSchema.validate(await res.json());
return UserDetails.parse(await res.json());
};