1+ import type { Database } from "@webstudio-is/postrest/index.server" ;
12import type { AppContext } from "@webstudio-is/trpc-interface/index.server" ;
23import type { GitHubProfile } from "remix-auth-github" ;
34import 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
178export 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
3223const 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
7565export const createOrLoginWithOAuth = async (
0 commit comments