onestyle
onestyle
Explore posts from servers
TTCTheo's Typesafe Cult
Created by onestyle on 11/14/2023 in #questions
Why am I seeing the neon db requests on the client side??
No description
4 replies
TTCTheo's Typesafe Cult
Created by onestyle on 11/11/2023 in #questions
Share types between front and and backend without trpc...
I'm working on a project using nextjs, Hono js, drizzle, turborepo . I don't want to use trpc and would like to enforce types. I want to infer the return type of the fetchMyCollection to export it and use it in the nextjs app. I tried to do type myType = ReturnType<typeof fetchAlbum> but this is only a shallow type. How can properly share the types across the backend and nextjs?
export async function fetchMyCollection(collectionItemId: string) {
const collectionItem = await myDatabase.query.collectionItems.findFirst({
where: eq(collectionItems.itemId, collectionItemId),
});
console.log("Fetched collection item: ", collectionItemId);

const resourcesCount = (
await myDatabase.select({
count: sql<number>`count(*)`,
}).from(myMediaResources).where(eq(myMediaResources.collectionItemId, collectionItemId))
)[0].count;
return { collectionItem: { ...collectionItem, resourcesCount }, resources: [] };
}
export async function fetchMyCollection(collectionItemId: string) {
const collectionItem = await myDatabase.query.collectionItems.findFirst({
where: eq(collectionItems.itemId, collectionItemId),
});
console.log("Fetched collection item: ", collectionItemId);

const resourcesCount = (
await myDatabase.select({
count: sql<number>`count(*)`,
}).from(myMediaResources).where(eq(myMediaResources.collectionItemId, collectionItemId))
)[0].count;
return { collectionItem: { ...collectionItem, resourcesCount }, resources: [] };
}
3 replies
TTCTheo's Typesafe Cult
Created by onestyle on 9/22/2023 in #questions
Setting my T3 stack manually
Hey, is there a video/guide to setup T3 stack manually. I have an MUI template which I want to use the same T3 config #questions
5 replies