JavascriptMick
JavascriptMick
Explore posts from servers
NNuxt
Created by JavascriptMick on 12/16/2024 in #❓・help
multi-version rest api
@kapa.ai none of your solutions work. I have updated the discussion here (https://github.com/nitrojs/nitro/discussions/2413#discussioncomment-11601171) in the hope of getting a response from the Nitro team
20 replies
NNuxt
Created by JavascriptMick on 12/16/2024 in #❓・help
multi-version rest api
@kapa.ai ok so this nearly works, let me explain. This route rules configuration proxys all v2 routes to the base versions...
routeRules: {
'/api/v2/**': { proxy: '/api/**' }
},
routeRules: {
'/api/v2/**': { proxy: '/api/**' }
},
But what if I have a route that is implemented differently for V2? (e.g. /api/v2/stoopid) the above configuration ensures that the V2 version of the handler is ignored. Is it possible to have a catch all like above but somehow exclude specific routes from the catch all, something like this...
routeRules: {
'/api/v2/stoopid': { proxy: 'false' },
'/api/v2/**': { proxy: '/api/**' }
},
routeRules: {
'/api/v2/stoopid': { proxy: 'false' },
'/api/v2/**': { proxy: '/api/**' }
},
Alternatively, I will need to individually specify proxies for all default routes that have no v2 version. this is simple but tedious.

routeRules: {
'/api/v2/someroute': { proxy: '/api/someroute' },
'/api/v2/someotherroute': { proxy: '/api/someotherroute' },
... etc for all routes that have no v2 version
},

routeRules: {
'/api/v2/someroute': { proxy: '/api/someroute' },
'/api/v2/someotherroute': { proxy: '/api/someotherroute' },
... etc for all routes that have no v2 version
},
Here is a discussion that I think is relevant although it is not resolved very clearly (https://github.com/nitrojs/nitro/discussions/2413) so, I guess my question is, is it possible to include a 'catch all' glob based route in nuxtConfig but also have exclusions to the catch all for specific routes that have V2 version?
20 replies
NNuxt
Created by JavascriptMick on 12/16/2024 in #❓・help
multi-version rest api
@kapa.ai this doesn't work, it doesn't compile. can I do it with route rules in nuxt.config?
20 replies
PPrisma
Created by JavascriptMick on 11/14/2024 in #help-and-questions
gin index
FTR, this worked
@@index([my_string_column(ops: raw("gin_trgm_ops"))], type: Gin)

@@index([my_string_column(ops: raw("gin_trgm_ops"))], type: Gin)

4 replies
PPrisma
Created by JavascriptMick on 4/21/2024 in #help-and-questions
children and favourite child (ambiguous relation)
ok, never mind I figured it out. I want to apologise to anybody who is triggered by this example. I know these type of relationships can be fraught and vexxed. I only seek to understand.
model Parent {
id Int @id @default(autoincrement())

favourite_child_id Int
favourite_child Child @relation("ParentHasFavourite", fields: [favourite_child_id], references: [id])

children Child[] @relation("ParentHasChildren")

@@map("parent")
}

model Child {
id Int @id @default(autoincrement())

parent_id Int
parent Parent @relation("ParentHasChildren", fields: [parent_id], references: [id])

parents_who_love_me_most Parent[] @relation("ParentHasFavourite")

@@map("child")
}
model Parent {
id Int @id @default(autoincrement())

favourite_child_id Int
favourite_child Child @relation("ParentHasFavourite", fields: [favourite_child_id], references: [id])

children Child[] @relation("ParentHasChildren")

@@map("parent")
}

model Child {
id Int @id @default(autoincrement())

parent_id Int
parent Parent @relation("ParentHasChildren", fields: [parent_id], references: [id])

parents_who_love_me_most Parent[] @relation("ParentHasFavourite")

@@map("child")
}
2 replies
NNuxt
Created by JavascriptMick on 2/17/2024 in #❓・help
Can I put multiple Favicon assets in public?
for now, I have dumped them all in and done this in my nuxt.config.ts...
app: {
head: {
htmlAttrs: {
lang: 'en'
},
title: 'Blah',
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
{
rel: 'icon',
type: 'image/png',
sizes: '32x32',
href: '/favicon-32x32.png'
},
{
rel: 'icon',
type: 'image/png',
sizes: '16x16',
href: '/favicon-16x16.png'
},
{
rel: 'apple-touch-icon',
sizes: '180x180',
href: '/apple-touch-icon.png'
},
{ rel: 'manifest', href: '/site.webmanifest' }
]
}
},
app: {
head: {
htmlAttrs: {
lang: 'en'
},
title: 'Blah',
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
{
rel: 'icon',
type: 'image/png',
sizes: '32x32',
href: '/favicon-32x32.png'
},
{
rel: 'icon',
type: 'image/png',
sizes: '16x16',
href: '/favicon-16x16.png'
},
{
rel: 'apple-touch-icon',
sizes: '180x180',
href: '/apple-touch-icon.png'
},
{ rel: 'manifest', href: '/site.webmanifest' }
]
}
},
I guess I'll see how it goes
2 replies
TtRPC
Created by JavascriptMick on 6/2/2023 in #❓-help
Use onError to change an application error into a TRPCError?
8 replies
TtRPC
Created by JavascriptMick on 6/2/2023 in #❓-help
Use onError to change an application error into a TRPCError?
ah nice, thanks guys, yep this works.....
const t = initTRPC.context<Context>().create({
errorFormatter: (opts)=> {
const { shape, error } = opts;
if (!(error.cause instanceof AccountLimitError)) {
return shape;
}
return {
...shape,
data: {
...shape.data,
httpStatus: 401,
code: 'UNAUTHORIZED'
},
};
}
})
const t = initTRPC.context<Context>().create({
errorFormatter: (opts)=> {
const { shape, error } = opts;
if (!(error.cause instanceof AccountLimitError)) {
return shape;
}
return {
...shape,
data: {
...shape.data,
httpStatus: 401,
code: 'UNAUTHORIZED'
},
};
}
})
8 replies
NNuxt
Created by JavascriptMick on 5/7/2023 in #❓・help
What are people using for Toasts?
I also wrote a simple wrapper for the DaisyUI Modal that makes it nicer to use https://gist.github.com/JavascriptMick/77838a21d4ec1b5606dd5ae09ad21a67
10 replies
NNuxt
Created by JavascriptMick on 5/7/2023 in #❓・help
What are people using for Toasts?
oh, also, the creator of DaisyUI has indicated that the suboptimal behaviour of modal will be fixed in version 3 by using the html dialog element https://github.com/saadeghi/daisyui/issues/1341#issuecomment-1504395570
10 replies
NNuxt
Created by JavascriptMick on 5/7/2023 in #❓・help
What are people using for Toasts?
Got it working, it's not too ugly.. no additional libraries, just Pinia and DaisyUI https://gist.github.com/JavascriptMick/d2830e8703e706fe0a0f6703b0877f3f
10 replies
NNuxt
Created by JavascriptMick on 5/7/2023 in #❓・help
What are people using for Toasts?
thanks @ven yep I saw this.... and I am concerned about the accessibility aspects that were mentioned e.g. modals not really being modal etc. The consensus though in the comments for that video seemed to be that Daisy didn't have behaviour (js) so it was unreasonable to expect it to do stuff like limiting the tab context. Again, I feel like headless ui has the right approach in that it only does the behaviour and lets you style as you wish.. but headless.ui doesn't have toasts and they apparently don't intend to support them either.
10 replies
NNuxt
Created by JavascriptMick on 5/7/2023 in #❓・help
What are people using for Toasts?
I think I'm just going to integrate notifications into my Pinia state and use DaisyUI to style them. I looked at all the component libraries and they all feel a bit heavy and when it comes to actually doing the toast behaviours, they don't actually have them (e.g. headless UI and FlowbiteI usually like to get a bit funky with notification state anyway e.g. keeping around a list of notifications that have already 'closed' in case you want to go back to them. If I get this working, will post a link to the source here.
10 replies
NNuxt
Created by JavascriptMick on 4/13/2023 in #❓・help
Best Design system for SAAS app?
ok ok, looks like tailwind has won the mindshare war and is friking everywhere 🙂 why would I buck the trend
10 replies
NNuxt
Created by roga on 3/23/2023 in #❓・help
Nuxt & Supabase Auth
I don't have your exact problem but I have my supabase auth and guards working pretty good here https://github.com/JavascriptMick/nuxt3-boilerplate hth
7 replies
NNuxt
Created by JavascriptMick on 4/7/2023 in #❓・help
Global onMounted for Pinia initialisation?
for now I have resolved this by specifying onMounted for every page where the user needs to be initialised. The store function is idempotent and does no work if it is not required. This seems to work. Thanks for your help @chakraecho
8 replies
NNuxt
Created by JavascriptMick on 4/7/2023 in #❓・help
Global onMounted for Pinia initialisation?
ok so I did the plugin and it does invoke my store function but now inside the store function, the trpc client supplied by trpc-nuxt is not available via useNuxtApp
const { $client } = useNuxtApp();
const { dbUser } = await $client.auth.getDBUser.query();
const { $client } = useNuxtApp();
const { dbUser } = await $client.auth.getDBUser.query();
[nuxt] [request error] [unhandled] [500] Cannot read properties of undefined (reading 'auth')
8 replies