stubailo / meteor-rest

:sleeping: simple:rest - make your Meteor app accessible over HTTP and DDP alike
https://atmospherejs.com/simple/rest
MIT License
382 stars 85 forks source link

Custom route for collection endpoint #94

Open jykae opened 8 years ago

jykae commented 8 years ago

How to define custom route for collection endpoint? I was able to do that for publications but I would like to have all API endpoints under /api route.

stubailo commented 8 years ago

collection endpoint

What do you mean by collection endpoint?

jykae commented 8 years ago

I have looked through the package code and I can see that you scroll through all publications, methods, collections that exist in the project.

I mean actually "collection methods". https://github.com/stubailo/meteor-rest/blob/master/packages/rest/README.md#collection-methods

I would like to be able to configure at least the route like I can do with publications, https://github.com/stubailo/meteor-rest/blob/master/packages/rest/README.md#options-for-meteorpublish-added-by-this-package

As I see it is usually a good way to have REST API under eg. "/api/collection" route for API user experience. Subdomain eg. "api.github.com/endpoint" way is ofc the other way, but we are currently bundling API within the application for the first version at least.

Could we have also GET method generated for "collection methods" to have full CRUD support for each collection automatically? GET all and GET with id for example. Then we would not need to use separate publication to generate GET endpoint for collection.

Sorry for the short initial report, ask if something is for this feature request is not clear, we could possibly contribute for the package as this looks nice overall what you are doing :)

stubailo commented 8 years ago

Could we have also GET method generated for "collection methods" to have full CRUD support for each collection automatically? GET all and GET with id for example. Then we would not need to use separate publication to generate GET endpoint for collection.

Sounds like you're looking for Restivus. If you want a more RESTful approach, that is the package you should use. The purpose of simple:rest (probably misnamed but nobody would get simple:http-api) is specifically for methods and publications rather than generating a whole new set of REST endpoints just for your API.

But if what we are asking for is just a simple way to add a prefix to the collection methods, we can do that.

jykae commented 8 years ago

The latter one is fine. I like the meteoristic approach, "simple way", binding automatically to existing collections is nice. Just some configuration options is what we would like to have: control over routes/endpoints, where the resources are AND what we expose publicly through REST API.