Grimbo
Grimbo
TTCTheo's Typesafe Cult
Created by Grimbo on 11/9/2023 in #questions
React Strict Mode - Second render, different initial state ?
No description
11 replies
TTCTheo's Typesafe Cult
Created by Grimbo on 11/2/2023 in #questions
Vercel postgres + Prisma migrate
I got a super simple setup using Vercel's Postgres services, when running prisma migrate dev I do however get stuck with the following error:
Error: ERROR: database "prisma_migrate_shadow_db_ff837554-d59a-4816-be77-e2cd7b0cb73b" is being accessed by other users
DETAIL: There are 2 other sessions using the database.
Error: ERROR: database "prisma_migrate_shadow_db_ff837554-d59a-4816-be77-e2cd7b0cb73b" is being accessed by other users
DETAIL: There are 2 other sessions using the database.
Searching around the web is not making me much wiser when it comes to Vercel's services specifically on how to resolve the issue. Does anyone happen to have any insight or ideas on how to resolve the issue? Cheers!
3 replies
TTCTheo's Typesafe Cult
Created by Grimbo on 10/13/2023 in #questions
Headless CMS for Notion like knowledge base ?
Hello! I have a, potential, upcoming consulting gig where a company that publishes books, tv shows and games in their IP wants to build an internal wiki for their world lore. They want something Notion-like in the sense of the possibility of pages to have nested sub-pages several levels deep. And then on top of that a bunch of other quite deep and custom features for search, user accounts, changelogs for new pages etc. I'm quite settled on my tech stack already. I'm, however, having a hard time to find a headless CMS that matches my need , where you can define a structure of nested pages.I couldn't find anything from Contentful, CosmicJS etc. that seem to support that in a great way. My current best idea is to actually use Notion as the CMS where they edit pages... and then use Notion's API to fetch data and pages. But, it's a little cumbersome to work with. Or end up building a basic CMS myself, using some library and e.g. markdown files. Does anyone else know of a CMS that you think could be a good candidate, or have any other idea on how you would approach this? Cheers! 🌟
10 replies
TTCTheo's Typesafe Cult
Created by Grimbo on 6/22/2023 in #questions
getStaticProps & SSG helper data still being fetched on client.
Hello ya'll, my first time working on a new project using the T3 stack. Like it a lot so far. I'm a bit stumped after trying to pre-fetch data for a static page though. After looking through guides for SSG helpers, my assumption would be that the following code should work
import React from "react"
import { createServerSideHelpers } from '@trpc/react-query/server'
import { api } from "~/utils/api"
import { jobRouter } from "~/server/api/routers/job"
import { createInnerTRPCContext } from "~/server/api/trpc"
import { GetStaticPropsContext, InferGetStaticPropsType } from "next"

import { Menu, Head, Footer, JobCard } from "~/components"
import SuperJSON from "superjson"

export default function Home(props: InferGetStaticPropsType<typeof getStaticProps>) {

const { data: jobs } = api.job.getAll.useQuery()

return (
<div className="min-h-screen flex flex-col justify-between">
<Head />
<main>
<Menu />
<div className="mt-18 p-4 flex flex-col gap-4">
{jobs?.map((job) => (<JobCard key={job.id} title={job.title} companyName={job.company.name} companyLogo={job.company.logoUrl} />))}
</div>
</main>
<Footer />
</div>
)
}

export const getStaticProps = async (context: GetStaticPropsContext) => {
const helpers = createServerSideHelpers({
router: jobRouter,
ctx: createInnerTRPCContext({ session: null }),
transformer: SuperJSON
})

await helpers.getAll.prefetch()

return {
props: {
trpcState: helpers.dehydrate(),
},
}
}
import React from "react"
import { createServerSideHelpers } from '@trpc/react-query/server'
import { api } from "~/utils/api"
import { jobRouter } from "~/server/api/routers/job"
import { createInnerTRPCContext } from "~/server/api/trpc"
import { GetStaticPropsContext, InferGetStaticPropsType } from "next"

import { Menu, Head, Footer, JobCard } from "~/components"
import SuperJSON from "superjson"

export default function Home(props: InferGetStaticPropsType<typeof getStaticProps>) {

const { data: jobs } = api.job.getAll.useQuery()

return (
<div className="min-h-screen flex flex-col justify-between">
<Head />
<main>
<Menu />
<div className="mt-18 p-4 flex flex-col gap-4">
{jobs?.map((job) => (<JobCard key={job.id} title={job.title} companyName={job.company.name} companyLogo={job.company.logoUrl} />))}
</div>
</main>
<Footer />
</div>
)
}

export const getStaticProps = async (context: GetStaticPropsContext) => {
const helpers = createServerSideHelpers({
router: jobRouter,
ctx: createInnerTRPCContext({ session: null }),
transformer: SuperJSON
})

await helpers.getAll.prefetch()

return {
props: {
trpcState: helpers.dehydrate(),
},
}
}
I'm only going to need to revalidate my frontpage once per day for new jobs. However, when deploying my app to Vercel, it's clearly not static. I can see a network request made, and any new data in the db will be shown. Appreciate any help or ideas 🙏
10 replies