Theo's Typesafe Cult

TTC

Theo's Typesafe Cult

Join the community to ask questions about Theo's Typesafe Cult and get answers from other members.

Join

server side calls trpc

Hi, is there someone who can explain to me how do I make server side call with trpc in t3 ??

zod to check if string is only whitespaces

how do i use zod to check if a string is only whitespaces?

is there a way to typesafety in Swagger Ui

i wonder if there is a way to write api's docs with swagger with typesafety in it ? of course that wouldn't be a comment , maybe an object type or somethings and the docs would be in .json and do you any alternative to write docs for an api beside swagger...

getServerSideProps NextJS

Is getServerSideProps used only to fetch data? I mean is it worth calling it e.g to fetch images from public folder?...

Union TS generic function definitions into one type with all possible input -- output types

Working with GQL for my employer and using graphql-hooks which is being invoked inside a custom hook that handles adding headers for us as needed. I'd like to create a type definition that will allow us to denote what the expected response in the data key will be based on the input string passed as an argument. I went ahead and created a def that accepts two generic parameters, one which represents the input string literal (T) and the other which represents the expected shape of the data (U):
type UseGQLGeneric<T, U> = (
request: T, // GQL query string
requestOptions?: object
) => [RequestFn<U>, UseClientRequestResult<U>]; // U being the response body
type UseGQLGeneric<T, U> = (
request: T, // GQL query string
requestOptions?: object
) => [RequestFn<U>, UseClientRequestResult<U>]; // U being the response body
...

What calendar software do you use? (Windows, MacOS, iOS)

Hey! I want to start scheduling my day, so I started looking for some calendar software/app that has good compatibility across all devices. Which one would you recommend me to use based on your satisfaction?...

Free site for sending signup signin emails?

which site is good for sending emails for signup/signin

Conditional render - UI with mode

Can anyone point to a repo / project which exemplifies a React code pattern for a UI which has 2 modes. For example, admin user and user. In such a UI the admin can configure the things within the UI, and these are seen by the user. Here the UI is very similar for both roles, but the behaviour and controls are different. Simply filling the code with conditions to render / not render various controls is too simplistic, messy and hard to maintain. What I'm looking for is something like a page structure into which two sets of behaviours are imposed....

Presigned Url image upload get response

I am uploading an images using a presigned url currently this is my response ```ts uploadResult Response {type: 'cors', url: 'https://s3.eu-west-1.amazonaws.com/foobar', redirected: false, status: 204, ok: true, …} body: ReadableStream...

[solved] pnpm being annoying on my potato

```log { "0 debug pnpm:scope": { "selected": 1 },...

Unable to apply certain CSS-attributes to Radix components

I am working on a dropdown menu and text-based properties like text-xl, font-medium were applied, but not bg-lime-400 Looking at the DOM I can see that bg-lime-400 is in the classname, but looking at the styles tab in dev tools I see no mention of background-color being applied or overridden. Here is the code snippet in case it proves useful:...

How nextJS optimizes application for SEO?

If it's still an SPA why we can't have good SEO with CRA?

tRPC with mobile apps?

What's the suggested way of working with tRPC when it comes to mobile apps? How do you ensure that your CI doesn't let you push a new backend to production if it breaks the mobile app in production?

How to secure DB secrets in T3 stack (Next.js)

I am getting up and running with the T3 stack and I am wondering where I can keep my database secrets so they aren't bundled into the client. For instance, I want to use firebase-admin on my server which requires me to have a firebase config file. How can I tell NextJS "please keep these secrets only on the server side"?

tRPC vs nextJS API routes

In a T3 app, are there any advantages to still using plain old nextJS API routes? Or, do you find yourselves just putting everything in your tRPC router?

how do I get the name of the component passed as Outlet?

I'm using react-location for routing, and I'm passing some components as children to a this sharedLayout component. ```html <sharedLayout> <Outlet /> </sharedLayout>...

NextAuth - should I use JWTs or DB sessions (adapter)

I've watched the video where Theo rants about NextAuth, sessions etc. However my question is still which option should I use and why (between DB session and JWTs)? For example, I understand that the adapter is useful when you need to keep track of all the sessions, refresh tokens, invalidate sessions etc. and that JWT have their drawbacks, like you can't unset them once they are defined. However, in my case I don't really use those features (refresh tokens) at all because all I need from Auth is confirmation to let them login, after that I don't need any provider services because of which I would need to refresh. That's why I also don't need all the other information I get from the providers and It also makes managing the db simpler, because of some of my use cases....

Env import in `next.config.mjs` for Docker Image

Hey, in the docs of create-t3-app it states that I should remove the import { env } from "./src/env/server.mjs"; when deploying with Docker. How exactly am I able to do this only for production? Because I'd like to keep it for development to check env vars.

fetching data from external api with trpc

So i've watched a couple trpc videos, but I still don't know how to fetch data from some api for example: https://pokeapi.co/ with TRPC. TRPC is for sure the most confusing part of the stack for me. Am I just dumb?

picking new tech quickly

What's your advice of picking new tech quickly? I was invited to do a task for recrutation in Django, the problem is Ive never used Django before (job is for jr backend i mainly do front these days but why not give it a shot) I did something with flask in the past, don't know how similiar they are. The task doesnt look that hard and I have 7 days but still not knowing Django sucks 😵