jeff.kershner
jeff.kershner
RRefine
Created by quickest-silver on 1/23/2024 in #general
1. Adding List Page | refine
I need a NextJS application though. Is there a tutorial for NextJS?
2 replies
TTCTheo's Typesafe Cult
Created by aditya on 9/25/2023 in #questions
No response returning from api route
It is tough to debug this just by looking at your code. If you write console logs at each step and see what values are going in and coming out, that is probably the best way to see what is going on. It is weird that you are not getting any response? Like seriously no response from the API? Are you getting a 200 but no data, or is the API not even returning?
6 replies
TTCTheo's Typesafe Cult
Created by cadams on 9/25/2023 in #questions
When to use "src/page/api/doStuff.ts" vs "src/server/api/routers/routerThatDoesStuff.ts"
Hello... as you know, you can't call a hook conditionally. But in react-query (and tRPC), you can supply an enabled parameter on when you want to call that useQuery. For example:
const bill = api.sale.bill.useQuery(
{rows: spreadSheet?.rows ?? [] },
{ refetchInterval: false, refetchOnWindowFocus: false, enabled: hasBilled });
const bill = api.sale.bill.useQuery(
{rows: spreadSheet?.rows ?? [] },
{ refetchInterval: false, refetchOnWindowFocus: false, enabled: hasBilled });
This useQuery will only be executed if hasBilled is true. This is a typical pattern that is used when submitting a form. When clicking submit, you change a local state variable to true and use that variable in the enabled flag. Does this answer your question?
11 replies
TTCTheo's Typesafe Cult
Created by Bozic0909 on 9/18/2023 in #questions
env variable is undefined
Isn't this a t3 discord?
6 replies
TTCTheo's Typesafe Cult
Created by Bhan Singh on 9/23/2023 in #questions
Drizzle and Create-t3
@Bozic0909 You shouldn't have to do that if you are running dotenv in your studio command like this (in your package.json):
"db:studio": "dotenv drizzle-kit studio",
"db:studio": "dotenv drizzle-kit studio",
My entire drizzle.config.ts look like this:
import { type Config } from "drizzle-kit";

import { env } from "~/env.mjs";

export default {
schema: "./src/server/db/schema.ts",
driver: "mysql2",
dbCredentials: {
connectionString: env.DATABASE_URL,
},
tablesFilter: ["rtc_*"],
} satisfies Config;
import { type Config } from "drizzle-kit";

import { env } from "~/env.mjs";

