I know that the difference between firebase's cloud callable functions and http functions have been clarified here. However, I still find myself confused in terms of the specific use case of building an API for CRUD operations to the firestore.
I know how to do this with http functions and express, but http functions don't pass a context with user tokens like how callable functions does.
Can/how do you create a router similar to how one would with express with http functions (see below) that allow you to create an API that can handle GET, POST, PUT, and DELETE requests for public and private routes with middleware all within one callable function? Or would you need to create a new callable function for each "route"?
// Define Routes
app.use('/api/users', require('./routes/users'));
app.use('/api/auth', require('./routes/auth'));
app.use('/api/contacts', require('./routes/contacts'));
Can you also hook up the callable function to be called from firebase hosting on particular routes like http functions can (see below)?
"hosting": {
"public": "client/build",
"rewrites": [
{
"source": "/api{,/**}",
"function": "api"
},
{
"source": "**",
"destination": "/index.html"
}
]
},
Or would it just be better to stick with passing an express app through http functions and authenticating by just passing the user token in the request headers?