RESTful Api's not grouped according to group resource
FilledStacks opened this issue · comments
When using the package as intended and described here "Each of the resources will expose a single cloud function endpoint using express and we will internally split the paths and perform the intended actions.".
Currently the endpoints overwrite each other with this url
http://localhost:5000/boxtout-production/us-central1/restful-api
They are organized as follows:
functions
src
orders
restful
getOrders.endpoint.js
getMenuItems.endpoint.js
payments
restful
addPayment.endpoint.js
...
When we build the backend all the function won't live in the same folder. This is a common practice when building a system that multiple developers will work on or if the project is intended to be worked on over multiple years. The way we build the backend using the firebase-backend package is by creating major resources groups which are divided into two parts.
- Reactive functions: A function that will only run in reaction to a change in firebase's database, auth, cloud storage or any other service with a trigger event on it.
- RESTful function: A restful endpoint for the dedicated resource that will only run when called directly through an http request.
As an example we can look at the boxtout backend (which is why this package is being built). It's split into 5 major "parts" of the backend:
- Orders
- Users
- Payments
- Products
- Tips
As it was originally built in the boxtout src when publishing the .endpoint.ts functions it created an api for each group. This package does not do that. I expect 1 of the following to be true when publishing my backend restful functions.
- Each group has its own api (original)
This would publish urls looking something like this:
http://localhost:5000/boxtout-production/us-central1/orders-api/{endpointName}
http://localhost:5000/boxtout-production/us-central1/users-api/{endpointName}
http://localhost:5000/boxtout-production/us-central1/payments-api/{endpointName}
http://localhost:5000/boxtout-production/us-central1/products-api/{endpointName}
- One api is published for the backend with a dedicated resource path per resource grouping
http://localhost:5000/boxtout-production/us-central1/api/order/{endpointName}
http://localhost:5000/boxtout-production/us-central1/api/users/{endpointName}
http://localhost:5000/boxtout-production/us-central1/api/payments/{endpointName}
http://localhost:5000/boxtout-production/us-central1/api/products/{endpointName}
@r0hit-gupta please look at this when you get a chance
Clone and test the functionality on this branch of boxtout. It attempts to make use of the firebase-backend package.
run npm run serve
to run locally and see if the api is being grouped according to this issue above.