brr
brr
Explore posts from servers
TtRPC
Created by brr on 7/6/2024 in #❓-help
Trying to get the return type of a procedure.
Using TRPC v11. I am failing to return the type. I get the error Type alias 'ProtectedProcedureType' circularly references itself. Any ideas? This is my code
type ProtectedProcedureType = inferProcedureBuilderResolverOptions<
typeof protectedProcedure
>;

export type ProtectedProcedureContext = ProtectedProcedureType["ctx"];
type ProtectedProcedureType = inferProcedureBuilderResolverOptions<
typeof protectedProcedure
>;

export type ProtectedProcedureContext = ProtectedProcedureType["ctx"];
I need the type to be reusable in other files. I also tried this
type ProtectedProcedure = typeof protectedProcedure
type ProtectedProcedureOptions = Parameters<Parameters<ProtectedProcedure['query']>[0]>[0]
export type ProtectedProcedureContext = ProtectedProcedureOptions['ctx']
type ProtectedProcedure = typeof protectedProcedure
type ProtectedProcedureOptions = Parameters<Parameters<ProtectedProcedure['query']>[0]>[0]
export type ProtectedProcedureContext = ProtectedProcedureOptions['ctx']
still when I slap on the export I get the circularly references itself error...
2 replies
TTCTheo's Typesafe Cult
Created by brr on 2/8/2024 in #questions
useQueries hook
Hey, I am importing the api from trpc/react and I can't seem to be able to use the useQueries hook from react-query. The options that pop up are useQuery, useSuspenseQuery and getQueryKey I have a query which will return multiple ids, and I need to run these ids to the useQueries, if this makes sense, any help is appreciated
2 replies
TTCTheo's Typesafe Cult
Created by brr on 12/29/2022 in #questions
prisma folder and db nowhere to be found in docker container
4 replies
TTCTheo's Typesafe Cult
Created by brr on 12/28/2022 in #questions
Docker is failing on openssl1.1-compat
I am trying to build my t3 project, but I get these errors
#8 2.590 ERROR: unable to select packages:
#8 2.619 openssl1.1-compat (no such package):
#8 2.619 required by: world[openssl1.1-compat]"
#8 2.590 ERROR: unable to select packages:
#8 2.619 openssl1.1-compat (no such package):
#8 2.619 required by: world[openssl1.1-compat]"
I tried lots of things suggested here https://github.com/prisma/prisma/issues/16553, and I am not sure if I should update prisma to 4.8.0 which supposedley fixes the issue. I am on prisma 4.5.0, any ideas? I am on windows
3 replies
TTCTheo's Typesafe Cult
Created by brr on 12/26/2022 in #questions
trying to access req and res in trpc query
I need to access res to set a header. I tried accessing req and res from ctx but only session and prisma are available. Any ideas? I tried looking it up but didn't really get anywhere
export const filesRouter = router({
getPreSignedUrl: protectedProcedure
.input(
z.object({
fileName: z.string().min(1),
})
)
.query(async ({ ctx, input }) => {
console.log("in");
console.log(ctx);
...
export const filesRouter = router({
getPreSignedUrl: protectedProcedure
.input(
z.object({
fileName: z.string().min(1),
})
)
.query(async ({ ctx, input }) => {
console.log("in");
console.log(ctx);
...
12 replies
TTCTheo's Typesafe Cult
Created by brr on 10/6/2022 in #questions
react query question
currently when fetching the current user im checking if the JWT has expired, and making a call to a route to refresh the JWT. I placed both of these in 1 query (which I think is bad practice), how can I split them up?
function useAuth() {
return useQuery(
['user'],
async () => {
let expiresAt = localStorage.getItem('expires_at') || 0;
let refreshToken = localStorage.getItem('refresh_token');
if (new Date().getTime() > expiresAt) {
const res = await axios.post(
`${url}/api/auth/refresh`,
{
refreshToken: refreshToken,
},
{
withCredentials: true,
}
);
localStorage.setItem('refresh_token', res.data.refreshJwt);
localStorage.setItem('expires_at', res.data.expiresAt);
}
const { data } = await axios.get(`${url}/api/auth/current`, {
withCredentials: true,
});
return data.user.role;
},
{
refetchOnReconnect: false,
refetchOnWindowFocus: false,
retry: 0,
}
);
}
function useAuth() {
return useQuery(
['user'],
async () => {
let expiresAt = localStorage.getItem('expires_at') || 0;
let refreshToken = localStorage.getItem('refresh_token');
if (new Date().getTime() > expiresAt) {
const res = await axios.post(
`${url}/api/auth/refresh`,
{
refreshToken: refreshToken,
},
{
withCredentials: true,
}
);
localStorage.setItem('refresh_token', res.data.refreshJwt);
localStorage.setItem('expires_at', res.data.expiresAt);
}
const { data } = await axios.get(`${url}/api/auth/current`, {
withCredentials: true,
});
return data.user.role;
},
{
refetchOnReconnect: false,
refetchOnWindowFocus: false,
retry: 0,
}
);
}
I have tried multiple ways, but none of them seem like a good way of doing things, any help is appreciated thanks
4 replies