McKamyk
McKamyk
Explore posts from servers
Aarktype
Created by McKamyk on 4/1/2025 in #questions
string.integer.parse < 100
Here's an actual validator I'm trying to build
const decimals = type('string.integer.parse | number.integer < 28')
const decimals = type('string.integer.parse | number.integer < 28')
I want the input to be a number, potentialy in string form, and less than 28.
decimals("20") // passes fine
decimals(20) // passet file
decimals(100) // fails correctly
decimals("100") // passes *should fail*
decimals("20") // passes fine
decimals(20) // passet file
decimals(100) // fails correctly
decimals("100") // passes *should fail*
How do I build a check on the output of the parse?
39 replies
Aarktype
Created by McKamyk on 3/31/2025 in #questions
spread and generics
I'm wanting to define a generic, then another generic wrapping and passing through the generic
const apiResponse = type('<t>', {
data: 't',
last_updated: 'number',
})
type ApiResponse<T> = ReturnType<typeof apiResponse.infer<T>>['infer']
// ^ this works fine

const apiPaginatedResponse = type('<t>', {
'...': apiResponse<t>, // <-- what do I do here?
cursor: 'null | string'
})
type ApiPaginatedResponse<T> = ReturnType<typeof apiPaginatedResponse.infer<T>>['infer']
const apiResponse = type('<t>', {
data: 't',
last_updated: 'number',
})
type ApiResponse<T> = ReturnType<typeof apiResponse.infer<T>>['infer']
// ^ this works fine

const apiPaginatedResponse = type('<t>', {
'...': apiResponse<t>, // <-- what do I do here?
cursor: 'null | string'
})
type ApiPaginatedResponse<T> = ReturnType<typeof apiPaginatedResponse.infer<T>>['infer']
7 replies
TTCTheo's Typesafe Cult
Created by McKamyk on 11/9/2024 in #questions
Posthog analytics on api hotpaths.
Hi, I have an app with many APIs we expose to users (Actually tanstack start serverFns). These APIs are calling downstream APIs from one of our providers. I'd like to get some insight into which of our ServerFns are calling which downstream APIs, and how often. I'm thinking of using Posthog, because I've heard lots about them. I have a wrapper I'm putting at the top of all my ServerFns that checks auth and stuff, so I can easily put a capture({...}) event there, no problem. I also have wrappers for the downstream apis from our provider that I reuse all over the site, I can easily put another capture({...}) in each of those. What I'd like to be done though, tie the capture({...}) at the top of the serverFn to all of the capture({...})s that are done by the downstream apis. So, I'd like to understand which ServerFns are using the most downstream API credits. I'm running everything in lambda, if that makes a difference.
7 replies
TTCTheo's Typesafe Cult
Created by McKamyk on 1/11/2023 in #questions
Create T3, appDir, tRPC
So I'm wanting to start new pet project, this'll be the first time I'm using T3 with Tailwind, Next, and tRPC. I want to use the new experimental appDir setting. When I create a repo with npm create t3-app@latest it defaults to the pages/ style. I added experimental: {appDir: true} to the next config, created a app/ directory, and copy pasted pages/index.tsx to app/page.tsx. But I'm getting errors saying I'm importing a component that needs useState, which only works on Client Components.
Maybe one of these should be marked as a client entry with "use client":
node_modules/@trpc/next/dist/index.mjs
src/utils/api.ts
src/app/page.tsx
Maybe one of these should be marked as a client entry with "use client":
node_modules/@trpc/next/dist/index.mjs
src/utils/api.ts
src/app/page.tsx
Should I forego T3 and setup Next/Tailwind/Typescript/tRPC manually, or should I adapt T3 into using app/ properly?
14 replies