5

What is about a REST API? Is there already a way to define some routes and logic for the API on the server? I think this is nowadays a must-have feature.

And the same with File-Uploads. With express framework I can already handle uploads really easy. How do I do this in Meteor? The documentation says nothing about it. So are there some plans to implement it? Or is there already a way?

om-nom-nom
  • 62,329
  • 13
  • 183
  • 228
krevativ
  • 530
  • 1
  • 8
  • 9
  • The "REST API" part is a duplicate of [How to expose a RESTful web service using Meteor](http://stackoverflow.com/questions/10150538/how-to-expose-a-restful-web-service-using-meteor), which has far better answers. – Dan Dascalescu Apr 28 '15 at 22:24

2 Answers2

9

As far as REST goes: Meteor doesn't yet provide a supported API for serving HTTP from your application. This is intentional: in the not-too-distant future, your application server is likely to not be just a single process directly serving end users, but an arbitrarily parallelizable service behind a proxy tier. So we'll need to provide a supported API for responded to HTTP requests (for example, REST) that continues to work in such a setting.

If you really need to accept direct HTTP REST requests now, take a peek at how packages/accounts-oauth-helper/oauth_server.js uses __meteor_bootstrap__.app to hook into the Connect middleware framework. This will work for now, but we don't promise that Meteor will always be powered by Connect :)

Supporting REST endpoints is on Meteor's roadmap.

So is file uploads (that's what binary type refers to).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
David Glasser
  • 1,438
  • 13
  • 21
  • 1
    Another example of setting up HTTP endpoints can be found in Tom Coleman's meteor-router package. https://github.com/tmeasday/meteor-router/blob/master/router_server.js#L151 – avital Dec 14 '12 at 01:34
  • The "REST API" part is a duplicate of [How to expose a RESTful web service using Meteor](http://stackoverflow.com/questions/10150538/how-to-expose-a-restful-web-service-using-meteor), which has updated answers. – Dan Dascalescu Apr 28 '15 at 22:25
0

I have been using https://github.com/crazytoad/meteor-collectionapi#readme

Which will create rest endpoints on your collections right out of the box. You can use meteorite to install it.

Community
  • 1
  • 1
Nahim N
  • 9
  • 1
  • The "REST API" part is a duplicate of [How to expose a RESTful web service using Meteor](http://stackoverflow.com/questions/10150538/how-to-expose-a-restful-web-service-using-meteor), which has updated answers. – Dan Dascalescu Apr 28 '15 at 22:26