Brokenwind
Brokenwind
Explore posts from servers
TtRPC
Created by Michael Schaufelberger on 11/27/2024 in #❓-help
Hydration error when using useQuery instead of useSuspenseQuery when prefetching
I updated to the latest and I seem to not be getting this anymore. Can anyone confirm?
6 replies
BABetter Auth
Created by palicz on 1/20/2025 in #help
Protected routes
Here's my middleware:
import type { Session } from "better-auth/types";

import { betterFetch } from "@better-fetch/fetch";
import { NextResponse, type NextRequest } from "next/server";

// ---

const notAuthenticated = ["/login"];

export default async function authMiddleware(request: NextRequest) {
const { data: session } = await betterFetch<Session>("/api/auth/get-session", {
baseURL: request.nextUrl.origin,
headers: {
cookie: request.headers.get("cookie") || "",
},
});

const isNotAuthenticatedRoute = notAuthenticated.includes(request.nextUrl.pathname);

if (isNotAuthenticatedRoute && session) {
return NextResponse.redirect(new URL("/", request.url));
}

if (!session && !isNotAuthenticatedRoute) {
return NextResponse.redirect(new URL("/login", request.url));
}

return NextResponse.next();
}

export const config = {
matcher: ["/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|logo|robots.txt|403|404|500).*)"],
};
import type { Session } from "better-auth/types";

import { betterFetch } from "@better-fetch/fetch";
import { NextResponse, type NextRequest } from "next/server";

// ---

const notAuthenticated = ["/login"];

export default async function authMiddleware(request: NextRequest) {
const { data: session } = await betterFetch<Session>("/api/auth/get-session", {
baseURL: request.nextUrl.origin,
headers: {
cookie: request.headers.get("cookie") || "",
},
});

const isNotAuthenticatedRoute = notAuthenticated.includes(request.nextUrl.pathname);

if (isNotAuthenticatedRoute && session) {
return NextResponse.redirect(new URL("/", request.url));
}

if (!session && !isNotAuthenticatedRoute) {
return NextResponse.redirect(new URL("/login", request.url));
}

return NextResponse.next();
}

export const config = {
matcher: ["/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|logo|robots.txt|403|404|500).*)"],
};
This one will not let you go in the /login if you're already logged in. You can just extend that by adding in the notAuthenticated array if you want to disable sign ups or any other pages.
66 replies
PPrisma
Created by Brokenwind on 1/13/2025 in #help-and-questions
Prisma.skip on deeply nested objects
Hey, thanks for responding. In my specific example:
territory: {
id: territoryId ?? Prisma.skip,
district: {
id: districtId ?? Prisma.skip,
region: {
id: regionId ?? Prisma.skip,
},
},
},
territory: {
id: territoryId ?? Prisma.skip,
district: {
id: districtId ?? Prisma.skip,
region: {
id: regionId ?? Prisma.skip,
},
},
},
I have this structure in place so I can supply the territoryId, districtId, regionId when filtering. This allows me to have dynamic filtering and I want to supply these as needed. Just giving them territoryId, districtId, or regionId works in itself and filters through that. My issue is when I have those 3 undefined. It will use Prisma.skip as intended but it doesn't give me the result I want. The result that I want is to not filter any by territory at all. Instead, prisma (I believe) is filtering where territories are undefined (which shouldn't because I have strictUndefinedChecks) and I get no result. When I log the filters, this is what it looks like: territory: { id: dr {}, district: { id: dr {}, region: { id: dr {}, } } } Which is what prisma does when all three are undefined. Currently, this works for me:
territory:
territoryId || districtId || regionId
? {
id: territoryId ?? Prisma.skip,
district: {
id: districtId ?? Prisma.skip,
region: {
id: regionId ?? Prisma.skip,
},
},
}
: Prisma.skip,
territory:
territoryId || districtId || regionId
? {
id: territoryId ?? Prisma.skip,
district: {
id: districtId ?? Prisma.skip,
region: {
id: regionId ?? Prisma.skip,
},
},
}
: Prisma.skip,
In my opinion, if this is the structure:
territory: {
id: Prisma.skip,
district: {
id: Prisma.skip,
region: {
id: Prisma.skip,
},
},
}
territory: {
id: Prisma.skip,
district: {
id: Prisma.skip,
region: {
id: Prisma.skip,
},
},
}
It should just skip it. My workaround is ugly code and I wish I didn't need that.
4 replies
DTDrizzle Team
Created by Brokenwind on 11/25/2024 in #help
Unable to sort relational query
I've read in other places that this feature isn't available yet, tho I've seen it working in a drizzle.run site
5 replies
DTDrizzle Team
Created by Brokenwind on 11/25/2024 in #help
Unable to sort relational query
Nothing happens (it doesn't sort) but I do get TypeScript errors: Object literal may only specify known properties, and 'orderBy' does not exist in type
5 replies
DTDrizzle Team
Created by Brokenwind on 11/13/2024 in #help
Optionally migrate a table.
I didn't see this but from the looks of it, it might be what I was actually looking for. I'll give it a shot thanks!
3 replies
BABetter Auth
Created by kaas on 11/1/2024 in #bug-reports
[Not sure if bug] Admin plugin does not use the Infering Types
Glad I could help man. Good thing I also looked here for a solution
7 replies
BABetter Auth
Created by kaas on 11/1/2024 in #bug-reports
[Not sure if bug] Admin plugin does not use the Infering Types
It's not just for the username plugin. It also works for additionalFields. I agree it should be on the docs though.
7 replies
BABetter Auth
Created by kaas on 11/1/2024 in #bug-reports
[Not sure if bug] Admin plugin does not use the Infering Types
I figured you need the data key to fill up the remaining fields.
await authClient.admin.createUser({
name: "Admin for Testing",
password: "password1234",
role: "admin",
data: {
username: "admin",
},
await authClient.admin.createUser({
name: "Admin for Testing",
password: "password1234",
role: "admin",
data: {
username: "admin",
},
7 replies
BABetter Auth
Created by kaas on 11/1/2024 in #bug-reports
[Not sure if bug] Admin plugin does not use the Infering Types
I also encountered this issue. It doesn't fill them up
7 replies
DTDrizzle Team
Created by Brokenwind on 6/18/2024 in #help
Can't migrate on vercel postgres
Thanks. It still won't connect on my end. This is probably an issue with Vercel or the latest version of Drizzle
10 replies
DTDrizzle Team
Created by Brokenwind on 6/18/2024 in #help
Can't migrate on vercel postgres
Have you resolved your issue? Are you able to connect to Vercel now?
10 replies
DTDrizzle Team
Created by Brokenwind on 6/18/2024 in #help
Can't migrate on vercel postgres
Got it. Thanks
10 replies
DTDrizzle Team
Created by Brokenwind on 6/18/2024 in #help
Can't migrate on vercel postgres
That's strange.
Resolved - This incident has been resolved. Jun 18, 14:44 UTC
Are you still having issues with it?
10 replies
DTDrizzle Team
Created by Brokenwind on 6/18/2024 in #help
Can't migrate on vercel postgres
I see, I'm from SEA and I'm using sin1. Hope they would resolve it or at least post it in status. I've checked vercel-status earlier and did not see any issues posted.
10 replies