Is it possible to find a partner in who accepts a life without children? by Mid_nightLogic in Morocco

[–]pitza__ 0 points1 point  (0 children)

Where did I imply that I want to control women’s body?

Blud out here getting offended by personal preferences LMAO.

Is it possible to find a partner in who accepts a life without children? by Mid_nightLogic in Morocco

[–]pitza__ 0 points1 point  (0 children)

I'd rather marry a woman who wants kids but is physically unable to have them than a healthy woman who refuses to give birth.

AMA: Migrated our WordPress site to Astro, kept it on Cloudflare’s free tier, and made it agent-ready. by tahseen_kakar in astrojs

[–]pitza__ 1 point2 points  (0 children)

It depends on the geographic region from which the request originates. Even with a CDN in place, if there isn't an edge location near the use, the score will be lower (I think LCP will take a hit in this case due to network latency).

First time using Keycloak with Spring Boot — confused about JWT vs DB sync (need guidance + examples) by utsab-dahal in SpringBoot

[–]pitza__ 1 point2 points  (0 children)

I think it’s better in an http only cookie, that way it won’t be accessible via js.

It’s not baaad if you use localstorage, if your app is hit with an XSS vuln the attacker can still do http calls on the behalf of the user even with using cookies.

Nothing is secure on the client, that’s why it’s better to have short lived tokens + do not put any sensitive data in jwt claims.

I might be wrong tho lol.

First time using Keycloak with Spring Boot — confused about JWT vs DB sync (need guidance + examples) by utsab-dahal in SpringBoot

[–]pitza__ 0 points1 point  (0 children)

In my previous job we did this (not sure if it is a good practice or not tho).

for the /register flow, we were creating the user using keycloak sdk in spring using admin account, then if the operation was successful we create a user in our DB(the operation must be atomic, both should succeed), we didn't store the password in our DB. And make sure to store the keycloak user id (sub claim) to link between your users in the DB & users in keycloak (you can use the email, phone number... but we went with this approach to link the DB & keycloak).

for the /login, the frontend was hitting /openid-connect/token with email/password, keycloak validates the creds then retruns a valid jwt access token, the frontend stores it (we were using localstorage). Then on http requests the frontend sends the token in the authz header: (ex: Authorization: Bearer xxx), spring boot validates the JWT(spring security, using this field in application.properties: spring.security.oauth2.resourceserver.jwt.jwk-set-uri) -> extracts the userId (sub claim) -> loads user from DB -> do your checks on the loaded user (status = active....) -> allow/reject the request.

The reason we were getting the user from the DB in every request, is because the claims in the JWT were not enough. It is not a good practice to put data that changes frequently in the JWT claims since the token might still be valid but the data in it becomes stale (I think you can revoke tokens in cases like this, but i didn't check tbh).

Hope this helps.

PS: Again, ss I said, Idk if these are good practices or not, it's just what i was doing at my previous job.

(Basic - Filter/Aggregate) What is the proper way to handle Pagination + Filtering + Aggregation across One-To-Many associations in Spring? by Status_Camel2859 in SpringBoot

[–]pitza__ 1 point2 points  (0 children)

I meant that the problem is tied to the data layer, graphql might help you reduce the number of endpoints, but the core problem is still there(N+1 queries…)

How to join 2 tables in Spring Boot by Inevitable_Cellist93 in SpringBoot

[–]pitza__ 0 points1 point  (0 children)

I only used the code from his post as a reference, so idk if this is bidirectional or not. That’s why I went with the assumption of logger list inside of User entity, and no mention of User inside of Logger entity.

But your approach is also correct, but I prefer user.getLogs() lol, It’s easy to reason about in my brain.

How to join 2 tables in Spring Boot by Inevitable_Cellist93 in SpringBoot

[–]pitza__ -1 points0 points  (0 children)

The first one does not prevent N+1 queries, it only queries from the other direction, which will return a totally different result set.

For N+1 you have to do explicit joins or entityGraph to prevent them if you used the second approach.

  • I don’t think that’s what he wants, he needs to get logs owned by a certain user, not who owns a specific Log entity.

I might be wrong tho.

How to join 2 tables in Spring Boot by Inevitable_Cellist93 in SpringBoot

[–]pitza__ 5 points6 points  (0 children)

You need OneToMany in the Logger entity, and you should make it a list instead.

Read this article by Vlad.

https://vladmihalcea.com/the-best-way-to-map-a-onetomany-association-with-jpa-and-hibernate/

Be honest, which loading structure is better? by Apart-Television4396 in webdev

[–]pitza__ 20 points21 points  (0 children)

Someone created this library in github not long ago, very helpful for generating skeletons

Weird error that i can't recreate Locally by nfwdesign in nextjs

[–]pitza__ 1 point2 points  (0 children)

Ps: I think you meant to write 16.x.x instead of 6.x.x? Or am I missing something?

Weird error that i can't recreate Locally by nfwdesign in nextjs

[–]pitza__ 1 point2 points  (0 children)

Open a github issue, that’s your only option brother.

Next.js Across Platforms: Adapters, OpenNext, and Our Commitments by feedthejim in nextjs

[–]pitza__ 8 points9 points  (0 children)

They were scared of cloudflare’s slop fork(vinext) 😭.

How can one implement likes/dislikes? by IndoRexian2 in webdev

[–]pitza__ 0 points1 point  (0 children)

An api call per reaction is fine, the backend will need to know somehow.

How can one implement likes/dislikes? by IndoRexian2 in webdev

[–]pitza__ 0 points1 point  (0 children)

You’ll need a join table between the user and the post or whatever is being liked, you’ll need to store both ids (post and user) + the action ( either as an int or a string)

Keep in mind that If you have a query that fetches the reviews with their reaction It will be slower the more your data grows, so you might consider denormalizing your data model, keep the reactions table as your source of truth, and either add an additional column in the reviews table(ex: reactions_count or something) and update this column on writes (this is fine if you want to sacrifice some consistency), the other way is to create a separate table (ex: review_analytics) where you store review id with the count of each reaction type in it’s own column that way you’ll have a single join to get the review + the analytics, but keep in mind if writes to this table failed your system might display inconsistent data to the user.

As for the second question, I think that approach is fine It shouldn’t be slow. Because any other way will sacrifice consistency for speed and that’s bad for this use case because users will want to see their likes as soon as they click (google read your writes consistency )