West side ⁉
West side ⁉
Explore posts from servers
TTCTheo's Typesafe Cult
Created by West side ⁉ on 10/24/2023 in #questions
T3 App directory: can't use tRPCs useQuery hook
Even though the component is client side, any idea?
59 replies
TTCTheo's Typesafe Cult
Created by West side ⁉ on 10/24/2023 in #questions
Lucia + T3, although can't set sessions
Same as title says, I'd go to the context, and pass req and res:
export const createInnerTRPCContext = (opts: CreateContextOptions) => {
return {
headers: opts.headers,
db,
req: opts.req,
res: opts.res,
};
};

export const createTRPCContext = (opts: { req: NextRequest, res: NextResponse }) => {
// Fetch stuff that depends on the request

return createInnerTRPCContext({
headers: opts.req.headers,
req: opts.req,
res: opts.res,
});
};
export const createInnerTRPCContext = (opts: CreateContextOptions) => {
return {
headers: opts.headers,
db,
req: opts.req,
res: opts.res,
};
};

export const createTRPCContext = (opts: { req: NextRequest, res: NextResponse }) => {
// Fetch stuff that depends on the request

return createInnerTRPCContext({
headers: opts.req.headers,
req: opts.req,
res: opts.res,
});
};
Within the router, I'd try to set session, nothing happens, no cookies appear on client side:
export const userRouter = createTRPCRouter({
create: publicProcedure
.input(z.object({ email: z.string().min(1) }))
.mutation(async ({ ctx, input }) => {
const user: DatabaseUserAttributes = await auth.createUser({
key: {
providerId: "username",
providerUserId: input.email,
password: "hi",
},
attributes: {},
});
const session: { sessionId: string } = await auth.createSession({
userId: user.userId,
attributes: {},
});
const authRequest = auth.handleRequest(ctx.req.method, context);
authRequest.setSession(session);
}),
});
export const userRouter = createTRPCRouter({
create: publicProcedure
.input(z.object({ email: z.string().min(1) }))
.mutation(async ({ ctx, input }) => {
const user: DatabaseUserAttributes = await auth.createUser({
key: {
providerId: "username",
providerUserId: input.email,
password: "hi",
},
attributes: {},
});
const session: { sessionId: string } = await auth.createSession({
userId: user.userId,
attributes: {},
});
const authRequest = auth.handleRequest(ctx.req.method, context);
authRequest.setSession(session);
}),
});
Any ideas?
2 replies
TTCTheo's Typesafe Cult
Created by West side ⁉ on 10/24/2023 in #questions
Accessing headers from TRPC and modifying them
In the latest Create-T3-App it seems to be passing headers along the context but modifying them does nothing any idea on how to modify?
15 replies
TTCTheo's Typesafe Cult
Created by West side ⁉ on 10/14/2023 in #questions
Drizzle-ORM+PSQL: sorry, too many clients already
X tRPC failed on school.getAll: sorry, too many clients already I guess this is because the connections stay open? or because it opens a connection per request for some reason? This is my TRPC inner context:
const createInnerTRPCContext = (opts: CreateContextOptions) => {
return {
db,
};
};
const createInnerTRPCContext = (opts: CreateContextOptions) => {
return {
db,
};
};
(Default one provided by T3-Drizzle stack) Why is that happening?
9 replies
TTCTheo's Typesafe Cult
Created by West side ⁉ on 10/12/2023 in #questions
Validating array using zod
How is it supposed to be done? It's returning errors that are basically flat arrays, I can't determine which element of the array is errorful Any ideas? Help is GREATLY appreciated
14 replies
TTCTheo's Typesafe Cult
Created by West side ⁉ on 9/22/2023 in #questions
createServerSideHelpers not offering mutation routes!
So basically:
const helpers = createServerSideHelpers({
router: appRouter,
ctx: await createTRPCContext({ req, res }),
transformer: superjson, // optional - adds superjson serialization
});
const helpers = createServerSideHelpers({
router: appRouter,
ctx: await createTRPCContext({ req, res }),
transformer: superjson, // optional - adds superjson serialization
});
Filters out every mutation route, i.e. I can't say helpers.user.edit why??
6 replies
TTCTheo's Typesafe Cult
Created by West side ⁉ on 9/16/2023 in #questions
Am I supposed to handle type-related errors on client side? (TRPC)
No description
8 replies
TTCTheo's Typesafe Cult
Created by West side ⁉ on 9/15/2023 in #questions
await TRPC's useQuery
I want to use trpc's useQuery on the server side (in getServerProps) is it possible to await for data to arrive before returning? i.e. await api.auth.checkLogin.useQuery()?
7 replies
DTDrizzle Team
Created by West side ⁉ on 9/12/2023 in #help
.onUpdateNow() for postgresql?
is that possible?
4 replies