12

I need the Meteor server to handle a very simple POST request not coming from the application client. With Express, I'd just do something like app.post('/something', function....

Is there an equivalent in Meteor? If not, how should I set this up, startup an Express server in a is_server context?

Hudon
  • 1,636
  • 18
  • 28
  • Just checked in IRC (#meteor on irc.freenode.net) and was told that this is simply not implemented (yet). – Hudon Apr 23 '12 at 15:33
  • it doesn't provide because Meteor isn't designed to work that way. The docs tell it's designed for real time communication, not Rest – Parth Thakkar May 10 '12 at 17:04
  • You can run a REST API with Meteor as described at [How to expose a RESTful Web Service using Meteor](http://stackoverflow.com/questions/10150538/howto-expose-a-restful-web-service-using-meteor) – Dan Dascalescu Nov 14 '12 at 19:53

3 Answers3

6

Meteor does not yet have the built in functionality to provide a restful API.

greggreg
  • 11,945
  • 6
  • 37
  • 52
  • 1
    Is there anyone working on it? Is there any plans of implementing it? – zVictor Jun 26 '12 at 23:23
  • 1
    Is it impossible to implement given the architecture? – lefnire Jul 26 '12 at 15:00
  • @lefnire: REST support can be implemented with Meteor - see [Can I mount another route handler through __meteor_bootstrap__.app?](http://stackoverflow.com/questions/10119777/can-i-mount-another-route-handler-through-meteor-bootstrap-app). Greg: Any chance to update your answer? – Dan Dascalescu Nov 14 '12 at 19:43
  • There is now another option: [meteor-collectionapi](https://github.com/crazytoad/meteor-collectionapi), see my answer below. – kynan Jun 15 '13 at 13:53
2

You can build basic routing into our application using Backbone, as in the Meteor example provided here: http://meteor.com/examples/todos

You can do something like this:

var AppRouter = Backbone.Router.extend({
  routes: {
    "": "dashboard",
    "home": "dashboard",
    "profile": "profile",
},

profile: function () {
    Session.set("current_view", "profile")
    this.navigate('profile', {trigger: true});
},

Also take a look at: How to expose a RESTful Web Service using Meteor

Community
  • 1
  • 1
andreimpop
  • 331
  • 2
  • 8
1

Alternatively you can serve RESTful APIs with Meteor using the meteor-collectionapi Atmosphere package. See also Is Meteor an option, if i need an additional REST API?.

Community
  • 1
  • 1
kynan
  • 13,235
  • 6
  • 79
  • 81