Trying to dynamically provide an API services composable
Hey ninjas, I came through creating an API service that loads firebase or restful API.
I made it as a composable and it might be my fault because it is not working properly
in the root of
composables
directory, here is the setup:
The idea I came up with is to use store parameters enabling the admin to choose the desired API service, what I've noticed is that it is not loading all the composable, or the IDE cannot see the definitions since I am using typescript.
any insights will be appreciated π12 Replies
put it in
server/utils
and you should be good πWill try it, thanks for the heads up π
@Flo I got issues because it is not supported to use or call composables outside any nuxt defined context/hook.
I think I have an issue with my approach as a higher level arc.
Let me share with you the inputs I have and see.
So, for firebase, I have to consume the composables SDK, for example (a logout function):
when I put that function in a composable, then call it from a parent, typescript shouts π
Composables only work on pages/components, not in server stuff
yeah you are right
Need to say, I have no clue about firebase
no worries π appreciate your responses though π
looks like you're doing some kind of oauth flow?
That's a perfect vision! β₯
I was trying to create a POC to put mix of stuff together to work in a rythm. Using
@sidebase/nuxt-auth
alongside with the backend service could be a cool thing. So my imagination sees the following:
1. Setting up auth middlewares
2. add Rest API service
3. add cloud/serverless service
I know it might look a crazything π
I was thinking of providing multiple API services to choose from or to work in parallel, but it looks complex a bit as it needs some engineering
the current issue is that typescript gets confused when nesting composables and recalling them, let's say:
I'm actually using sidebase/nuxt-auth with no issues
straightforward following the docs
Me too, I am using 'local' auth type and it works really well with any API, tried it with firebase, strapi, github and more
We're doing a combination of keycloak and local auth, local for developers
interesting
Yes, I needed to unite the API interfaces, Rest methods and Firebase methods should have name naming π
it really took time for me to understand it fully. May be because it is my first time getting my hands dirty doing it π