Patryk Makowski
Patryk Makowski
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Patryk Makowski on 11/29/2023 in #questions
@ts-oss/env-core server env schema type error
No description
1 replies
TtRPC
Created by Patryk Makowski on 5/23/2023 in #❓-help
Get the type of context after middleware
How can I get the type of the context of adminProcedure from export const adminProcedure = publicProcedure.use(isAdmin)? https://trpc.io/docs/server/middlewares
1 replies
TTCTheo's Typesafe Cult
Created by Patryk Makowski on 3/27/2023 in #questions
custom handleChange
2 replies
TTCTheo's Typesafe Cult
Created by Patryk Makowski on 3/18/2023 in #questions
Clerk? Centralised Auth
I need auth provider that can be used: - In web app (Next.JS 13) - In mobile app (Prob. React Native - Expo) - In custom BE facing external customers (Prob. Apollo GraphQl - https://github.dev/howtographql/typescript-apollo) I'm trying to find out if Clerk is good for this or not but I'm not sure what I'm looking for. Does someone have experience in working with this stack?
1 replies
TTCTheo's Typesafe Cult
Created by Patryk Makowski on 2/4/2023 in #questions
Underscore variable is still triggering eslint `no-unused-vars`. Why?
10 replies
TTCTheo's Typesafe Cult
Created by Patryk Makowski on 1/19/2023 in #questions
Building CT3 app with docker - libssl error
When building ct3 app I get an error saying that in prisma generate it can't load libssl package. I've done it before like a milion times in 2022 and it worked. I haven't changed anything in dockerFile since and it is just copied from the docs. Error:
#13 87.17 > 360review@0.1.0 postinstall /app
#13 87.17 > prisma generate
#13 87.17
#13 97.90 Prisma schema loaded from schema.prisma
#13 100.7 Error: Unable to establish a connection to query-engine-node-api library. It seems there is a problem with your OpenSSL installation!
#13 100.7 Details: Unable to require(`/app/node_modules/.pnpm/prisma@4.7.1/node_modules/prisma/libquery_engine-linux-musl.so.node`)
#13 100.7 Error loading shared library libssl.so.1.1: No such file or directory (needed by /app/node_modules/.pnpm/prisma@4.7.1/node_modules/prisma/libquery_engine-linux-musl.so.node)
#13 100.7 [Context: getDmmf]
#13 100.7
#13 100.7 Prisma CLI Version : 4.7.1
#13 100.8  ELIFECYCLE  Command failed with exit code 1.
------
executor failed running [/bin/sh -c if [ -f yarn.lock ]; then yarn --frozen-lockfile; elif [ -f package-lock.json ]; then npm ci; elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i; else echo "Lockfile not found." && exit 1; fi]: exit code: 1
#13 87.17 > 360review@0.1.0 postinstall /app
#13 87.17 > prisma generate
#13 87.17
#13 97.90 Prisma schema loaded from schema.prisma
#13 100.7 Error: Unable to establish a connection to query-engine-node-api library. It seems there is a problem with your OpenSSL installation!
#13 100.7 Details: Unable to require(`/app/node_modules/.pnpm/prisma@4.7.1/node_modules/prisma/libquery_engine-linux-musl.so.node`)
#13 100.7 Error loading shared library libssl.so.1.1: No such file or directory (needed by /app/node_modules/.pnpm/prisma@4.7.1/node_modules/prisma/libquery_engine-linux-musl.so.node)
#13 100.7 [Context: getDmmf]
#13 100.7
#13 100.7 Prisma CLI Version : 4.7.1
#13 100.8  ELIFECYCLE  Command failed with exit code 1.
------
executor failed running [/bin/sh -c if [ -f yarn.lock ]; then yarn --frozen-lockfile; elif [ -f package-lock.json ]; then npm ci; elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i; else echo "Lockfile not found." && exit 1; fi]: exit code: 1
34 replies
TTCTheo's Typesafe Cult
Created by Patryk Makowski on 1/15/2023 in #questions
NextAuth user in middleware
Hi, I want to get user in the middleware so I can do conditional redirection of the users that don't have specific property yet defined. Like an onboarding screen. How can i get user in the middleware to have something like this:
export function middleware(request: NextRequest) {
const isUserOnboarded = sessionData?.user?.isOnboarded;

if (request.nextUrl.pathname.startsWith('/') && !isUserOnboarded) {
return NextResponse.rewrite(new URL('/start', request.url))
}

if (request.nextUrl.pathname.startsWith('/start') &&
isUserOnboarded) {
return NextResponse.rewrite(new URL('/', request.url))
}
}
export function middleware(request: NextRequest) {
const isUserOnboarded = sessionData?.user?.isOnboarded;

if (request.nextUrl.pathname.startsWith('/') && !isUserOnboarded) {
return NextResponse.rewrite(new URL('/start', request.url))
}

if (request.nextUrl.pathname.startsWith('/start') &&
isUserOnboarded) {
return NextResponse.rewrite(new URL('/', request.url))
}
}
https://nextjs.org/docs/advanced-features/middleware#conditional-statements
24 replies
TTCTheo's Typesafe Cult
Created by Patryk Makowski on 12/14/2022 in #questions
Headless UI not working with NextJs 13 app dir
I copied just simple example from docs of Headless UI of Disclosure and without any errors it just doesn't work .
16 replies
TTCTheo's Typesafe Cult
Created by Patryk Makowski on 12/11/2022 in #questions
Zod discriminatedUnion
Hi guys, I have na union type as follows:
ts
sections: z.array(
z.discriminatedUnion("sectionType", [
z.object({
sectionType: z.literal("single"),
sectionName: z.string(),
answer: z.string(),
}),
z.object({
sectionType: z.literal("multiple"),
sectionName: z.string(),
questions: z.array(
z.object({
question: z.string(),
answer: z.string(),
})
),
}),
])
),
ts
sections: z.array(
z.discriminatedUnion("sectionType", [
z.object({
sectionType: z.literal("single"),
sectionName: z.string(),
answer: z.string(),
}),
z.object({
sectionType: z.literal("multiple"),
sectionName: z.string(),
questions: z.array(
z.object({
question: z.string(),
answer: z.string(),
})
),
}),
])
),
I want to get typesafe value from form to properly map questions. Currently I've done this:

export const getSection = <T extends SelfFormValues["sections"][number]>(
section: T | undefined,
type: T["sectionType"]
) => {
if (!section) throw new Error("Section not found");
if (section.sectionType !== type) throw new Error("Section type mismatch");
return section;
};

export const getSection = <T extends SelfFormValues["sections"][number]>(
section: T | undefined,
type: T["sectionType"]
) => {
if (!section) throw new Error("Section not found");
if (section.sectionType !== type) throw new Error("Section type mismatch");
return section;
};
But i still get an error Property 'questions' does not exist on type '{ answer: string; sectionType: "single"; sectionName: string; } when used like this:
{getSection(values.sections[0], "multiple")?.questions.map(
({ question }, index) => {
if (!question) return null;
const [label, subText] = question.replace(")", "").split("(");
return (
<SingleOptionRadio
isVertical
key={question}
label={`${label}`}
subText={subText}
{...getInputProps(
`sections.0.answers.${index}.answer` as const
)}
/>
);
}
)}
{getSection(values.sections[0], "multiple")?.questions.map(
({ question }, index) => {
if (!question) return null;
const [label, subText] = question.replace(")", "").split("(");
return (
<SingleOptionRadio
isVertical
key={question}
label={`${label}`}
subText={subText}
{...getInputProps(
`sections.0.answers.${index}.answer` as const
)}
/>
);
}
)}
2 replies
TTCTheo's Typesafe Cult
Created by Patryk Makowski on 11/28/2022 in #questions
NextAuth middleware
I don't know why when I'm using NextAuth middleware and I successfully log In (I can see session when I disable middleware and use useSession hook on index page) it still redirects me to login page 😕
9 replies
TtRPC
Created by Patryk Makowski on 11/17/2022 in #❓-help
CAS Authentication
So long story short. My University is using CAS as authentication provider. I was thinking that I could use NextAuth with it to authenticate my users but I have no clue how am I supposed to do that. They don't support OAuth2 because they have old version of CAS. I asked on GH discussion in NextAuth for help but didn't get any. I also tried seeking help on Theo's discord twice this month but no luck. I don't know what to do and I feel like people working there have no clue what to do. I really want to be using TRPC with NextJS as I love this combo but how on earth can I authenticate my users using something like this? I was told I could use this lib https://www.npmjs.com/package/node-cas-client
13 replies
TTCTheo's Typesafe Cult
Created by Patryk Makowski on 11/16/2022 in #questions
CAS with nextAuth
I have tremendous problem wrapping my head around this. My University is using CAS as authentication provider and I want to use it with NextAuth as Social Login. Does anyone have any idea how can I implement it? I'm pretty blue about authentication systems and I can't figure where to even start.
1 replies
TTCTheo's Typesafe Cult
Created by Patryk Makowski on 11/9/2022 in #questions
ping.gg logo
Hi guys, is there anywhere available ping logo as svg? My girlfriend is working on logo animation for a university project and i thought it might be cool to do ping logo. Theo? Are you cool with that?
5 replies
TTCTheo's Typesafe Cult
Created by Patryk Makowski on 11/2/2022 in #questions
How can I get history in NextJS? Or just Focus on item I redirected user from when he comes back
I need to focus on the item my user was redirected from to details page when he comes back. To do so I figured I need to have focus func in my general info page (/users/) and focus if someone is redirected to it from details page (/user/{id}). Do I need to get that id to focus on that item?
19 replies
TTCTheo's Typesafe Cult
Created by Patryk Makowski on 11/1/2022 in #questions
Is there Ct3a Dockerfile example for publishing site this way? Or should I just use standard nextjs
As in title
7 replies
TTCTheo's Typesafe Cult
Created by Patryk Makowski on 10/24/2022 in #questions
Anyone CAS magican?
1 replies
TTCTheo's Typesafe Cult
Created by Patryk Makowski on 10/1/2022 in #questions
what do you guys think about this?
2 replies