JavascriptMick
Explore posts from serversPPrisma
•Created by JavascriptMick on 11/14/2024 in #help-and-questions
gin index
how would I indicate this index exists on my prisma schema...
4 replies
Real cost of scaling Nuxt on netlify
I have a web app in Nuxt3 hosted on netlify.
Trying to figure out how the cost will scale as I go live.
The website will get some traffic but is largely brochure but it also serves a rest API that will be accessed via a mobile app. This will get smashed as I scale.
Netlify Pro gives me only 125k serverless function invitations per month. If I have 1000 users (I'm b2c) that's only 4 API calls per user per day... That's not going to work.
Same plan gives me 2 million edge function invocations gives me 600 API calls per user per day .. should be ok. Do I need to use the edge preset for this?
SERVER_PRESET=netlify_edge
I guess I'm just looking for some advice from anyone who has actually scaled out a Nuxt backend. Did you use netlify or similar or go to VPS? Did costs blow out? Did you need to refactor? Any help or refs appreciated
6 replies
PPrisma
•Created by JavascriptMick on 4/21/2024 in #help-and-questions
children and favourite child (ambiguous relation)
I want to model a relationship where a parent record can have many children but there is also a 'favourite' (or 'current favourite') child out of the list of children indicated by an id reference in the parent, to the child. I realise that this is a bit of a circular relationship and care will need to be taken when removing children or changing the favourite but I think the efficiency in query performance is worth the effort. Here is a contrived example...
This according to my brain should be fine but Prisma complains
I have tried a number of iterations of this including naming the relations and adding back references etc, all of which just introduce even more validation issues.
Any Ideas how I can make Prisma happy with this approach?
2 replies
Use onError to change an application error into a TRPCError?
I want to use the onError handler to change any instance of a custom application error into a TRPCError (I want the HTTP Status code to be a 401 rather than a 500). I tried this but it doesn't work...
nor does this
I can set individual properties on the error object like error.message but thought there might be an easier way. Has anybody got a nifty hack for this?
8 replies
Best Design system for SAAS app?
I'm shite at CSS but need to make my SAAS site look pretty. In the past I have used Bootstrap for everything but am open to new approaches. I guess important features are:-
- works good with Nuxt 3
- lots of example snippets
- possibility of theming
10 replies
Global onMounted for Pinia initialisation?
I have an initialisation method on my Pinia store that I want to invoke before any other store stuff is invoked. I am currently using onMounted on a header component but it feels like a hack and doesn't always fire.
AppHeader.vue script setup...
Is there a better approach for global store initialisation? maybe onMounted for the app.vue? or in defineNuxtConfig 'ready' hook?
8 replies
is context cached?
If I put an object on the context that represents the User record from my database...
And then I have a router function which changes important details of the user....
Do I need to 'mutate' the dbUser on the context....
or will subsequent calls to routes, re-invoke createContext and re-load the user from the database?
7 replies
Best way to implement input based validation on a router procedure
Hi guys, bit of a noob. I have already created a 'protectedProcedure', ensuring the user is logged in, but for some of my procedures, I also want to ensure the user is an ADMIN for the account specified on the input. This is my first try with validation just added at the top of the procedure implementation...
Is there a way to implement this with multiple input parsers (https://trpc.io/docs/procedures#multiple-input-parsers) ?? what would that look like?
15 replies
useState + watch + async fetch... should I just use Pinia at this point?
Hi All, New to Nuxt 3. I am using useState to hold my application state. I want to respond to a change in a state property (activeMembership) by doing a fetch (trpc/Prisma) and then using the fetch to update another bit of the state (notes). The following works ok but feels pretty clumsy.
Specifically, it feels strange to use a watch, it feels even stranger to put the watch + fetch in the setup script for the dashboard. I'm more familiar with Vuex where this would be an Action inside which I would dispatch a mutation to change the property (activeMembership) , then do the fetch, then dispatch another mutation to update the notes. No watches, central store, neat and tidy.
Is there a neater way to utilise useState or do I just quit and move to Vuex/Pinia at this point?
3 replies