export default {
schema: "./src/server/db/schema.ts",
driver: "mysql2",
dbCredentials: {
connectionString: env.DATABASE_URL,
},
tablesFilter: ["rtc_*"],
} satisfies Config;
21 replies
TTCTheo's Typesafe Cult
Created by Bhan Singh on 9/23/2023 in #questions
Drizzle and Create-t3
If either of you are still having trouble, send me your github repo (if its public) and I can try it locally. Your repo will not contain your .env file (at least it shouldn't), so it would be safe sharing.
21 replies
TTCTheo's Typesafe Cult
Created by Bhan Singh on 9/23/2023 in #questions
Drizzle and Create-t3
@Bhan Singh Interesting that you are getting invalid environment variables. What variables do you have? For database, you should only have DATABASE_URL. What auth provider are you using? Whatever auth provider you are using, you will need to make sure they are in your .env and env.mjs (in two places - in the server object and in the runtimeEnv).
21 replies
TTCTheo's Typesafe Cult
Created by Bhan Singh on 9/23/2023 in #questions
Drizzle and Create-t3
No description
21 replies
TTCTheo's Typesafe Cult
Created by Bhan Singh on 9/23/2023 in #questions
Drizzle and Create-t3
Your DATABSE_URL is wrong... Planetscale should give you this connection string (you might have to click on prisma in planetscale to see it). It should be something like this (replaced parts of my connection string with xxxx for obvious reasons):
mysql://t2xxxxxxxxxxosmqy:[email protected]/rtc?ssl={"rejectUnauthorized":true}
mysql://t2xxxxxxxxxxosmqy:[email protected]/rtc?ssl={"rejectUnauthorized":true}
If you go to your planetscale dashboard and click on settings -> passwords and click on Connect with Prisma (I know you are not using prisma, but that is the connect string you need). But you have to replace the sslaccept=strict with ssl={"rejectUnauthorized":true}
21 replies
TTCTheo's Typesafe Cult
Created by Bhan Singh on 9/23/2023 in #questions
Drizzle and Create-t3
It worked for me with a fresh install of a new planetscale database, brand new t3 app (7.20.2). I am using bun and NextAuth with a GoogleProvider. Does your drizzle-kit studio work and show your tables? Add this to your package.json:
"db:studio": "dotenv drizzle-kit studio",
"db:studio": "dotenv drizzle-kit studio",
And make sure you install mysql2 package:
bunx add mysql2
bunx add mysql2
Make sure your planetscale database string in your .env ends with:
?ssl={"rejectUnauthorized":true}
?ssl={"rejectUnauthorized":true}
No other custom changes were made on my side. Did you guys make any changes or do anything different?
21 replies
TTCTheo's Typesafe Cult
Created by Bozic0909 on 9/18/2023 in #questions
env variable is undefined
Not sure if this is an older version of t3, but in the latest at the time of my post (7.20.2), the drizzle.config.ts looks like this out of the box (and works):
import { type Config } from "drizzle-kit";

import { env } from "~/env.mjs";

export default {
schema: "./src/server/db/schema.ts",
driver: "mysql2",
dbCredentials: {
connectionString: env.DATABASE_URL,
},
tablesFilter: ["rtc_*"],
} satisfies Config;
import { type Config } from "drizzle-kit";

import { env } from "~/env.mjs";

export default {
schema: "./src/server/db/schema.ts",
driver: "mysql2",
dbCredentials: {
connectionString: env.DATABASE_URL,
},
tablesFilter: ["rtc_*"],
} satisfies Config;
6 replies
TTCTheo's Typesafe Cult
Created by Bhan Singh on 9/23/2023 in #questions
Drizzle and Create-t3
Mine worked out of the box with no custom changes. I know you said you pushed your schema but can you confirm the tables actually exist on planet scale? I will create a new project in the next hour to confirm as well.
21 replies
TTCTheo's Typesafe Cult
Created by papsn on 9/21/2023 in #questions
Error: Rendered more hooks than during the previous render.
Or: sessionData?.user !== “”
11 replies
TTCTheo's Typesafe Cult
Created by papsn on 9/21/2023 in #questions
Error: Rendered more hooks than during the previous render.
Try: sessionData?.user !== undefined
11 replies
TTCTheo's Typesafe Cult
Created by papsn on 9/21/2023 in #questions
Error: Rendered more hooks than during the previous render.
You can't conditionally call hooks in that manner. If you want to call that useQuery hook only when you have a user, then you have to do something like this:
const { data: sessionData } = useSession();

const data = api.example.getUserGuilds.useQuery({
userId: sessionData.user.id,
}, sessionData?.user !== null);
const { data: sessionData } = useSession();

const data = api.example.getUserGuilds.useQuery({
userId: sessionData.user.id,
}, sessionData?.user !== null);
The first parameter to useQuery is the object with your parameters, and the second parameter is the condition on when to call it. If sessionData?.user !== null (probably could be shortened to sessionData?.user), then call your userQuery. Make sense?
11 replies
TTCTheo's Typesafe Cult
Created by jeff.kershner on 9/18/2023 in #questions
Pusher with Vercel or Netlify?
OK.. I figured it out and it was silly. Apparently Vercel is closing the servless connection before the pusher is fully sent. I needed to await the pusher like this:
export const pusherRouter = createTRPCRouter({
connect: publicProcedure
.input(z.object({ name: z.string(), role: z.number() }))
.query(async({ input }) => {
await pusher.trigger(env.PUSHER_CHANNEL, env.PUSHER_EVENT, {
event: "connect",
name: input.name,
role: input.role,
role_name: indexToRoleName[input.role],
role_key: indexToRoleKey[input.role]
});

return "success";
}),
export const pusherRouter = createTRPCRouter({
connect: publicProcedure
.input(z.object({ name: z.string(), role: z.number() }))
.query(async({ input }) => {
await pusher.trigger(env.PUSHER_CHANNEL, env.PUSHER_EVENT, {
event: "connect",
name: input.name,
role: input.role,
role_name: indexToRoleName[input.role],
role_key: indexToRoleKey[input.role]
});

return "success";
}),
4 replies