Skip to content

Commit 9eaf3c9

Browse files
committed
Fix types
1 parent 348429a commit 9eaf3c9

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

apps/builder/app/dashboard/dashboard.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const user = {
1616
image: null,
1717
username: "Taylor",
1818
teamId: null,
19+
provider: "github",
1920
};
2021

2122
const createRouter = (element: JSX.Element) =>

apps/builder/app/shared/db/user.server.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
1+
import type { Database } from "@webstudio-is/postrest/index.server";
12
import type { AppContext } from "@webstudio-is/trpc-interface/index.server";
23
import type { GitHubProfile } from "remix-auth-github";
34
import type { GoogleProfile } from "remix-auth-google";
4-
import { z } from "zod";
55

6-
const User = z.object({
7-
id: z.string(),
8-
email: z.string().nullable(),
9-
image: z.string().nullable(),
10-
username: z.string().nullable(),
11-
createdAt: z.string(),
12-
teamId: z.string().nullable(),
13-
});
14-
15-
export type User = z.infer<typeof User>;
6+
export type User = Database["public"]["Tables"]["User"]["Row"];
167

178
export const getUserById = async (context: AppContext, id: User["id"]) => {
189
const dbUser = await context.postgrest.client
@@ -26,7 +17,7 @@ export const getUserById = async (context: AppContext, id: User["id"]) => {
2617
throw new Error("User not found");
2718
}
2819

29-
return User.parse(dbUser.data);
20+
return dbUser.data;
3021
};
3122

3223
const genericCreateAccount = async (
@@ -45,8 +36,7 @@ const genericCreateAccount = async (
4536
.single();
4637

4738
if (dbUser.error == null) {
48-
const user = User.parse(dbUser.data);
49-
return user;
39+
return dbUser.data;
5040
}
5141

5242
// https://github.com/PostgREST/postgrest/blob/bfbd033c6e9f38cfbc8b1cfe19ee009a9379e3dd/docs/references/errors.rst#L234
@@ -69,7 +59,7 @@ const genericCreateAccount = async (
6959
throw new Error("Failed to create user");
7060
}
7161

72-
return User.parse(newUser.data);
62+
return newUser.data;
7363
};
7464

7565
export const createOrLoginWithOAuth = async (

0 commit comments

Comments
 (0)